Discussion:
Checking menu items
(too old to reply)
Z.K.
2006-09-29 16:51:25 UTC
Permalink
I know this is probably a simple problem, but I can't seem to get it to work
properly. I have a menu in my CFormView and it contains 2 menu items called
On_1 and On_2. It can manage to check either one or the other, but I can't
figure out how to check both of them and then uncheck either one or both of
them. I am not sure if I am making myself clear or not. I need to be able
to check both depending on the values I have in an *.ini file and then
through the program uncheck one or both of them depending on a value that is
entered in a editbox. Any help would be appreciated.

Z.K.
Scott McPhillips [MVP]
2006-09-29 17:31:51 UTC
Permalink
Post by Z.K.
I know this is probably a simple problem, but I can't seem to get it to work
properly. I have a menu in my CFormView and it contains 2 menu items called
On_1 and On_2. It can manage to check either one or the other, but I can't
figure out how to check both of them and then uncheck either one or both of
them. I am not sure if I am making myself clear or not. I need to be able
to check both depending on the values I have in an *.ini file and then
through the program uncheck one or both of them depending on a value that is
entered in a editbox. Any help would be appreciated.
Z.K.
Are you using the ON_UPDATE_COMMAND_UI mechanism? Show a little code.
--
Scott McPhillips [VC++ MVP]
Z.K.
2006-09-29 19:06:27 UTC
Permalink
Post by Scott McPhillips [MVP]
Post by Z.K.
I know this is probably a simple problem, but I can't seem to get it
to work properly. I have a menu in my CFormView and it contains 2
menu items called On_1 and On_2. It can manage to check either one or
the other, but I can't figure out how to check both of them and then
uncheck either one or both of them. I am not sure if I am making
myself clear or not. I need to be able to check both depending on the
values I have in an *.ini file and then through the program uncheck
one or both of them depending on a value that is entered in a editbox.
Any help would be appreciated.
Z.K.
Are you using the ON_UPDATE_COMMAND_UI mechanism? Show a little code.
Well, since I thought it was so simple, I did not think you need any
code. Here you go though.

void CT46297View::OnToolsEnablefield4()
{
// TODO: Add your command handler code here

m_Field_Enable = 1;


}

void CT46297View::OnUpdateToolsEnablefield4(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here

pCmdUI->SetCheck(1);

//or

if(m_Field_Enable == 1)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);


}

void CT46297View::OnToolsEnablefield5()
{
m_Field_Enable = 2;

}

void CT46297View::OnUpdateToolsEnablefield5(CCmdUI *pCmdUI)
{
// TODO: Add your command update UI handler code here

pCmdUI->SetCheck(1);

//or

if(m_Field_Enable == 2)
pCmdUI->SetCheck(1);
else
pCmdUI->SetCheck(0);

}
Z.K.
2006-09-29 19:31:03 UTC
Permalink
Post by Scott McPhillips [MVP]
Post by Z.K.
I know this is probably a simple problem, but I can't seem to get it
to work properly. I have a menu in my CFormView and it contains 2
menu items called On_1 and On_2. It can manage to check either one or
the other, but I can't figure out how to check both of them and then
uncheck either one or both of them. I am not sure if I am making
myself clear or not. I need to be able to check both depending on the
values I have in an *.ini file and then through the program uncheck
one or both of them depending on a value that is entered in a editbox.
Any help would be appreciated.
Z.K.
Are you using the ON_UPDATE_COMMAND_UI mechanism? Show a little code.
Never mind, I figured it out myself. It was simple as I thought, I was
just having a mental block I guess.

Z.K.

Tom Serface
2006-09-29 17:55:31 UTC
Permalink
Are you sure the value is correctly being retrieved from the edit control
and that the comparison is correct (not falling prey to case problems or
something). I'd just trace through and stop in the command UI handler that
you've set up and see what value is being passed to SetCheck().

Tom
Post by Z.K.
I know this is probably a simple problem, but I can't seem to get it to
work properly. I have a menu in my CFormView and it contains 2 menu items
called On_1 and On_2. It can manage to check either one or the other, but
I can't figure out how to check both of them and then uncheck either one or
both of them. I am not sure if I am making myself clear or not. I need to
be able to check both depending on the values I have in an *.ini file and
then through the program uncheck one or both of them depending on a value
that is entered in a editbox. Any help would be appreciated.
Z.K.
Continue reading on narkive:
Loading...