How do you dim a menu inside the program, not in the resource script.
How do you dim a menu inside the program, not in the resource script.
Well if you really want to do it the hard way you are going to want to look at the CreateMenu() function, and the AppendMenu() function in the windows sdk. Here is a short code excerpt:
Code://...... HMENU hMenu; hMenu = CreateMenu() //return handle to new menu AppendMenu(hMenu, MF_STRING, IDM_FILE, "&File"); AppendMenu(hMenu, MF_STRING, IDM_EDIT, "&Edit"); SetMenu(hwnd, hMenu); //....
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
Ok so I got bored. Here is a complete working program that attaches a menu created by using the above code.
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
Ok, so I created my menu without a resource, that was easy enough. Now how do I go about dimming an item? And how do you make a dropdown from file?
What do you mean by dimming an item? If you mean thats is grayed just use this
Code:AppendMenu(hMenu, MF_STRING | MF_GRAYED, IDM_EDIT, "&Edit");
Woop?
Let's see if you mean enabling and disabling menu items then you would use EnableMenuItem(). Here is a code excerpt:
Hope that helps. Happy Coding!Code:EnableMenuItem(hMenu, IDM_FILE, MF_ENABLED); //enable item EnableMenuItem(hMenu, IDM_EDIT, MF_GRAYED); //disable item
[edit]
Here is another sample program. This one dynamically creates the menu, and then enables/disables menu items based on user selection.
This program has 2 dropdown menus File and Help
[/edit]
Last edited by andyhunter; 12-28-2004 at 05:52 PM.
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem
thanks
One more question, how do you make a seperator?
Happy Coding!Code:AppendMenu(hMenu, MF_SEPARATOR, 0, NULL);
[edit]
So for example in the sample program I provided if we did this:
It would put a separator between Start and StopCode:AppendMenu(hMenuPopup, MF_STRING, IDM_FILE_START, TEXT("Start")); AppendMenu(hMenuPopup, MF_SEPARATOR, 0, NULL); AppendMenu(hMenuPopup, MF_STRING, IDM_FILE_STOP, TEXT("Stop"));
[/edit]
Last edited by andyhunter; 12-28-2004 at 08:42 PM.
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem