Enabling/Disabling a button in a Rebar control

Started by Eros Olmi, January 10, 2015, 01:31:08 PM

Previous topic - Next topic

Eros Olmi

I'm getting crazy trying to enable/disable a button over a toolbar inside a rebar band/rebar

Based on application situations I need to enable/disable some of the buttons.
Maybe I'm blind and solution is just under my eyes but ...

I need to Enable the "Bundle" button (see image)

Paul Squires

Hi Eros,

FF_Control_Enable does not work on individual toolbar buttons. You should use the WinAPI TB_ENABLEBUTTON message. The best solution is to use Jose's wrappers for the ToolBar control. I use Jose's wrappers for everything I do these days.

http://www.planetsquires.com/protect/forum/index.php?topic=3597.0

Check out the ToolBar function "Toolbar_EnableButton"
Paul Squires
PlanetSquires Software

Eros Olmi

#2
Perfect.

Thanks a lot.

PS: I'm also migrating to Jose wrappers step by step but have so many thousand lines to change from old school :)

José Roca

FF_Control_Enable can't work with toolbar buttons because they aren't "real" buttons, but drawn by Windows.

Eros Olmi

Thanks a lot.

I've found how to do using Jose functions ToolBar_DisableButton and ToolBar_EnableButton

Example:
    ToolBar_DisableButton(gfrmMainToolBarHandle, IDC_FRMMAIN_TOOLBAR_BUNDLE_BUTTON_BUNDLE)
    ToolBar_EnableButton(gfrmMainToolBarHandle, IDC_FRMMAIN_TOOLBAR_BUNDLE_BUTTON_CANCEL)

Rolf Brandt

Or using the API you could use:


      hToolBar = GetDlgItem( HWND_FRMMAIN, IDC_FORM1_TOOLBAR1 )
      SendMessage hToolBar, %TB_SETSTATE, IDC_FORM1_TOOLBAR1_CUSTINFO, %TBSTATE_DISABLED     


Rolf
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Rolf Brandt

And of course to enable:

SendMessage hToolBar, %TB_SETSTATE, IDC_FORM1_TOOLBAR1_CUSTINFO, %TBSTATE_DISABLED

Rolf
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)