15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Problem disabling CBitmapButtons ....

Gforce -- gforce@liquidaudio.com
Friday, December 06, 1996

Environment : VC++ 4.2b, Win 95

        I'm having problems disabling a CBitmapButton,

        In my FormView app, I have 2 controls the subclasses CDialogBar,
both
dialog bar templates have a button      with the same name, both
controls
have a member variable of class CBitmapButton attached to the button
(via AutoLoad ()), I'm trying to disable the    button(s)at startup and
enable them when certain conditions are met...I use a EnableWindow
(FALSE)call and then check with IsWindowEnabled() to make sure it's
disable, it works upon startup (I output result to trace window), but
when my app starts up, the button is enabled....

        Yes I do have the required bitmaps for the button (U,D,X).

        Any help would be greatly appreciated..

G



Mihir Dalal -- m_dalal@ECE.concordia.CA
Monday, December 09, 1996



On Fri, 6 Dec 1996, Gforce wrote:

> Environment : VC++ 4.2b, Win 95
> 
>         I'm having problems disabling a CBitmapButton,
> 
>         In my FormView app, I have 2 controls the subclasses CDialogBar,
> both
> dialog bar templates have a button      with the same name, both
> controls
> have a member variable of class CBitmapButton attached to the button
> (via AutoLoad ()), I'm trying to disable the    button(s)at startup and
> enable them when certain conditions are met...I use a EnableWindow
> (FALSE)call and then check with IsWindowEnabled() to make sure it's
> disable, it works upon startup (I output result to trace window), but
> when my app starts up, the button is enabled....
> 
>         Yes I do have the required bitmaps for the button (U,D,X).
> 
>         Any help would be greatly appreciated..
> 
> G


Try the following. I believe it should work. I have have been able to 
successfully disable and enable bitmap buttons at run time on my form view 
with the following technique:

1. Firstly, it seems you haven't written a  ON_UPDATE_COMMAND_UI handler for 
   those bitmap buttons. Infact, you need to (& must)  write only one 
   OnCommandUI handler for both the buttons since you mention they have the 
   same ID. (Bear in mind, that ON_UPDATE_COMMAND_UI handlers can be 
   written for buttons too, their use is not restricted to just menu items)
2. Declare a flag and set/reset it as and where you want to disable/enable
   those buttons. 
3. In your OnCommandUI handler, first check for that flag whether it is set
   or reset. Depending on that, call EnableWindow(FALSE) or 
   EnableWindow(TRUE).

That should solve your problems.


Mihir Dalal
(University Researcher)




| Вернуться в корень Архива |