Avatar of kuldeepruhela
kuldeepruhela
 asked on

How to Disable Some Tools from Toolbar in VC++6.0/MFC SDI Application

hi all
       i have an VC++6.0/MFC SDI Application in which i want to Disable some Tools from Toolbar.

Please tell me how to do it.

send the vc++/mfc CODE


 
System Programming

Avatar of undefined
Last Comment
alb66

8/22/2022 - Mon
alb66

If ID_YOURTOOL is the ID of your tool you can do this:

in .h file:

afx_msg void OnUpdateYourTool(CCmdUI *pCmdUI);

in .cpp file:

BEGIN_MESSAGE_MAP(CYourView, CView)
      ON_UPDATE_COMMAND_UI( ID_YOURTOOL, OnUpdateYourTool)
END_MESSAGE_MAP()


void CYourView::OnUpdateYourTool(CCmdUI *pCmdUI)
{
      BOOL bEnable = ... <---- your condition;

      pCmdUI->Enable( bEnable );
}


alb66

For a complete explanation you can read "How to Update User-Interface Objects" at
http://msdn.microsoft.com/en-us/library/72t5ykb7(VS.71).aspx
kuldeepruhela

ASKER
hi alb66

 i am using your first Suggestion for disable a tool from a toolbar now i need that when i click on a Button it should be Enable.


Please tell me how to do it


This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
kuldeepruhela

ASKER
hi all

 i am using following Solution

If ID_YOURTOOL is the ID of your tool you can do this:

in .h file:

afx_msg void OnUpdateYourTool(CCmdUI *pCmdUI);

in .cpp file:

BEGIN_MESSAGE_MAP(CYourView, CView)
      ON_UPDATE_COMMAND_UI( ID_YOURTOOL, OnUpdateYourTool)
END_MESSAGE_MAP()


void CYourView::OnUpdateYourTool(CCmdUI *pCmdUI)
{
      BOOL bEnable = ... <---- your condition;

      pCmdUI->Enable( bEnable );
}



to disable a tool from a toolbar now i need that when i click on a Button it should be Enable.


Please tell me how to do it

ASKER CERTIFIED SOLUTION
alb66

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
alb66

Hey kuldeepruhela, why B grade? Something was wrong or incomplete?