I decided to try this

This is a discussion on I decided to try this within the Windows Programming forums, part of the Platform Specific Boards category; I decided to update my (pathetic) HTML editor. I wanted to make a dialog box with a menu. In Petzold's ...

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    I decided to try this

    I decided to update my (pathetic) HTML editor. I wanted to make a dialog box with a menu. In Petzold's book, it say that you can create a menu like this:
    Code:
    MENU menu-name
    in the resource script, but as soon as I attempt to execute my program, it decides not to even come up! When I remove my menu, it works fine. IS PETZOLD WRONG...?? (GOD FORBID)

    Thanks
    -Chris

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >MENU menu-name

    You might try:
    menu-name MENU

    Although you may actually have to throw in some menu items for this to work.

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    what the...?

    Are you sure that that will work? That doesn't really make sense to me...

  4. #4
    Registered User
    Join Date
    Sep 2001
    Location
    England
    Posts
    121
    Shouldnt this be in Windows Programming? Anyway I havent had any experience programming resources manually, but this is some code I ripped out of the program I'm working on at the moment. It's MSVC generated but it looks similar to what you're doing. IDR_TYKETYPE is a menu resource in VC++ but I think it's the same thing as the menu name (?).

    Code:
    IDR_TYKETYPE MENU DISCARDABLE 
    BEGIN
        POPUP "&File"
        BEGIN
            MENUITEM "&New\tCtrl+N",                ID_FILE_NEW
            MENUITEM "&Open...\tCtrl+O",            ID_FILE_OPEN
            MENUITEM SEPARATOR
            MENUITEM "P&rint Setup...",             ID_FILE_PRINT_SETUP
            MENUITEM SEPARATOR
            MENUITEM "Recent File",                 ID_FILE_MRU_FILE1, GRAYED
            MENUITEM SEPARATOR
            MENUITEM "E&xit",                       ID_APP_EXIT
        END
        POPUP "&1 Booking In"
        BEGIN
            MENUITEM "&1 Rollers",                  32772
            MENUITEM "&2 Production List",          32773
            MENUITEM "&3 Sub Contract",             32774
            MENUITEM "&4 Roller Count",             32775
            MENUITEM "&5 Job Status",               32776
            MENUITEM "&6 Print Outstanding Job Value", 32777
        END
    END

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>> MENUITEM "&1 Rollers", 32772

    Unless you have a really good reason, it is a bad idea to use literals here, much better to use symbolic names and define all the symbols in a header. One day when you've got thousands of them, and you really can't figure out why your getting the action you are getting, you'll wish you had!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Robert602, what you have there (I think) is the resource script for a menu. What i'm trying to do is attactch a menu to a dialog box. MENU menu-name is supposed to go where you script the dialog where menu-name is the name of the menu that you have already created. This doesn't seem to work though, even though its in 'Programming Windows 5th Edition' by Charles Petzold...

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    381
    You'll probbly have to put up more code.
    But if its outside of the code then you'll probbly have to use HMENU instead of just MENU.

  8. #8
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Would I be able to create my dialog using CreateWindow() in order to specify the menu, or isn't this possible?

  9. #9
    Registered User
    Join Date
    Jan 2002
    Posts
    381
    Yes.
    Try somthing like WS_POPUP.

  10. #10
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    so...would this work?
    Code:
    hDlg = CreateWindow (szAppName, szCaption,
                              WS_POPUP,
                              CW_USEDEFAULT, CW_USEDEFAULT,
                              CW_USEDEFAULT, CW_USEDEFAULT,
                              NULL, NULL, hInstance, NULL) ;
    Or should I include more style parameters?

  11. #11
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    is it possible to move this thread to the Windows Programming board?

  12. #12
    Registered User
    Join Date
    Jan 2002
    Posts
    381
    You'll have to tinker with it a bit, but your heading in the right direction.
    But you'll have to add the controls to the window yourself.

  13. #13
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    I understand, but this still doesn't explain why my book ('Programming Windows 5th Edition' by Charles Petzold) says that you can add a menu to your dialog box simply by placing Menu menu-name into your code.... By the way, its on page 494, for anyboy who has the book. C'mon you 'Pezold Patriots' (lol).

  14. #14
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    I don't know about other compilers but in MSVC you can insert a menu resource directly into a dialog.

    Create the dialog and menu. In the dialog, get its properties. Bottom right, below caption is the spot for the menu ID.

    Use DrawMenuBar() and / or GetMenu() with the dialogs HWND.

    Sometimes need to paint it before it displays. Beware of dialogs / windows with the CHILD style as they are not ment to have menus. Will work under Win98 but is harder under Win2000 / XP
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  15. #15
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Yes, I am using MSVC (thank god)

    THANKS! That sounds right from what i've read. I'll give that a try. Thanks again.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hello, bored reading and a bunch of questions.
    By Jorl17 in forum C++ Programming
    Replies: 13
    Last Post: 04-03-2008, 06:43 PM
  2. So I decided to use function pointers in my code for the first time...
    By A10 in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 11-13-2007, 07:13 AM
  3. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 08:41 PM
  4. Full Sail
    By AKrampovitis in forum Game Programming
    Replies: 38
    Last Post: 06-01-2005, 09:21 AM
  5. I've decided Bush is right, and we're wrong.
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 03-30-2005, 09:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21