fork download
  1. class CMyWindow : public CFrameWnd
  2. {
  3. public:
  4. CMyWindow();
  5.  
  6. DECLARE_MESSAGE_MAP()
  7. afx_msg void OnEnd();
  8. afx_msg void OnAbout();
  9. afx_msg void OnPaint();
  10. afx_msg void OnDropFiles(HDROP hDropInfo);
  11. afx_msg void OnFileOpen();
  12. private:
  13. CImage m_image;
  14. // 画像を読み込む
  15. bool LoadImage(CString filename);
  16. };
  17.  
  18. void CMyWindow::OnPaint()
  19. {
  20. CPaintDC dc(this); // device context for painting
  21. // TODO: ここにメッセージ ハンドラー コードを追加します。
  22. // 描画メッセージで CFrameWnd::OnPaint() を呼び出さないでください。
  23. CDC bmpDC;
  24. CBitmap* cbmp;
  25.  
  26. cbmp = CBitmap::FromHandle(m_image);
  27. if (cbmp == NULL)
  28. return;
  29. bmpDC.CreateCompatibleDC(&dc);
  30. CBitmap* oldbmp = bmpDC.SelectObject(cbmp);
  31. dc.SetStretchBltMode(STRETCH_HALFTONE);
  32. dc.SetBrushOrg(0, 0);
  33. dc.StretchBlt(0, 0, 1024, 768, &bmpDC, 0, 0, m_image.GetWidth(), m_image.GetHeight(), SRCCOPY);
  34. bmpDC.SelectObject(oldbmp);
  35. cbmp->DeleteObject();
  36. bmpDC.DeleteDC();
  37. }
  38.  
  39. void CMyWindow::OnDropFiles(HDROP hDropInfo)
  40. {
  41. UINT length = DragQueryFile(hDropInfo, 0, NULL, 0);
  42. CString csfile;
  43. DragQueryFile(hDropInfo, 0, csfile.GetBuffer(length + 1), length + 1);
  44. csfile.ReleaseBuffer();
  45.  
  46. LoadImage(csfile);
  47. InvalidateRect(NULL, false);
  48. }
  49.  
  50. // 画像を読み込む
  51. bool CMyWindow::LoadImage(CString filename)
  52. {
  53. m_image.Destroy();
  54. m_image.Load(filename);
  55. return m_image.IsNull() ? true : false;
  56. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:1: error: expected class-name before ‘{’ token
 {
 ^
prog.cpp:6:22: error: ISO C++ forbids declaration of ‘DECLARE_MESSAGE_MAP’ with no type [-fpermissive]
  DECLARE_MESSAGE_MAP()
                      ^
prog.cpp:6:22: error: expected ‘;’ at end of member declaration
  DECLARE_MESSAGE_MAP()
                      ^
                       ;
prog.cpp:7:2: error: ‘afx_msg’ does not name a type
  afx_msg void OnEnd();
  ^~~~~~~
prog.cpp:8:2: error: ‘afx_msg’ does not name a type
  afx_msg void OnAbout();
  ^~~~~~~
prog.cpp:9:2: error: ‘afx_msg’ does not name a type
  afx_msg void OnPaint();
  ^~~~~~~
prog.cpp:10:2: error: ‘afx_msg’ does not name a type
  afx_msg void OnDropFiles(HDROP hDropInfo);
  ^~~~~~~
prog.cpp:11:2: error: ‘afx_msg’ does not name a type
  afx_msg void OnFileOpen();
  ^~~~~~~
prog.cpp:13:2: error: ‘CImage’ does not name a type
  CImage m_image;
  ^~~~~~
prog.cpp:15:17: error: ‘CString’ has not been declared
  bool LoadImage(CString filename);
                 ^~~~~~~
prog.cpp:18:6: error: no declaration matches ‘void CMyWindow::OnPaint()’
 void CMyWindow::OnPaint()
      ^~~~~~~~~
prog.cpp:18:6: note: no functions named ‘void CMyWindow::OnPaint()’
prog.cpp:1:7: note: ‘class CMyWindow’ defined here
 class CMyWindow : public CFrameWnd
       ^~~~~~~~~
prog.cpp:39:29: error: variable or field ‘OnDropFiles’ declared void
 void CMyWindow::OnDropFiles(HDROP hDropInfo)
                             ^~~~~
prog.cpp:39:29: error: ‘HDROP’ was not declared in this scope
prog.cpp:51:27: error: ‘bool CMyWindow::LoadImage’ is not a static data member of ‘class CMyWindow’
 bool CMyWindow::LoadImage(CString filename)
                           ^~~~~~~
prog.cpp:51:27: error: ‘CString’ was not declared in this scope
stdout
Standard output is empty