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.
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.
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
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?
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?
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.
Here are all the neccesary files to compile.
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.
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?