Windows Explorer Type Customizable Toolbars

Everything else that doesn't fall into one of the other PB categories.
Shopro
Enthusiast
Enthusiast
Posts: 148
Joined: Tue May 13, 2003 8:05 am

Windows Explorer Type Customizable Toolbars

Post 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
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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..
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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)

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

but i guess it is only available in xp. So why not use danilos lib if you can ?
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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?

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Shopro
Enthusiast
Enthusiast
Posts: 148
Joined: Tue May 13, 2003 8:05 am

Post by Shopro »

hi guys,

thanks for the info.

I think I'll play around with Danilo's PureTools.

-Shopro
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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. :P

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
Last edited by Sparkie on Fri Jul 23, 2004 12:58 pm, edited 1 time in total.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

nice!
Shopro
Enthusiast
Enthusiast
Posts: 148
Joined: Tue May 13, 2003 8:05 am

Post by Shopro »

Woah!

Awesome Sparkie. Mind if I use this code in my projects?

-Shopro
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post 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.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post by NoahPhense »

Very nice Sparkie.. one for the archiv!

- np
Shopro
Enthusiast
Enthusiast
Posts: 148
Joined: Tue May 13, 2003 8:05 am

Post 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
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Post 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.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Nice one :)
Post Reply