Page 1 of 3
Windows Explorer Type Customizable Toolbars
Posted: Wed Jul 21, 2004 12:12 pm
by Shopro
Hi,
I was wondering, what kind of gadgets are those toolbars you find in Windows Explorer(the file manager)?
http://www.active-eraser.com/images/3screen.gif
As in this screenshot, you can move around the menu bar, the navigation toolbar, etc.
Could this be done in PB?
Any comments?
Thanks!
-Shopro
Posted: Wed Jul 21, 2004 12:17 pm
by thefool
the ToolBarPRO lib that comes with Danilos puretools can create very cool toolbars. But i dont know if they can create movable like those..
Posted: Wed Jul 21, 2004 3:45 pm
by localmotion34
its called a REBAR control, and it is possible to create one using the API, you have to use
R=createwindowex_(#WS_EX_TOOLWINDOW,"REBARCLASSNAME", ......)
although ive never been able to get a rebar to actually be created in PB window. then you have to create a rebar band or gadget, and then
gadget=comboboxgadget(.....)
sendmessage_(R, #RB_INSERTBAND, wparam, @gadget)
Posted: Wed Jul 21, 2004 4:03 pm
by thefool
but i guess it is only available in xp. So why not use danilos lib if you can ?
Posted: Wed Jul 21, 2004 4:55 pm
by localmotion34
i dont think rebars are only available in XP. anyway, why wouldnt i be able to get it to work anyway? has anyone out there gotten a rebar to be created and work? or can anyone give an example of how to make it work?
Posted: Wed Jul 21, 2004 5:37 pm
by Shopro
hi guys,
thanks for the info.
I think I'll play around with Danilo's PureTools.
-Shopro
Posted: Fri Jul 23, 2004 2:09 am
by Sparkie
Here's my first attempt at a Rebar control. Works like a charm so far here on WinXP with PB 3.91. This is a bare minimum attempt so there is much more that can be done here. I'll leave that up to you to discover the other features.
Tip: Turn off XP Skin support in project options to see colorized rebar.
Code: Select all
; Rebar Control by Sparkie 07/22/2004
#TB_GETBUTTONSIZE = #WM_USER + 58
Structure myINITCOMMONCONTROLSEX
dwSize.l
dwICC.l
EndStructure
Procedure.l CreateRebar(hwndOwner, hwndST, hwndTB, hwndCB)
rbi.REBARINFO
rbBand.REBARBANDINFO
rc.RECT
icex.myINITCOMMONCONTROLSEX
icex\dwSize = SizeOf(myINITCOMMONCONTROLSEX)
icex\dwICC = #ICC_COOL_CLASSES | #ICC_BAR_CLASSES
InitCommonControlsEx_(@icex)
hwndRB = CreateWindowEx_(#WS_EX_TOOLWINDOW, "ReBarWindow32", #Null, #WS_CHILD | #WS_VISIBLE | #WS_CLIPSIBLINGS | #WS_CLIPCHILDREN | #RBS_VARHEIGHT | #CCS_NODIVIDER, 0, 0, 0, 0, hwndOwner, #Null, GetModuleHandle_(0), #Null)
rbi\cbSize = SizeOf(REBARINFO)
rbi\fMask = 0
rbi\himl = #Null
SendMessage_(hwndRB, #RB_SETBARINFO, 0, @rbi)
rbBand\cbSize = SizeOf(REBARBANDINFO)
rbBand\fMask = #RBBIM_COLORS | #RBBIM_TEXT | #RBBIM_STYLE | #RBBIM_CHILD | #RBBIM_CHILDSIZE | #RBBIM_SIZE;
rbBand\fStyle = #RBBS_CHILDEDGE
;/ turn off XP Skin support to see your color choices in the Rebar here
rbBand\clrBack = RGB(200, 200, 128)
rbBand\clrFore = RGB(64, 100, 0)
;/ Set values for band with the StringGadget
GetWindowRect_(hwndST, @rc)
sttext$ = "String"
rbBand\lpText = @sttext$ ; text to display for StringGadget
rbBand\hwndChild = hwndST ; handle to our STringGadget
rbBand\cxMinChild = 100 ; min width of band (0 hides gadget)
rbBand\cyMinChild = rc\bottom - rc\top ; min height of band
rbBand\cx = 200 ; width of band
;/ Add the band with the StringGadget
SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand)
;/ Get the height of the ToolBar we created earlier
dwBtnSize = SendMessage_(hwndTB, #TB_GETBUTTONSIZE, 0,0)
;/ Set values for band with the ToolBar
tbtext$ = "ToolBar"
rbBand\lpText = @tbtext$ ; text to display for ToolBar
rbBand\hwndChild = hwndTB ; handle to our ToolBar
rbBand\cxMinChild = 100 ; min width of band (0 hides ToolBar)
rbBand\cyMinChild = dwBtnSize>>16 ; min height of band set to button height
rbBand\cx = 200 ; width of band
;/ Add the band that has the toolbar.
SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand);
;/ Set values for the band with the ComboBox
GetWindowRect_(hwndCB, @rc);
cbtext$ = "ComboBox"
rbBand\lpText = @cbtext$ ; text to display for ToolBar
rbBand\hwndChild = hwndCB ; handle to our ComboBOxGadget
rbBand\cxMinChild = 100 ; min width of band (0 hides ComboBox)
rbBand\cyMinChild = rc\bottom - rc\top ; min height of band
rbBand\cx = 300 ; width of band
;/ Add the band that has the combobox
SendMessage_(hwndRB, #RB_INSERTBAND, -1, @rbBand);
ProcedureReturn hwndRB;
EndProcedure
If OpenWindow(0, 50, 50, 700, 200, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Rebar Control")
If CreateGadgetList(WindowID(0))
hStGad = StringGadget(0, 10, 50, 150, 20, "Hello World")
hTbGad = CreateToolBar(0, WindowID(0));
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
SetWindowLong_(hTbGad, #GWL_EXSTYLE, 128) ; best I can do for now
SetWindowLong_(hTbGad, #GWL_STYLE, 1442879821) ; best I can do for now
hCbGad = ComboBoxGadget(1, 10, 100, 100, 200)
For a=1 To 5
AddGadgetItem(1, -1, "ComboBox item " + Str(a))
Next
SetGadgetState(1,0)
TextGadget(2, 200, 100, 400, 20, "Clicking on any of the text labels in the Rebar also resizes the band.")
TextGadget(3, 200, 130, 400, 20, "Click and drag on any of the text labels to reposition the bands.")
CreateRebar(WindowID(), hStGad, hTbGad, hCbGad)
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_EventMenu
If Event = #PB_EventMenu
SetGadgetText(0, "ToolBar ID: " + Str(EventMenuID()))
EndIf
Case #PB_EventGadget
If EventGadgetID() = 1
SetGadgetText(0, GetGadgetText(1))
EndIf
Case #PB_Event_CloseWindow
Quit = #True
EndSelect
Until Quit = #True
End
Posted: Fri Jul 23, 2004 2:43 am
by PolyVector
nice!
Posted: Fri Jul 23, 2004 7:38 am
by Shopro
Woah!
Awesome Sparkie. Mind if I use this code in my projects?
-Shopro
Posted: Fri Jul 23, 2004 12:20 pm
by Sparkie
Thanks localmotion34 @ ShoPro
Mind if I use this code in my projects?
Thanks for asking ShoPro. Just give credit where credit is due (or not) and the code is good to go into anyone's project.
There is one little area I need to clean up though. The default exstyle / style parameters for the PB ToolBarGadget need a little tweaking. If you comment out these two lines
Code: Select all
SetWindowLong_(hTbGad, #GWL_EXSTYLE, 128) ; best I can do for now
SetWindowLong_(hTbGad, #GWL_STYLE, 1442879821) ; best I can do for now
you'll see the problem. If I find a cleaner method for adding the ToolBar, I'll post back here.
Posted: Fri Jul 23, 2004 12:45 pm
by Sparkie
Ok, this seems to be a better approach for adding a PB ToolBar to a Rebar.
Replace this
Code: Select all
SetWindowLong_(hTbGad, #GWL_EXSTYLE, 128) ; best I can do for now
SetWindowLong_(hTbGad, #GWL_STYLE, 1442879821) ; best I can do for now
with this
Code: Select all
style = GetWindowLong_(hTbGad, #GWL_STYLE)
newstyle = style | #CCS_NORESIZE | #CCS_NODIVIDER
SetWindowLong_(hTbGad, #GWL_STYLE, newstyle)
CCS_NORESIZE
Prevents the control from using the default width and height when setting its initial size or a new size. Instead, the control uses the width and height specified in the request for creation or sizing.
CCS_NODIVIDER
Prevents a two-pixel highlight from being drawn at the top of the control.
..
Posted: Fri Jul 23, 2004 4:23 pm
by NoahPhense
Very nice Sparkie.. one for the archiv!
- np
Posted: Fri Jul 23, 2004 4:31 pm
by Shopro
Sparkie:
Thanks alot for the update. Your code is giving my project a huge boost in appearance.
One small thing I noticed is, that for example,
Code: Select all
cbtext$ = "Address(&a)"
rbBand\lpText = @cbtext$ ; text to display for ToolBar
With the above code, the "(&a)" portion gets displayed as it is, instead of an "a", with an underbar under it. Any suggestions to get around this?
Thanks again
-Shopro
Posted: Fri Jul 23, 2004 4:35 pm
by localmotion34
actually he or someone should make a library out of it so that everyone can use it easily.
a command like :
PBRebar(#rebar,x,y,width,height,parentwindow.....)
and then:
Insertband(#rebar,hgadget....)
just something to think about.
Posted: Fri Jul 23, 2004 4:48 pm
by Fred
Nice one
