CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2022
    Posts
    11

    Unknown assertion

    Hello
    i've compiled the following app:

    main.cpp:
    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.rc:
    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
    resource.h:
    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
    The work correctly in Release Mode but in debug mode i will get the following 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
    What's the problem? How could i check the meaning of the assertion?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,276

    Re: Unknown assertion

    Quote Originally Posted by Quasar999 View Post
    ...
    What's the problem? How could i check the meaning of the assertion?
    Do the same like with any other assertion messagebox: press a Retry button to step in the code (line) caused this assertion.
    Or just find in your installation folder looking like:
    ...\Microsoft Visual Studio\<VS Version>\<version type>\VC\Tools\MSVC\<version no.>\atlmfc\src\mfc
    this winfrm.cpp file and look at its line 2592.
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured