Thread: enabling menu items

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    380

    enabling menu items

    I'm trying to create MDI text editior . I have a File menu with items grayed out. When a new document is created I would like them to become enabled. Any reason why my code doesn't work?

    I have attached the .c file for it.

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    It looks the EnableMenuItem function should work. I would think either for some reason the handle for the menu is coming out NULL or there is some error with when you decide to enable the menu. I didn't have time to check these so you should go back and make sure they are being called correctly before the EnableMenuItem functin call.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    I am not at home right now, so can't compile this, but here is a suggestion. Whenever I get a problem that I have no clue on, this is what I do. Use message boxes to tell me what is and what isn't happening.

    For example, in your if statement that checks (HWND)lparam and sets EnableFlag, put a messagebox in each section of the if-statement that says something like "enabled" or "disabled". THen once you establish if it gets that far, you know it has to be with the function you use to enable menu items. THen I would probably try using the enable menu item function somewhere in your program that runs in the main loop. Then you can see if the function works or not.

    A lot of time the error is something logical that is hard to see. Thats why you need to do weird things like this to narrow down where your code is not doing what you're expecting.

    Get what I'm saying?

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Yes, I understand you. Error checking I have forgotten about for some reason. Anys still haven't found the problem in my code. Is the main loop where messages get translated and dispatched?

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    You have not attached your header or resource files so I can't compile it.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Here are all the neccesary files to compile.

  7. #7
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Your call to GetMenu() is failing. The global you have set up to hold the handle of your main window is not initialised, when you create the main window, you store it in the local variable hwnd.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #8
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    Thank you. That solved my problem.

    I have another question. How do I determine the state of the Undo, Copy, Cut, and Paste commands? For example when using Notepad if the clipboard is empty these commands grayed out or aren't able. Does GetClipBoardData() hold the solution to this question?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  3. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  4. enabling and disabling menu items
    By poopy_pants2 in forum Windows Programming
    Replies: 2
    Last Post: 08-21-2002, 05:56 PM
  5. Enabling menu items
    By chomper in forum Windows Programming
    Replies: 2
    Last Post: 02-20-2002, 08:43 PM