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 8555075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:02:13+00:00 2026-06-11T15:02:13+00:00

I`m trying to create a menu programmatically but the code below fails to create

  • 0

I`m trying to create a menu programmatically but the code below fails to create the popup menu in the second menu item (neighbor of file)(in first File->new etc. everything is fine).
When I click on View it does nothing instead of show SelectAll command.

HMENU menu = CreateMenu();
HMENU subMenu1 = CreatePopupMenu();

AppendMenu(subMenu1,MF_STRING,IDC_MENU_NEW,_T("New"));
AppendMenu(subMenu1,MF_STRING,IDC_MENU_EXIT,_T("Exit"));

AppendMenu(menu,MF_POPUP,(UINT_PTR)subMenu1,_T("File"));

SetMenu(dlg,menu);
HMENU menu2 = CreateMenu(); 
HMENU subMenu2 = CreatePopupMenu();

AppendMenu(menu,MF_INSERT,(UINT_PTR)menu2,_T("View"));
AppendMenu(subMenu2,MF_STRING,IDC_MENU_EXIT2,_T("Select All"));

AppendMenu(menu2,MF_POPUP,(UINT_PTR)subMenu2,_T("View"));

What am I doing wrong? Can you point me to somewhere to find the information?

  • 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-11T15:02:14+00:00Added an answer on June 11, 2026 at 3:02 pm

    I believe your error is on this line of code

    AppendMenu(menu,MF_INSERT,(UINT_PTR)menu2,_T("View"));
    

    MF_INSERT is not a valid flag for AppendMenu and in fact maps to MF_ENABLED. In this case I believe you want to use MF_POPUP to insert the ‘View’ Sub menu.

    This is how MSDN describes MF_POPUP:

    Specifies that the menu item opens a drop-down menu or submenu. The
    uIDNewItem parameter specifies a handle to the drop-down menu or
    submenu. This flag is used to add a menu name to a menu bar, or a menu
    item that opens a submenu to a drop-down menu, submenu, or shortcut
    menu.

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

Sidebar

Related Questions

I am trying to create a context menu item inside a fragment. But I
I am trying to create a menu with the following code. But I cannot
I'm trying to programmatically create the custom horizontal menu for my custom module, but
I'm trying to create some Menu Item with Image & Label, using barry's class
I am trying to create a menu bar with the following items: File, Database,
I am trying to create a dynamic menu by reading an XML file using
Im trying to create a menu item so when a user clicks on the
I am trying to create a menu with PySide. This is the code def
I am trying to create a hovering menu, but it doesn't work. I create
i'm on Mac 10.6, i'm trying to create a menu with Qt (Creator), but

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.