Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6251319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:35:30+00:00 2026-05-24T13:35:30+00:00

I just started working on a project that was developed in Visual C++ 2005

  • 0

I just started working on a project that was developed in Visual C++ 2005 using MFC, by someone else. To do so, I installed Visual C++ 2010 – I have no experience using either version (or visual studio at all, for that matter).

The application has a menu bar that is implemented using the CMenu class, and is initialized from a resource (ie, is created using the menu editor).

If I run the application in debug mode, the following debug assertion fails as soon as I open any menu in the menu bar:

Filename: afxwin1.inl

Assertion (with appropriate context):



    _AFXWIN_INLINE HMENU CMenu::GetSafeHmenu() const
        { ASSERT(this == NULL || m_hMenu == NULL || ::IsMenu(m_hMenu));
            return this == NULL ? NULL : m_hMenu; }

According to the debugger, this is set to a pointer to my menu, and this->m_hMenu is set to a pointer as well – however, the debugger seems to be confused about the type, the value is 0xdeadbeef {unused=??? } (for a more boring value of 0xdeadbeef, of course).

It would seem that something is broken, and most likely in the project code – I am aware of this. However, if I create a release build, it runs without errors, and the menu is displayed correctly. Moreover, I edited the menu using the menu editor in Visual C++ 2010, and saved it – there was no change. I’m therefore ruling out menu compatibility issues from the resource being in the wrong format.

I am running Windows XP SP3 on a ThinkPad T61p.

The code that creates the menu is



    CMenu menu;
    menu.LoadMenu(RESOURCE_NAME);
    SetMenu(&menu);

And runs in the context of a subclass of CFrameWnd.

I have searched google a lot and am fairly certain that nobody had this problem before; Also, I’m a newbie to all of C++, MFC and Visual Studio. Help would be immensely appreciated; If I can provide more problem metadata, please tell me and I will do so.
Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:35:31+00:00Added an answer on May 24, 2026 at 1:35 pm

    According to MSDN (http://msdn.microsoft.com/en-us/library/177ay1x0.aspx)

    CMenu::LoadMenu() requires a parameter to be passed in, which is missing in your sample code.
    Do check on that and make sure you are passing a valid menu resource id.

    Edit:

    Your menu object is constructed on the stack and will be destroyed once it went out of scope.
    Where are you calling your CWnd::SetMenu from ? You need to make sure the object lifespan can last until the next CWnd::SetMenu else you will be holding/referring a dangling pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started working on a new project that already contains a .svn folder
I've just started working on an ASP.NET project which I hope to open source
I've just started working with ASP.NET MVC now that it's in beta. In my
Have just started using Google Chrome , and noticed in parts of our site,
I just started working on an existing grails project where there is a lot
Sorry for my bad English. I just started working on my school final's project
I am new to ASP and ASP.net. I have just started working on a
I just started working for a pretty large company and my group manages all
I'm just getting started working with foreign keys for the first time and I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.