PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Eros Olmi on January 10, 2015, 01:31:08 PM

Title: Enabling/Disabling a button in a Rebar control
Post by: Eros Olmi on January 10, 2015, 01:31:08 PM
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)
Title: Re: Enabling/Disabling a button in a Rebar control
Post by: Paul Squires on January 10, 2015, 02:29:25 PM
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"
Title: Re: Enabling/Disabling a button in a Rebar control
Post by: Eros Olmi on January 10, 2015, 02:36:12 PM
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 :)
Title: Re: Enabling/Disabling a button in a Rebar control
Post by: José Roca on January 11, 2015, 12:47:32 AM
FF_Control_Enable can't work with toolbar buttons because they aren't "real" buttons, but drawn by Windows.
Title: Re: Enabling/Disabling a button in a Rebar control
Post by: Eros Olmi on January 11, 2015, 02:05:19 AM
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)
Title: Re: Enabling/Disabling a button in a Rebar control
Post by: Rolf Brandt on January 11, 2015, 02:37:22 PM
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
Title: Re: Enabling/Disabling a button in a Rebar control
Post by: Rolf Brandt on January 13, 2015, 07:42:36 AM
And of course to enable:

SendMessage hToolBar, %TB_SETSTATE, IDC_FORM1_TOOLBAR1_CUSTINFO, %TBSTATE_DISABLED

Rolf