Disabling Toolbar Buttons?

Started by Anonymous, May 18, 2004, 01:41:33 PM

Previous topic - Next topic

Anonymous

What is the syntax required to enable/disable a toolbar button please?

I've tried "Control Disable hWnd, dwCtlId" but it doesn't work.

Andrew

George Bleck

Off the top of my head have a look at the %TB_SETSTATE message.

Jose Roca


  SendMessage hToolbar, %TB_ENABLEBUTTON, %IDM_SAVE, %FALSE

  SendMessage hToolbar, %TB_ENABLEBUTTON, %IDM_SAVE, %TRUE

Change hToolbar for your toolbar handle and %IDM_SAVE for your identifier.

Anonymous


Art Araya

OK - I feel like a dummy.  But where do I get the toolbar's handle?  I can see using F4 to get window handles and control IDs but there is no toolbar handle in there...

TIA

TechSupport

Yes, it is not very clear is it?

In the F4 popup you can get the Control ID of the Toolbar that you are interested in. You use that value to get the actual Window handle for the Toolbar. You use the API function GetDlgItem for that:

hToolbar = GetDlgItem( HWND_FORM1, IDC_FORM1_TOOLBAR1)


Hope that helps.

Art Araya

Thanks Paul - that did it.  Perhaps you should incorporate some of this info in the help file discussion about Toolbars.  Save yourself some support time!

TechSupport

Quote from: Art ArayaThanks Paul - that did it.  Perhaps you should incorporate some of this info in the help file discussion about Toolbars.  Save yourself some support time!
Yes, I sure will. As with the most programmers, the Help file is the most "boring" part of the whole job, but also probably the most important. I will add the info to the toolbar section.

Thanks!

Art Araya

While you're at it, might as well add it to the Status bar topic also.  I noticed that to set the text for a Status Bar panel (FF_StatusBar_SetText), the first param required is the handle of the Status bar control.  I was able to figure it out based on the Toolbar answer you gave me - but if I hadn't been working with toolbars, I would've been stuck with the StatusBar...

TechSupport

The StatusBar is the same as all other controls. You should be able to get the Windows Handle (e.g. HWND_FORM1_STATUSBAR) directly from the F4 popup.

Toolbars are different because it is possible to have several toolbars on any Form at any one time (i.e. by using a Rebar control).

Roger Garstang

I think the next important thing missing that is harder to get than a handle is the names of the resources.  A popup of them would be the next big thing.  Right now it is a process of putting the resource on a button/picture/whatever, compiling, then searching the generated code to see what FF called it if you want to use it on something else.

Also, while searching for images in statusbar panels I noticed they didn't get the recent revamping the other images did.  Just 16x16 is good since that is there size, but they still map 3D colors which sometimes can mess up an image that actually uses the 3D colors it is mapping and they don't have any options available to set.  Especially LR_SHARED which I pretty much use on everything.