
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.