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

  • SEARCH
  • Home
  • 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 8529953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:08:49+00:00 2026-06-11T09:08:49+00:00

In my MFC dialog based application I have main menu created with Visual Studio

  • 0

In my MFC dialog based application I have main menu created with Visual Studio resource editor, and in one place there is dynamic menu, created at run time. All parts of menu that are created with Visual studio have modern look, and my dynamically created sub-menu has old look, as shown in image below.

enter image description here

My code for creating dynamic sub-menu is something like this (not the real code, but real code is not all that important):

CMenu subMenu;
subMenu.CreateMenu();

for (...)
{
    subMenu.AppendMenu(
        MF_STRING | (isChecked ? MF_CHECKED : MF_UNCHECKED),
        <some menu ID>,
        <some menu text>);
}

Inserting this sub-menu to where it belongs is done like this (pretty much the actual code):

TCHAR szMenuString[256];
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE | MIIM_ID | MIIM_SUBMENU | MIIM_CHECKMARKS |
    MIIM_DATA | MIIM_STRING | MIIM_BITMAP | MIIM_FTYPE;
mii.dwTypeData = szMenuString;
mii.cch = sizeof(szMenuString) / sizeof(szMenuString[0]);

GetMenu()->GetMenuItemInfo(ID_SUBMENU, &mii);
mii.fMask |= MIIM_SUBMENU;
mii.hSubMenu = subMenu.GetSafeHmenu();
GetMenu()->SetMenuItemInfo(ID_SUBMENU, &mii);

How can I create my sub-menu so that it appears the same in style as the rest of the main menu?

My code is written in MFC, but your answer does not have to be in MFC (and probably cannot be).

  • 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-06-11T09:08:50+00:00Added an answer on June 11, 2026 at 9:08 am

    I discovered the solution, but don’t really understand what was happening. The solution is to prevent calling DestroyMenu on subMenu‘s destructor at the end of the function. This is done by either calling subMenu.Detach(), or making subMenu a pointer to CMenu.

    What I don’t understand is why is DestroyMenu turning new style menu to old style. I would expect that the menu is either destroyed and not shown, or copied in SetMenuItemInfo and so its style preserved. Whoever provides an answer to this one gets my vote 🙂

    Also, I would like to know if I’m producing a resource leak by calling Detach here, or is my dynamic sub-menu destroyed along with the main menu. Points await the one who provides an answer.

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

Sidebar

Related Questions

I have a MFC dialog based application. The main dialog contain a child dialog
I have created Dialog Based application in MFC (VS 2008).When I do #include in
I have an MFC-driven dialog-based application created with MSVS2005. Here is my problem step
The MFC application that i created is dialog based. Just one dialog thats all.
I am developing MFC Dialog based application in Visual Studio 2008. I want to
I have a MFC dialog based application in which I use ::system() function to
How can I print a document using MFC Dialog Based Application? I have made
I have written a runtime-created dialog class that doesn't use any resource files based
Language: Visual C++, MFC Environment: Visual Studio 2005 I have a dialog that requires
I have a dialog based MFC application through which I have to call a

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.