Thread: menus

  1. #1
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385

    menus

    is it better to include menus as a resource, hard code them, or create them on the fly?
    Monday - what a way to spend a seventh of your life

  2. #2
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    I know it realy depends on what you are doing. If you want the user to be able to modify them you would creat them on the fly. But if you are going to have a specific type of menu that is static (will not change), depends on how you like to code (hard code or resource). That should be able to give you an idea.
    C++ Is Powerful
    I use C++
    There fore I am Powerful

  3. #3
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227

    I like...

    I like to just put it in my code, and avoid resources wherever possible for some reason.

  4. #4
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    I agree

    The resources are mean and bad (lolz), load ur menu from a text file and create on the fly, And I STILL hav'nt gotton an answer about this mean resource and button Q I have on here.

    SPH

  5. #5
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227

    nooo

    no, don't load it from a TEXT file, just do something like....

    Code:
    /*excpert from ASMEdit...*/
    
    enum ID {ID_VIEW = 1, ID_FILE_EXIT = 9001, ID_FILE_OPEN = 9002, 
    ID_FILE_SAVE = 9003, ID_HELP_ABOUT = 9004, ID_CMPL_A86 = 9005,
    ID_CMPL_NASM = 9006, ID_FILE_NEW = 9007, ID_HELP_HELP = 9008};
    
    void MenuInit(HWND hwnd, HMENU hMenu, HMENU hSubMenu)
    {
    	hMenu = CreateMenu();
    
    	hSubMenu = CreatePopupMenu();
    	AppendMenu(hSubMenu, MF_STRING, ID_FILE_NEW, "&New");
    	AppendMenu(hSubMenu, MF_STRING, ID_FILE_OPEN, "&Open");
    	AppendMenu(hSubMenu, MF_STRING, ID_FILE_SAVE, "&Save");
    	AppendMenu(hSubMenu, MF_SEPARATOR, NULL, NULL);
    	AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "E&xit");
    	AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&File");
    
    	hSubMenu = CreatePopupMenu();
    	AppendMenu(hSubMenu, MF_STRING, ID_CMPL_A86, "Compile With A&86");
    	AppendMenu(hSubMenu, MF_STRING, ID_CMPL_NASM, "Compile With &NASM");
    	AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Compile With");
    
    	hSubMenu = CreatePopupMenu();
    	AppendMenu(hSubMenu, MF_STRING, ID_HELP_HELP, "&Help");
    	AppendMenu(hSubMenu, MF_STRING, ID_HELP_ABOUT, "&About ASMEdit...");
    	AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Help");
    	
    	SetMenu(hwnd, hMenu);
    }

  6. #6
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Talking Ken you've done it again lolz

    Ken! You noncompoop, thats wut I WAS TELLING THEM TO DO, just loaded from a file not hard coded strings lolz.

    SPH

  7. #7
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227

    so?

    mine's prettier.

  8. #8
    Registered User minime6696's Avatar
    Join Date
    Aug 2001
    Posts
    267

    Lightbulb Ding Ding

    Why dont u go on IM instead of filling my email box with stupid "KEN HAS REPLIED" messages!

    SPH

  9. #9
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227

    well

    why don't you try unblocking me, cuz I just got off IM :-P and now I'm going.


    TURN OFF E-MAIL REPLIES!!!

  10. #10
    Registered User Chemanuel's Avatar
    Join Date
    Aug 2001
    Posts
    13
    is it better to include menus as a resource, hard code them, or create them on the fly?
    In general, I prefer to build them as a resource because my applications have a fix menu and I don't want to bother to much with it.

    If you need a more "dynamic" menu it's better to create it on the fly.

    And you can always create a mixed menu, ie create a menu resource with some items and on the fly add/remove items depending on the application.
    Chemanuel

    Lo bueno si breve dos veces bueno (Baltasar Gracián 1601-1658)

  11. #11
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Why does it have to be either or? I use resources for my base menus and then alter them at run-time. It does not seem any harder for me to alter a resource menu at run-time than a non-resource menu. Besides, generating resource menus also allows me to see how the thing is going to look and act before I place it in my main window. It's probably just a matter of personal preference, but creating huge menus within code really looks ugly. I'd much rather have the beast sitting in a resource file somewhere.

    I don't see what the problem is with resource menus. If you are not using a library that allows for dynamic menus then write a small class that encapsulates the API calls and intercepts and translates the messages relating to menus and menu items. Once that is finished, just use that class in your future projects.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Win32 menus and resources help
    By firestorm in forum Windows Programming
    Replies: 24
    Last Post: 04-12-2005, 01:23 PM
  2. Creating pop up menus
    By Ti22 in forum C++ Programming
    Replies: 22
    Last Post: 01-18-2005, 09:27 PM
  3. help with menus example?
    By The Gweech in forum Windows Programming
    Replies: 3
    Last Post: 03-30-2004, 04:41 PM
  4. Menu's
    By Benzakhar in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2004, 10:13 PM
  5. adding menus at runtime
    By bennyandthejets in forum Windows Programming
    Replies: 3
    Last Post: 11-22-2002, 05:07 AM