I've got a simple menu, created it in the resource editor and made it the
menu for my main Dialog window. (CRSMDlg)

How do I get my menu to display a check / tick box next to the item when I
click on it. I tried adding the ON_UPDATE_COMMAND_UI event handler but no
matter what I do the menu item is not "ticked" :

void CRSMDlg::OnUpdateOps(CCmdUI *pCmdUI) {
pCmdUI->SetCheck(1);

}

Is there an update / repaint method I must call, some property I must set on
the Dialog box to inform it ?

Also I found that the shortcut keys does not display when you click on File,
but if you keep the ALT button , then only it displays it - can we switch
this behaviour off ?

Re: CDialog - Cannot set check mark to menu Item by David

David
Thu Apr 21 09:04:31 CDT 2005

>How do I get my menu to display a check / tick box next to the item when I
>click on it. I tried adding the ON_UPDATE_COMMAND_UI event handler but no
>matter what I do the menu item is not "ticked" :
>
>void CRSMDlg::OnUpdateOps(CCmdUI *pCmdUI) {
> pCmdUI->SetCheck(1);
>
>}

Pieter,

If you debug your code, is it ever getting called?

Have a look for references to using UpdateDialogControls on MSDN - an
old article by Paul DiLascia explained how to use it.

>Also I found that the shortcut keys does not display when you click on File,
>but if you keep the ALT button , then only it displays it - can we switch
>this behaviour off ?

This is probably the user setting in the display properties - "Hide
underlined letters for keyboard navigation until I press the Alt key"

Dave

Re: CDialog - Cannot set check mark to menu Item by Pieter

Pieter
Thu Apr 21 17:23:34 CDT 2005

Thx David, I found the following link that solved my problem -
http://support.microsoft.com/default.aspx?scid=kb;en-us;242577



Thanks for the tip on the display settings - I did not know you can set
menu's not to show the shortcut keys !



Regards

Pieter



"David Lowndes" <davidl@example.invalid> wrote in message
news:2icf61hok79i4buba5uh7lbf1ch1apefal@4ax.com...
> >How do I get my menu to display a check / tick box next to the item when
> >I
>>click on it. I tried adding the ON_UPDATE_COMMAND_UI event handler but no
>>matter what I do the menu item is not "ticked" :
>>
>>void CRSMDlg::OnUpdateOps(CCmdUI *pCmdUI) {
>> pCmdUI->SetCheck(1);
>>
>>}
>
> Pieter,
>
> If you debug your code, is it ever getting called?
>
> Have a look for references to using UpdateDialogControls on MSDN - an
> old article by Paul DiLascia explained how to use it.
>
>>Also I found that the shortcut keys does not display when you click on
>>File,
>>but if you keep the ALT button , then only it displays it - can we switch
>>this behaviour off ?
>
> This is probably the user setting in the display properties - "Hide
> underlined letters for keyboard navigation until I press the Alt key"
>
> Dave



Re: CDialog - Cannot set check mark to menu Item by Mark

Mark
Thu Apr 21 15:04:11 CDT 2005

With CDialog, ON_UPDATE_COMMAND_UI is not called unless you explicitly set
it to be so, I cannot remember how.

Easier idea is simply to change its setting as required using simple setting
macro's or functions. The CDialog preserves their values.

/* macros for changing the menu options quickly */
#define SwitchMenuCheck(m, i) m->CheckMenuItem(i, m->GetMenuState(i,
MF_BYCOMMAND) == MF_CHECKED ? 0 : MF_CHECKED)

#define SwitchMenu(x) const int nID = x; CMenu* menu = GetMenu();
SwitchMenuCheck(menu, x); this->ForceResize();

#define SwitchCheck(x) const int nID = x; CMenu* menu = GetMenu();
SwitchMenuCheck(menu, x);

--
- Mark Randall
http://zetech.swehli.com

"Pieter Claassens" <erica.altini@blueyonder.co.uk> wrote in message
news:enM5IujRFHA.904@tk2msftngp13.phx.gbl...
> I've got a simple menu, created it in the resource editor and made it the
> menu for my main Dialog window. (CRSMDlg)
>
> How do I get my menu to display a check / tick box next to the item when I
> click on it. I tried adding the ON_UPDATE_COMMAND_UI event handler but no
> matter what I do the menu item is not "ticked" :
>
> void CRSMDlg::OnUpdateOps(CCmdUI *pCmdUI) {
> pCmdUI->SetCheck(1);
>
> }
>
> Is there an update / repaint method I must call, some property I must set
> on
> the Dialog box to inform it ?
>
> Also I found that the shortcut keys does not display when you click on
> File,
> but if you keep the ALT button , then only it displays it - can we switch
> this behaviour off ?
>
>
>
>
>



Re: CDialog - Cannot set check mark to menu Item by Severian

Severian
Fri Apr 22 10:00:29 CDT 2005

On Thu, 21 Apr 2005 21:04:11 +0100, "Mark Randall"
<markyr@REMOVETHISgoogle.ANDTHIScom> wrote:

>With CDialog, ON_UPDATE_COMMAND_UI is not called unless you explicitly set
>it to be so, I cannot remember how.
>
>Easier idea is simply to change its setting as required using simple setting
>macro's or functions. The CDialog preserves their values.
>
>/* macros for changing the menu options quickly */
>#define SwitchMenuCheck(m, i) m->CheckMenuItem(i, m->GetMenuState(i,
>MF_BYCOMMAND) == MF_CHECKED ? 0 : MF_CHECKED)
>
>#define SwitchMenu(x) const int nID = x; CMenu* menu = GetMenu();
>SwitchMenuCheck(menu, x); this->ForceResize();
>
>#define SwitchCheck(x) const int nID = x; CMenu* menu = GetMenu();
>SwitchMenuCheck(menu, x);

I would prefer

#define SwitchMenuCheck(m, i)\
((m)->CheckMenuItem(i, m->GetMenuState(i,\
MF_BYCOMMAND) == MF_CHECKED ? 0 : MF_CHECKED)

#define SwitchMenu(x) do {\
const int nID = x;\
CMenu* menu = GetMenu();\
SwitchMenuCheck(menu, x);\
this->ForceResize();\
while (0)

#define SwitchCheck(x) do {\
const int nID = x;\
CMenu* menu = GetMenu();\
SwitchMenuCheck(menu, x);\
} while (0)

This makes the multi-statement macro usable as a single statement in
constructs like:

if (some_flag)
SwitchMenu(id);
else
// Do something else

--
Phillip Crews aka Severian
Microsoft MVP, Windows SDK
Posting email address is real, but please post replies on the newsgroup.