I have created a very basic MFC Application but when i run it, it use 100% of my CPU resources. Here is the code:
Can anybody tell me what am i doing wrong?
Code:
#include <afxwin.h>
class CDrawingApp : public CWinApp {
public:
virtual BOOL InitInstance();
CDrawingApp() {};
};
class CMainFrame : public CFrameWnd {
public:
CMainFrame() {
Create( NULL, "DrawingApp" );
}
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP( CMainFrame, CFrameWnd )
ON_WM_PAINT()
END_MESSAGE_MAP()
BOOL CDrawingApp::InitInstance() {
m_pMainWnd = new CMainFrame;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
void CMainFrame::OnPaint() {
CDC *pDC = GetDC();
CRect lpRect;
lpRect.left = 50;
lpRect.top = 50;
lpRect.right = 300;
lpRect.bottom = 300;
pDC->Rectangle(lpRect);
ReleaseDC(pDC);
}
CDrawingApp theApp;