Kindly provide me with the code/logic
that how to toggle the buttons on the toolbar
i.e if u press it once it must be shown as pressed and when u press it once again it should be shown as up
Kindly Help
Sebnak
Printable View
Kindly provide me with the code/logic
that how to toggle the buttons on the toolbar
i.e if u press it once it must be shown as pressed and when u press it once again it should be shown as up
Kindly Help
Sebnak
in OnUpdateEvent you use
pCmdUI->SetCheck(..);
Code:int ind = m_wndToolBar.CommandToIndex(ID_MYCHECKED_BUTTON);
UINT style = m_wndToolBar.GetButtonStyle( ind ) | TBBS_CHECKBOX ;
m_wndToolBar.SetButtonStyle(ind, style );
Thanks for the reply , now the same Functionality I have to add in the menu for those buttons,i.e if button A is checked in menu List , in front of menu item a , a chek mark must mbe there,
It is possible if both share the same id
now For setting chek I am using PcmDUI->Setcheck();
But As I have wriiten this in on_update,
the toggling starts on and off ,i.e there is no need to explicitly push the button
kindly help
Create a menu item, and give it the same resource id as for the toolbar button. Also check the 'Checked' property in the menu item.
It's not working
i simply cannot follow you. please try to explain the problem better.Quote:
Originally posted by sebnak
Thanks for the reply , now the same Functionality I have to add in the menu for those buttons,i.e if button A is checked in menu List , in front of menu item a , a chek mark must mbe there,
It is possible if both share the same id
now For setting chek I am using PcmDUI->Setcheck();
But As I have wriiten this in on_update,
the toggling starts on and off ,i.e there is no need to explicitly push the button
kindly help
to check/uncheck a menu item use:
Code:void CMainFrame::OnUpdateMenuItem(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(TRUE/FALSE);
}
there is a button on the toolbar , which do something and toggles, the same work is to be done by a menuitem from the main menu
Now for toggling on Update_command, I have used the above code i.e getButtonStyle and SetButtonStlye
Now the menuitem on menu shares the same id as of button and has the property of checked,now if the button is toggling , simultansly the menu item should bear a check or unchek mark
If I used PCCmd->SetCheck, this is only for handling toolbar buttons as the pointer has the value for CtoolbarCmdUI , and not the value for Cmenu,
So it changes the button value and not the menu item(check , uncheck), though the Id's are Same
for eg
int ind = m_wndToolBar.CommandToIndex(ID_OPTIONS_BAVIEW);
UINT style = m_wndToolBar.GetButtonStyle( ind ) | TBBS_CHECKBOX ;
m_wndToolBar.SetButtonStyle(ind, style );
if(style == 2)
{
PCmdUI->SetCheck(True)
}
I am not able to control my menu item chek , unchek , while the button toggles
this is the prob
I hope now u r having the clear picture
Kindly Help
Declare a boolean variable in your class,
add a handler to your menu/toolbar click and toogle the value of boolean thereCode:BOOL bState;
and in ON_UPDATEUI_XXX hadler just add followingCode:bState = !bState;
AmitCode:PCmdUI->SetCheck(bState);
Oh Great!!!!!!!!!!
It's Working
Thanks A ton
Sebnak
hi Amit
but sometimes it's not working
I mean if u have pressed the button down , there is correponding check mark agnst the menu item, vice versa , if u pressed the button up, then again the menu item gets unchek, but if u r doing it frequently , despite u have unpressed the button , a chek mark will be there , i.e the status is not updated b/w the Command handler and the Update_ handler
how could we overcome this problem, I don't want to incorporate
Sleep etc
I hope this is the problem or probably there can be another reason for this .
Kindly suggest
Sebnak