Fancy Panel Gadget (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

Fancy Panel Gadget (Windows)

Post by RASHAD »

Optitions are unlimited
You can use Imag ButtonGadget instead with different images
Tested with PB 4.6 x86 - Windows 7 x64
Have fun

Code: Select all


Global SG
Global Dim x(6)
x(1) = 0
x(2) = 46
x(3) = 92
x(4) = 138

  If OpenWindow(0, 0, 0, 400, 300, "Fancy PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    PanelGadget(100, 10, 10, 380, 280)
      AddGadgetItem (100, -1, "Panel 1")
      AddGadgetItem (100, -1,"Panel 2")
        ButtonGadget(101, 10, 15, 80, 24,"Button 1")
        ButtonGadget(102, 95, 15, 80, 24,"Button 2")
      AddGadgetItem (100, -1,"Panel 3")
      AddGadgetItem (100, -1,"Panel 4")
    CloseGadgetList()
    ContainerGadget(0, 10, 6,210, 26,#PB_Container_BorderLess)
      ButtonGadget(1, 0, 5, 48, 24,"Panel 0",#BS_FLAT)
      ButtonGadget(2, 46, 5,48, 24,"Panel 1",#BS_FLAT)
      ButtonGadget(3, 92, 5, 48, 24,"Panel 2",#BS_FLAT)
      ButtonGadget(4, 138, 5, 48, 24,"Panel 3",#BS_FLAT)
    CloseGadgetList()
    BringWindowToTop_(GadgetID(0))
    
    Import "Uxtheme.lib"
        SetWindowTheme(Window.l, Body.p-unicode, Title.p-unicode)                                                  
    EndImport        
    SG = 4
    Run = 1
  Repeat
      Select WaitWindowEvent()
      
        Case #PB_Event_CloseWindow
            Quit = 1
      
        Case #PB_Event_Gadget
          Select EventGadget()
                     
          EndSelect
          
        Case #WM_MOUSEMOVE         
          GetCursorPos_ (@p.POINT) 
          ScreenToClient_ (WindowID(0), @p)            
          Select ChildWindowFromPoint_ (GadgetID(0), p\y<< 32+p\x)
              Case GadgetID(1)
                If SG <> 1            
                  ResizeGadget(SG,x(SG),5 ,48 ,24)
                  SetWindowTheme(GadgetID(SG),"", "BUTTON")
                  ResizeGadget(1,0,0 ,48 ,28)
                  SetWindowTheme(GadgetID(1),"", "WINDOW")
                  SetGadgetState(100,0)
                EndIf 
                  SG = 1                                    
              Case GadgetID(2)
                If SG <> 2
                  ResizeGadget(SG,x(SG),5 ,48 ,24)
                  SetWindowTheme(GadgetID(SG),"", "BUTTON")
                  ResizeGadget(2,46,0 ,48 ,28)
                  SetWindowTheme(GadgetID(2),"", "WINDOW")
                  SetGadgetState(100,1)
                EndIf 
                  SG = 2
              Case GadgetID(3)
                If SG <> 3
                  ResizeGadget(SG,x(SG),5 ,48 ,24)
                  SetWindowTheme(GadgetID(SG),"", "BUTTON")
                  ResizeGadget(3,92,0 ,48 ,28)
                  SetWindowTheme(GadgetID(3),"", "WINDOW")
                  SetGadgetState(100,2)
                EndIf 
                  SG = 3
              Case GadgetID(4)
                If SG <> 4 Or Run = 1
                  ResizeGadget(SG,x(SG),5 ,48 ,24)
                  SetWindowTheme(GadgetID(SG),"", "BUTTON")
                  ResizeGadget(4,138,0 ,48 ,28)
                  SetWindowTheme(GadgetID(4),"", "WINDOW")
                  SetGadgetState(100,3)
                  Run = 0
                EndIf 
                  SG = 4
              EndSelect

              
              
                
      EndSelect
      
  Until Quit = 1
  EndIf
Egypt my love
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Fancy Panel Gadget (Windows)

Post by falsam »

Good Job RASHAD, very good :)

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Fancy Panel Gadget (Windows)

Post by RASHAD »

@falsam Hi
Thanks mate
You are the author of PB Contribution
Feel free my friend to add any of my posts you like
I will be honored

Thanks mate
Egypt my love
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Fancy Panel Gadget (Windows)

Post by Kwai chang caine »

Wouuaaauuhh again a great code of the PB magician :shock:
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Fancy Panel Gadget (Windows)

Post by IdeasVacuum »

By the powers invested upon me as Chief Bug Maker, I hereby bestow upon you the title Rashad, Pharaoh of Tricks n Tips.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply