Главная страница | назад





Article #15995: Using EnableMenuItem

 Question and Answer Database
FAQ995C.txt Using EnableMenuItem
Category :OWL
Platform :All
Product :BC++ 5.x
Question:
I've got a problem with the TMenu.EnableMenuItem function.
From a TWindow I used : TMenu menu(Parent->HWindow);
(Parent is a TDecoratedFrame)
menu.CheckMenuItem(CM_COLLECTE,MF_CHECKED|MF_BYCOMMAND); works
fine but menu.EnableMenuItem(CM_CERTIF,MF_GRAYED|MF_BYCOMMAND);
doesn't work even with Parent->DrawMenuBar();
MF_GRAYED|MF_DISABLED doesn't work too
Answer:
Chances are you need to read up on command enablers. Somewhere
in your prog you have something like:
EV_COMMAND(CM_MYCOMMAND, CmMyMethod)
Si? So, beneath it add the line
EV_COMMAND_ENABLE(CM_MYCOMMAND, CeMyMethod)
and declare a member function CeMyMethod as follows:
void MyWindow::CeRDSConnect(TCommandEnabler& e)
OWL calls this function (if it exists) during idle time (which
happens a LOT) and passes you a 'Command Enabler' for the
command. You can enable, disable, or gray it here, and any menu
or button anywhere referencing that command in your program will
get grayed, checked, or whatever.
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99