Hello
i've compiled the following app:
main.cpp:
resource.rc:Code:#include <afxwin.h> #include "resource.h" class C_MyApp : public CWinApp { public: BOOL InitInstance(); }; class C_MainFrame : public CFrameWnd { public: C_MainFrame(); private: int m_nBeeps; void OnOneBeep(); // declare fxns that respond void OnFourBeeps(); // to menu items void OnGreeting(); void OnTimer(UINT); // declare fxn that responds // to WM_TIMER messages CMenu Menu; DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(C_MainFrame, CFrameWnd) // define message map ON_COMMAND(ID_ONE_BEEP, OnOneBeep) // WM_COMMAND messages ON_COMMAND(ID_FOUR_BEEPS, OnFourBeeps) // are from menu items ON_COMMAND(ID_GREETING, OnGreeting) ON_WM_TIMER() // for WM_TIMER message END_MESSAGE_MAP() C_MainFrame::C_MainFrame() { Menu.LoadMenu(IDR_MENU1); CRect WindowRect(100, 150, 600, 400); this->SetMenu(&Menu); HBRUSH hredBrush = CreateSolidBrush(RGB(255, 0, 0)); CString MyWindowClass = AfxRegisterWndClass( CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, AfxGetApp()->LoadCursor(IDC_CURSOR1), hredBrush, AfxGetApp()->LoadIcon(IDI_ICON1)); Create(MyWindowClass, L"Main Window C", WS_CAPTION | WS_SYSMENU | //"Bitwise-OR" all WS_VSCROLL | WS_HSCROLL | //attribute styles WS_SIZEBOX, WindowRect); //Create(NULL, L"Menus - Example A", WS_OVERLAPPEDWINDOW, // WindowRect, NULL, MAKEINTRESOURCE(IDR_MENU2)); LoadAccelTable(MAKEINTRESOURCE(IDR_ACCELERATORS)); this->SetMenu(&Menu); m_nBeeps = 0; } BOOL C_MyApp::InitInstance() { m_pMainWnd = new C_MainFrame; m_pMainWnd->ShowWindow(m_nCmdShow); return TRUE; } C_MyApp theApp; void C_MainFrame::OnOneBeep() { ::MessageBeep(0); } void C_MainFrame::OnFourBeeps() { SetTimer(1, 200, NULL); } void C_MainFrame::OnGreeting() { int MyChoice = MessageBox(L"Hello there!\nDo you want four beeps?", L"Greeting", MB_ICONEXCLAMATION | MB_YESNOCANCEL); if (MyChoice == IDYES) OnFourBeeps(); } void C_MainFrame::OnTimer(UINT nID) { if (m_nBeeps == 4) { KillTimer(1); m_nBeeps = 0; return; } else { ::MessageBeep(0); m_nBeeps++; } }
resource.h:Code:// Microsoft Visual C++ generated resource script. // #include "resource.h" #include "winres.h" ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON1 ICON "icon1.ico" ///////////////////////////////////////////////////////////////////////////// // // Cursor // IDC_CURSOR1 CURSOR "cursor1.cur" ///////////////////////////////////////////////////////////////////////////// // // Menu // IDR_MENU1 MENU BEGIN POPUP "One Four Beeps" BEGIN MENUITEM "One Beep", ID_ONE_BEEP MENUITEM "Four Beeps", ID_FOUR_BEEPS END MENUITEM "Greeting", ID_GREETING END ///////////////////////////////////////////////////////////////////////////// // // Accelerator // IDR_ACCELERATORS ACCELERATORS BEGIN "g", ID_ONE_BEEP, ASCII, NOINVERT "G", ID_FOUR_BEEPS, ASCII, NOINVERT VK_RETURN, ID_ONE_BEEP, VIRTKEY, NOINVERT END
The work correctly in Release Mode but in debug mode i will get the following assertion:Code://{{NO_DEPENDENCIES}} // File di inclusione generato con Microsoft Visual C++. // Utilizzato da resource.rc // #define VS_VERSION_INFO 1 #define IDI_ICON1 101 #define IDR_MENU2 101 #define IDC_CURSOR1 102 #define IDR_MENU1 103 #define IDR_ACCELERATORS 105 #define ID_ONE_BEEP 106 #define ID_FOUR_BEEPS 107 #define ID_GREETING 108
What's the problem? How could i check the meaning of the assertion?Code:Debug Assertion Failed! Program: C:\WINDOWS\SYSTEM32\mfc140ud.dll File: d:\a01\_work\38\s\src\vctools\VC7Libs\Ship\ATLMFC\Src\MFC\winfrm.cpp Line: 2592


Reply With Quote

Victor Nijegorodov
