| | |
Menu items
![]() |
I have a MFC application that uses a menu, I want the menu disabled by default (easy enough), but what command do I use to reenable it? I tried
The program runs up until it executes that statement, then it crashes. Any ideas?
C Syntax (Toggle Plain Text)
GetDlgItem(IDM_FILE_TEST)->EnableWindow(TRUE);
The program runs up until it executes that statement, then it crashes. Any ideas?
Thanx,
Atrus
Atrus
C Syntax (Toggle Plain Text)
CMenu* menu = GetMenu(); CMenu* submenu = menu->GetSubMenu(0); submenu->EnableMenuItem(ID_MENUITEM_YOU_WANT_TO_ENABLE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
Just for your information, GetDlgItem is used only for the child windows of the mother dialog. The menu is a separate entity. There for will return NULL and will fail.
C Syntax (Toggle Plain Text)
GetDlgItem(IDM_FILE_TEST)
C Syntax (Toggle Plain Text)
GetDlgItem(IDM_FILE_TEST)->EnableWindow()
I realized before I posted that that was odviously the wrong thing to use, but it was the closest I could think of. (As a side note, my question was about enabling, and you aswnered how to disable, but I figured it out
And it works) Just a couple of questions. Why the whole CMenu stuff. Why can't you just do?
And it works) Just a couple of questions. Why the whole CMenu stuff. Why can't you just do? C Syntax (Toggle Plain Text)
EnableMenuItem(ID_MENUITEM_YOU_WANT_TO_ENABLE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
Thanx,
Atrus
Atrus
•
•
•
•
Originally Posted by atrusmre
(As a side note, my question was about enabling, and you aswnered how to disable, but I figured it outAnd it works)
•
•
•
•
Originally Posted by atrusmre
Why the whole CMenu stuff. Why can't you just do?
C Syntax (Toggle Plain Text)
EnableMenuItem(ID_MENUITEM_YOU_WANT_TO_ENABLE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
In Contrast, the CMenu::EnableMenuItem function is not a member of the CWnd Class. It is a member of the CMenu Class. To call this inside the Dialog window, you will have to first get the handle for the object of the desired menu item using CWnd::GetMenu(). Actually what you get here is the pointer for the Menubar. Then use the CMenu::GetSubMenu to get the Menu you want and call the CMenu::EnableMenuItem() function.
![]() |
Similar Threads
- add sub menu items to css menu? (JavaScript / DHTML / AJAX)
- Add Administrative Tools to Your Start Menu (Windows tips 'n' tweaks)
- how to bind keys to menu items? (Python)
- In which folder are the Start menu items? (Windows NT / 2000 / XP)
- In need of Menu over Frames (JavaScript / DHTML / AJAX)
- Drop Down Menu (ASP.NET)
Other Threads in the C Forum
- Previous Thread: Book Recommendation for Cell Phone Programming
- Next Thread: sort in unix--help
| Thread Tools | Search this Thread |
* adobe ansi api array arrays binarysearch calculate centimeter char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking hardware highest homework i/o inches incrementoperators intmain() iso km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pattern pdf performance pointer posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h






