Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Trying to add a menu bar to a dialog

Trying to add a menu bar to a dialog

Scheduled Pinned Locked Moved C / C++ / MFC
comlinuxlearning
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    hi I am trying to add a MENU bar to my Dialog when I look at this link seems I should be able to DIALOG resource - Win32 apps | Microsoft Docs[^] however after I add it

    IDD_DIALOG21 DIALOGEX 0, 0, 790, 321
    MENU IDR_MAINFRAME
    STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
    CAPTION "Dialog"
    FONT 8, "MS Shell Dlg", 400, 0, 0x1
    BEGIN
    CONTROL "",IDC_RICHEDIT21,"RichEdit20A",ES_MULTILINE | WS_BORDER | WS_TABSTOP,27,7,780,273
    LTEXT "Static",IDC_STATIC15,7,7,20,273,WS_CLIPSIBLINGS
    END

    and open up the dialog in the resource editor it doesn't display I tried creating a new project "Dialog Based" and the menu (control to add it ) in the wizard was grayed out thanks

    L L V 3 Replies Last reply
    0
    • F ForNow

      hi I am trying to add a MENU bar to my Dialog when I look at this link seems I should be able to DIALOG resource - Win32 apps | Microsoft Docs[^] however after I add it

      IDD_DIALOG21 DIALOGEX 0, 0, 790, 321
      MENU IDR_MAINFRAME
      STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
      CAPTION "Dialog"
      FONT 8, "MS Shell Dlg", 400, 0, 0x1
      BEGIN
      CONTROL "",IDC_RICHEDIT21,"RichEdit20A",ES_MULTILINE | WS_BORDER | WS_TABSTOP,27,7,780,273
      LTEXT "Static",IDC_STATIC15,7,7,20,273,WS_CLIPSIBLINGS
      END

      and open up the dialog in the resource editor it doesn't display I tried creating a new project "Dialog Based" and the menu (control to add it ) in the wizard was grayed out thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I don't have a VS version that includes the resource editor, so I have to do things manually. However, I can confirm that dialog boxes work fine with menus.

      F 1 Reply Last reply
      0
      • F ForNow

        hi I am trying to add a MENU bar to my Dialog when I look at this link seems I should be able to DIALOG resource - Win32 apps | Microsoft Docs[^] however after I add it

        IDD_DIALOG21 DIALOGEX 0, 0, 790, 321
        MENU IDR_MAINFRAME
        STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
        CAPTION "Dialog"
        FONT 8, "MS Shell Dlg", 400, 0, 0x1
        BEGIN
        CONTROL "",IDC_RICHEDIT21,"RichEdit20A",ES_MULTILINE | WS_BORDER | WS_TABSTOP,27,7,780,273
        LTEXT "Static",IDC_STATIC15,7,7,20,273,WS_CLIPSIBLINGS
        END

        and open up the dialog in the resource editor it doesn't display I tried creating a new project "Dialog Based" and the menu (control to add it ) in the wizard was grayed out thanks

        L Offline
        L Offline
        leon de boer
        wrote on last edited by
        #3

        Easy to do it manually .. inside WM_INITDIALOG assuming the dialog window handle is hWnd Try this

        		HMENU hMenubar;
        		HMENU hMenu;
        
        		hMenubar = CreateMenu();
        		hMenu = CreateMenu();
        
        		AppendMenuW(hMenu, MF\_STRING, 10000, "&New");
        		AppendMenuW(hMenu, MF\_STRING, 10001, "&Open");
        		AppendMenuW(hMenu, MF\_SEPARATOR, 0, NULL);
        		AppendMenuW(hMenu, MF\_STRING, WM\_QUIT, "&Quit");
        
        		AppendMenuW(hMenubar, MF\_POPUP, (UINT\_PTR)hMenu, "&File");
        		SetMenu(hWnd, hMenubar);
        

        In vino veritas

        F 1 Reply Last reply
        0
        • L leon de boer

          Easy to do it manually .. inside WM_INITDIALOG assuming the dialog window handle is hWnd Try this

          		HMENU hMenubar;
          		HMENU hMenu;
          
          		hMenubar = CreateMenu();
          		hMenu = CreateMenu();
          
          		AppendMenuW(hMenu, MF\_STRING, 10000, "&New");
          		AppendMenuW(hMenu, MF\_STRING, 10001, "&Open");
          		AppendMenuW(hMenu, MF\_SEPARATOR, 0, NULL);
          		AppendMenuW(hMenu, MF\_STRING, WM\_QUIT, "&Quit");
          
          		AppendMenuW(hMenubar, MF\_POPUP, (UINT\_PTR)hMenu, "&File");
          		SetMenu(hWnd, hMenubar);
          

          In vino veritas

          F Offline
          F Offline
          ForNow
          wrote on last edited by
          #4

          thanks

          1 Reply Last reply
          0
          • L Lost User

            I don't have a VS version that includes the resource editor, so I have to do things manually. However, I can confirm that dialog boxes work fine with menus.

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            ok maybe it only display them when you do a SHowWindow

            L 1 Reply Last reply
            0
            • F ForNow

              hi I am trying to add a MENU bar to my Dialog when I look at this link seems I should be able to DIALOG resource - Win32 apps | Microsoft Docs[^] however after I add it

              IDD_DIALOG21 DIALOGEX 0, 0, 790, 321
              MENU IDR_MAINFRAME
              STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
              CAPTION "Dialog"
              FONT 8, "MS Shell Dlg", 400, 0, 0x1
              BEGIN
              CONTROL "",IDC_RICHEDIT21,"RichEdit20A",ES_MULTILINE | WS_BORDER | WS_TABSTOP,27,7,780,273
              LTEXT "Static",IDC_STATIC15,7,7,20,273,WS_CLIPSIBLINGS
              END

              and open up the dialog in the resource editor it doesn't display I tried creating a new project "Dialog Based" and the menu (control to add it ) in the wizard was grayed out thanks

              V Offline
              V Offline
              Victor Nijegorodov
              wrote on last edited by
              #6

              ForNow wrote:

              after I add it

              IDD_DIALOG21 DIALOGEX 0, 0, 790, 321
              MENU IDR_MAINFRAME
              ...
              END

              and open up the dialog in the resource editor it doesn't display

              Did you create the menu IDR_MAINFRAME itself?

              F 1 Reply Last reply
              0
              • F ForNow

                ok maybe it only display them when you do a SHowWindow

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                I thought you were talking about a modal dialog.

                1 Reply Last reply
                0
                • V Victor Nijegorodov

                  ForNow wrote:

                  after I add it

                  IDD_DIALOG21 DIALOGEX 0, 0, 790, 321
                  MENU IDR_MAINFRAME
                  ...
                  END

                  and open up the dialog in the resource editor it doesn't display

                  Did you create the menu IDR_MAINFRAME itself?

                  F Offline
                  F Offline
                  ForNow
                  wrote on last edited by
                  #8

                  IDR_MENU is defined in my resource file I basically took the menu for the MainFrame and wanted to use it for the Dialog Opening up The resource editor I am beginning to think when you view a dialog with menu it wont display it There is a only a way to view the menu by itself once I get my code going and do a ShowWindow for the Dialog i'll see if it displays the menu

                  IDR_MAINFRAME MENU
                  BEGIN
                  POPUP "&File"
                  BEGIN
                  MENUITEM "E&xit", ID_APP_EXIT
                  END
                  POPUP "&Edit"
                  BEGIN
                  MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO
                  MENUITEM SEPARATOR
                  MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
                  MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
                  MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
                  END
                  POPUP "&View"
                  BEGIN
                  MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
                  MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
                  END
                  POPUP "&ProgDebug"
                  BEGIN
                  MENUITEM "Program Debug", ID_DEBUG
                  END
                  POPUP "&Asidlist"
                  BEGIN
                  MENUITEM "Address Space List", ID_ASID
                  END
                  POPUP "&Help"
                  BEGIN
                  MENUITEM "&About DBGR...", ID_APP_ABOUT
                  END
                  END

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups