I just started to learn MFC. I know moderate WinAPI, but hardly ever use it, so it's extremely rusty.
For some reason when I tried to add a test menu to my program I began to encounter strange crashes. I trapped the failure but I can't find anything wrong with my code.. please help.
Some facts:
-My menu was created using the Menu Creation dialog tool, IDR_MENU2 is the name of it in the resource.h file.
The message pops up "Error: 0" then my app crashes (when i try to update the nonexistant HWND).Code:PHP Code:/*my window class*/ class CMainWin : public CFrameWnd { public: CMainWin(); afx_msg void OnLButtonDown(UINT flags, CPoint loc); afx_msg void OnRButtonDown(UINT flags, CPoint loc); afx_msg void OnTest(); DECLARE_MESSAGE_MAP() }; /*my Constructor*/ CMainWin::CMainWin() { if(!Create(NULL, "MFC is as easy as 810,92,443",WS_OVERLAPPEDWINDOW,rectDefault,NULL,"IDR_MENU2")) { char buf[256]; sprintf(buf,"Error: %d",GetLastError()); AfxMessageBox(buf,MB_OK,0); } } /*my message map*/ BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) ON_WM_LBUTTONDOWN() ON_WM_RBUTTONDOWN() ON_COMMAND(ID_TEST,OnTest) ON_COMMAND(ID_TEST_GO,OnTest) END_MESSAGE_MAP() /*and from the resource.h*/ #define IDR_MENU2 111 #define ID_TEST 112 #define ID_TEST_GO 113
If anyone has any ideas, or if you think i need to put more info up here, please respond. Thanks in advance![]()



LinkBack URL
About LinkBacks



