How to enable/disable Toolbar button in Dialog Based MFC application 
Author Message
 How to enable/disable Toolbar button in Dialog Based MFC application

Hi,

I have a dialog based MFC application. Depending on some condition/case I
enable/disable some of the menu options. I want the toolbar buttons
(equivalent of the menu options e.g. Copy, Paste options ) to
enable/disable.

In SDI/MDI MFC application this scenario is taken care by the framework but
in case of the Dialog based application it has to be handled. [Like I have
handled for Menu update message WM_INITMENUPOPUP].

Can anyone give me some pointer on it.

Thanks,

--
Regards,
Amar Kumar.



Sun, 16 Oct 2005 08:26:57 GMT  
 How to enable/disable Toolbar button in Dialog Based MFC application
To enable/disable a menu item, you can use CMenu::EnableMenuItem(). For a
toolbar button to be enabled/disabled, you can use
CToolBarCtrl::EnableButton.

--
Ajay Kalra [MVP - VC++]


Quote:
> Hi,

> I have a dialog based MFC application. Depending on some condition/case I
> enable/disable some of the menu options. I want the toolbar buttons
> (equivalent of the menu options e.g. Copy, Paste options ) to
> enable/disable.

> In SDI/MDI MFC application this scenario is taken care by the framework
but
> in case of the Dialog based application it has to be handled. [Like I have
> handled for Menu update message WM_INITMENUPOPUP].

> Can anyone give me some pointer on it.

> Thanks,

> --
> Regards,
> Amar Kumar.



Sun, 16 Oct 2005 08:36:28 GMT  
 How to enable/disable Toolbar button in Dialog Based MFC application
I want to do it the way as it is done in SDI/MDI application. In SDI/MDI
application, framework fires on some update UI message every time the
application get's focus.

How it can be done for Dialog based application.

- Amar.


Quote:
> To enable/disable a menu item, you can use CMenu::EnableMenuItem(). For a
> toolbar button to be enabled/disabled, you can use
> CToolBarCtrl::EnableButton.

> --
> Ajay Kalra [MVP - VC++]



> > Hi,

> > I have a dialog based MFC application. Depending on some condition/case
I
> > enable/disable some of the menu options. I want the toolbar buttons
> > (equivalent of the menu options e.g. Copy, Paste options ) to
> > enable/disable.

> > In SDI/MDI MFC application this scenario is taken care by the framework
> but
> > in case of the Dialog based application it has to be handled. [Like I
have
> > handled for Menu update message WM_INITMENUPOPUP].

> > Can anyone give me some pointer on it.

> > Thanks,

> > --
> > Regards,
> > Amar Kumar.



Sun, 16 Oct 2005 08:46:40 GMT  
 How to enable/disable Toolbar button in Dialog Based MFC application
There is no inbuilt support for this in a Dialog app. You will have to do
the work yourself by essentially copying the code in
CFrameWnd::OninitMenupopup for a menu. Take a look at sample for this at
codeguru. For a toolbar, you will need to do handle WM_KICKIDLE and copy the
code as in a SDI/MDI(I dont know the exact location). Either way, take a
look at codeguru and codeproject for both these tasks.

--
Ajay Kalra [MVP - VC++]


Quote:
> I want to do it the way as it is done in SDI/MDI application. In SDI/MDI
> application, framework fires on some update UI message every time the
> application get's focus.

> How it can be done for Dialog based application.

> - Amar.



> > To enable/disable a menu item, you can use CMenu::EnableMenuItem(). For
a
> > toolbar button to be enabled/disabled, you can use
> > CToolBarCtrl::EnableButton.

> > --
> > Ajay Kalra [MVP - VC++]



> > > Hi,

> > > I have a dialog based MFC application. Depending on some
condition/case
> I
> > > enable/disable some of the menu options. I want the toolbar buttons
> > > (equivalent of the menu options e.g. Copy, Paste options ) to
> > > enable/disable.

> > > In SDI/MDI MFC application this scenario is taken care by the
framework
> > but
> > > in case of the Dialog based application it has to be handled. [Like I
> have
> > > handled for Menu update message WM_INITMENUPOPUP].

> > > Can anyone give me some pointer on it.

> > > Thanks,

> > > --
> > > Regards,
> > > Amar Kumar.



Sun, 16 Oct 2005 08:52:20 GMT  
 How to enable/disable Toolbar button in Dialog Based MFC application

Thanks a lot.
I handled  the WM_KICKIDLE message and it worked...

Thanks,
 - Amar.


Quote:
> There is no inbuilt support for this in a Dialog app. You will have to do
> the work yourself by essentially copying the code in
> CFrameWnd::OninitMenupopup for a menu. Take a look at sample for this at
> codeguru. For a toolbar, you will need to do handle WM_KICKIDLE and copy
the
> code as in a SDI/MDI(I dont know the exact location). Either way, take a
> look at codeguru and codeproject for both these tasks.

> --
> Ajay Kalra [MVP - VC++]



> > I want to do it the way as it is done in SDI/MDI application. In SDI/MDI
> > application, framework fires on some update UI message every time the
> > application get's focus.

> > How it can be done for Dialog based application.

> > - Amar.



> > > To enable/disable a menu item, you can use CMenu::EnableMenuItem().
For
> a
> > > toolbar button to be enabled/disabled, you can use
> > > CToolBarCtrl::EnableButton.

> > > --
> > > Ajay Kalra [MVP - VC++]



> > > > Hi,

> > > > I have a dialog based MFC application. Depending on some
> condition/case
> > I
> > > > enable/disable some of the menu options. I want the toolbar buttons
> > > > (equivalent of the menu options e.g. Copy, Paste options ) to
> > > > enable/disable.

> > > > In SDI/MDI MFC application this scenario is taken care by the
> framework
> > > but
> > > > in case of the Dialog based application it has to be handled. [Like
I
> > have
> > > > handled for Menu update message WM_INITMENUPOPUP].

> > > > Can anyone give me some pointer on it.

> > > > Thanks,

> > > > --
> > > > Regards,
> > > > Amar Kumar.



Mon, 17 Oct 2005 16:11:57 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. cannot gray toolbar-buttons in an mfc-dialog-based application

2. enable/disable toolbar button using pCmdUI->Enable(TRUE/FALSE) doesnt work

3. enable/disable toolbar button

4. Enable/ Disable Toolbar Buttons

5. enable/disable a toolbar button

6. When to enable/disable toolbar buttons?

7. How to disable/enable a button of the manfraime toolbar

8. How do I enable/disable Toolbar buttons?

9. how get the enable/disable status from toolbar button

10. Enabling - Disabling a Toolbar button

11. Enable/Disable toolbar button problem 2

12. Enabling or Disabling a toolbar button with

 

 
Powered by phpBB® Forum Software