Hi,
I am trying to create a rebar menu. In order to do this I need to make the iBitmap member of the button's TBBUTTON structure to I_IMAGENONE. If I choose to not use an image in the UI it still leaves space for the image. I have to explicitly set the image to I_IMAGENONE.
I have tried working with the buttons in the FF_FORM_WM_CREATE method but I cannot even get the handle of the Toolbar using GetDlgItem; it always returns 0.
How do I supress the image on a toolbar button??
Thanks
Trevor
Hi Trevor,
If I understand you correctly, you want to create something like a top menu in the rebar band of the rebar control. I am working with the code to see how this can be done. I will report back soon on my success or failure.
Thanks Paul,
That is exactly what I want to do.
The Toolbar Editor in FireFly does not handle things other than adding toolbars to the rebar bands. I have tried to hack the WM_CREATE to modify the appearance of the toolbar and buttons. Here is what I have so far:
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ 'optional user defined Long value
) As Long
Local Tbb As TBBUTTONINFO
Local hRebar As Dword
Local hToolBar As Dword
Local hOldImageList As Dword
Local nExStyle As Long
' Get the toolbar located in the rebar
hRebar = GetDlgItem( hWndForm, IDC_FORM1_REBAR )
hToolBar = GetDlgItem( hRebar, IDC_FORM1_TOOLBAR1 )
' Modify the toolbar to remove the extended style %TBSTYLE_EX_DRAWARROWS
nExStyle = SendMessage( hToolBar, %TB_GETEXTENDEDSTYLE, 0, 0 ) And (Not %TBSTYLE_EX_DRAWDDARROWS)
SendMessage hToolBar, %TB_SETEXTENDEDSTYLE, 0, nExStyle
' Ensure that the toolbar has the correct styles set
nExStyle = SendMessage( hToolBar, %TB_GETSTYLE, 0, 0 )
SendMessage hToolBar, %TB_SETSTYLE, 0, nExStyle Or %TBSTYLE_FLAT Or %TBSTYLE_LIST
' Modify the toolbar buttons to remove the image identifier
Tbb.cbSize = SizeOf( TBBUTTONINFO )
Tbb.dwMask = %TBIF_IMAGE Or %TBIF_STYLE
Tbb.iImage = %I_IMAGENONE
Tbb.fsStyle = %TBSTYLE_BUTTON Or %BTNS_DROPDOWN Or %BTNS_AUTOSIZE
' Apply the new button styles to the buttons
SendMessage hToolBar, %TB_SETBUTTONINFO, IDC_FORM1_TOOLBAR1_BUTTON1, VarPtr( Tbb )
SendMessage hToolBar, %TB_SETBUTTONINFO, IDC_FORM1_TOOLBAR1_BUTTON2, VarPtr( Tbb )
SendMessage hToolBar, %TB_SETBUTTONINFO, IDC_FORM1_TOOLBAR1_BUTTON3, VarPtr( Tbb )
SendMessage hToolBar, %TB_SETBUTTONINFO, IDC_FORM1_TOOLBAR1_BUTTON4, VarPtr( Tbb )
SendMessage hToolBar, %TB_SETBUTTONINFO, IDC_FORM1_TOOLBAR1_BUTTON5, VarPtr( Tbb )
SendMessage hToolBar, %TB_SETBITMAPSIZE, 0, MakLng(0, 0)
hOldImageList = SendMessage( hToolBar, %TB_SETIMAGELIST, 0, ByVal %Null )
If hOldImageList Then ImageList_Destroy( hOldImageList )
hOldImageList = SendMessage( hToolBar, %TB_SETHOTIMAGELIST, 0, ByVal %Null )
If hOldImageList Then ImageList_Destroy( hOldImageList )
hOldImageList = SendMessage( hToolBar, %TB_SETDISABLEDIMAGELIST, 0, ByVal %Null )
If hOldImageList Then ImageList_Destroy( hOldImageList )
Local rbBand As REBARBANDINFO
rbBand.cbSize = SizeOf( REBARBANDINFO )
rbBand.fMask = %RBBIM_CHILDSIZE
rbBand.cxMinChild = 0
rbBand.cyMinChild = 20
SendMessage hRebar, %RB_SETBANDINFO, 0, VarPtr( rbBand )
End Function
There is still a spacing between the buttons.
Many thanks Paul, I will look at removing that space somehow. That has shown me a lot about working with a rebar.
Well, I've cracked it. Although I don't know how. I now have a Rebar Top Menu without the spaces. I have played around with the settings for a while and I now do not know which one has done it. Basically as the Button Styles are being set in code now; I no longer set them in the properties box. If I leave them all blank (apart from the Button Option) then it takes out the space that was appearing; but I don't know why!!!
Thanks again
Cool! Happy that it worked out for you. :)