Panel Gadget with\without Spin Control [Windows]

Share your advanced PureBasic knowledge/code with the community.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Panel Gadget with\without Spin Control [Windows]

Post by RASHAD »

Hi

Code: Select all

Global Dim spin(5)

Procedure HideSpin(gad)
  hwnd = GetWindow_(GadgetID(gad),#GW_CHILD   )
  hSpin = FindWindowEx_(GadgetID(gad), hwnd, "msctls_updown32", 0)
  If hSpin
    spin(gad) = hSpin
  EndIf
EndProcedure

If OpenWindow(0, 0, 0, 350, 255, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  PanelGadget     (0, 10, 10, 316, 203)
    AddGadgetItem (0, -1, "Panel 1")
      PanelGadget (1, 5, 5, 242, 166)
        AddGadgetItem(1, -1, "Sub-Panel 1")
        AddGadgetItem(1, -1, "Sub-Panel 2")
        AddGadgetItem(1, -1, "Sub-Panel 3")
        AddGadgetItem(1, -1, "Sub-Panel 4")
        AddGadgetItem(1, -1, "Sub-Panel 5")
        AddGadgetItem(1, -1, "Sub-Panel 6")
      CloseGadgetList()
    AddGadgetItem (0, -1,"Panel 2")
      ButtonGadget(2, 10, 15, 80, 24,"Button 1")
      ButtonGadget(3, 95, 15, 80, 24,"Button 2")
    AddGadgetItem (0, -1,"Panel 3")
    AddGadgetItem (0, -1,"Panel 4")
    AddGadgetItem (0, -1,"Panel 5")
    AddGadgetItem (0, -1,"Panel 6")
    AddGadgetItem (0, -1,"Panel 7")
    AddGadgetItem (0, -1,"Panel 8")
    AddGadgetItem (0, -1,"Panel 9")
    AddGadgetItem (0, -1,"Panel 10")
  CloseGadgetList()
  HideSpin(0)
  HideSpin(1)
  FrameGadget(#PB_Any,9,9,318,205,"",#PB_Frame_Flat)
  ButtonGadget(10,10,220,80,24,"Spin 0")
  ButtonGadget(20,100,220,80,24,"Spin 1")
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Quit = 1
       
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 10
            Run0 ! 1
            If Run0 = 0
              ShowWindow_(Spin(0),#SW_SHOW)
            Else
              ShowWindow_(Spin(0),#SW_HIDE)
            EndIf
           
          Case 20
            Run1 ! 1
            If Run1 = 0
              ShowWindow_(Spin(1),#SW_SHOW)
            Else
              ShowWindow_(Spin(1),#SW_HIDE)
            EndIf         
         
        EndSelect
    EndSelect
  Until Quit = 1
EndIf
Edit :Update
Last edited by RASHAD on Thu Oct 22, 2020 5:36 am, edited 1 time in total.
Egypt my love
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Panel Gadget with\without Spin Control [Windows]

Post by Paul »

I think I'm missing something...
What am I suppose to see here?
Image Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Panel Gadget with\without Spin Control [Windows]

Post by RASHAD »

viewtopic.php?f=13&t=76119

You can hide or show the scroll control at the right edge at any time
That mean you can enable or disable the Panel gadget scroll
Egypt my love
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Panel Gadget with\without Spin Control [Windows]

Post by Paul »

This is what I see when I run your example on Windows 10 Home...
(Pressing Spin0 or Spin1 shows nothing different)

Image


If I enable DPI aware I see this...
Image
Image Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Panel Gadget with\without Spin Control [Windows]

Post by RASHAD »

Hi Paul
Previous post updated to show the purpose of this snippet
Egypt my love
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Panel Gadget with\without Spin Control [Windows]

Post by Paul »

Thanks RASHAD, arrows now appear.

Not sure why anyone would want to remove the arrows.
If you press the tab farthest right it will advance to the next tab and the tab farthest left will be removed, but without the arrows there is no way to return to the previous tabs once they are off the screen.
Image Image
Mohsen

Re: Panel Gadget with\without Spin Control [Windows]

Post by Mohsen »

Paul wrote: Not sure why anyone would want to remove the arrows.
If you press the tab farthest right it will advance to the next tab and the tab farthest left will be removed, but without the arrows there is no way to return to the previous tabs once they are off the screen.
Hi Paul
you are right, this may not useful for everyone. but I'm building my new visual designer and I needed that feature. I have no problem detecting clicks on tabs, but this spin control made it a little difficult for me, so I decided to get rid of it for now.

Image
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Panel Gadget with\without Spin Control [Windows]

Post by Paul »

Like I said, without the arrows you lose the ability to go back to the beginning tabs.
As your animation demonstrates you had to increase the size of the panel just to get the tabs back into view.

This is just a "heads up" to anyone that decides to remove the navigation arrows and what the consequences might be for doing that :)

Thanks to RASHAD for the code to remove them but also the ability to easily bring them back!
Image Image
Mohsen

Re: Panel Gadget with\without Spin Control [Windows]

Post by Mohsen »

That's right, but I have a solution for that. I manage it. :wink:
Post Reply