Create vertical panel tabs in Purebasic ?

Just starting out? Need help? Post your questions and find answers here.
hdt888
User
User
Posts: 47
Joined: Sun Jul 07, 2024 8:42 am

Create vertical panel tabs in Purebasic ?

Post by hdt888 »

By default Panel/Tabs are in horizontal position, is there any option to make it vertical? :?:
Thanks you for help.
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Create vertical panel tabs in Purebasic ?

Post by RASHAD »

Hi
You need to adapt it for DPI

Code: Select all

Procedure IsMouseOver(hWnd) 
  GetWindowRect_(hWnd,r.RECT) 
  GetCursorPos_(p.POINT) 
  Result = PtInRect_(r,p\y << 32 + p\x) 
  ProcedureReturn Result 
EndProcedure

Procedure _MyPanelGadget(hWnd, id, x, y, x1, y1)
  tc = CreateWindowEx_(0, "SysTabControl32", "",#WS_OVERLAPPED | #WS_CHILD | #WS_VISIBLE | #WS_CLIPSIBLINGS | #WS_GROUP | #WS_TABSTOP  | #TCS_VERTICAL, x, y, x1, y1, hwnd, id, 0, 0)
  ProcedureReturn tc
EndProcedure

Procedure AddTab(wnd.i, index.i, text.s) 
  tad.TC_ITEM 
  tad\mask = 1
  tad\pszText = @text.s
  tad\cchTextMax = Len(text)
  tad\iImage = -1
  tad\lParam = 0  
  SendMessage_(wnd, #TCM_INSERTITEM, index, tad)
EndProcedure

Procedure DeleteTabControl(wnd.i)
  DestroyWindow_(wnd)
EndProcedure

If OpenWindow(0, 0, 0, 600, 460, "Vertical Panel Gadget", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
  SetWindowColor(0,$C6FEFD)
  
  tc = _MyPanelGadget(WindowID(0), 100 , 20, 50, 260,390)
  AddTab(tc, 0, "General")
  Dim tab(3)
  cont0 = ContainerGadget(#PB_Any,45,54,232,384)
  tab(0) = cont0
  SetGadgetColor(cont0,#PB_Gadget_BackColor,$E6E6E6)
  ButtonGadget(10,10,10,100,30,"test")
  CloseGadgetList()
  
  AddTab(tc, 1, "Video")
  cont1 = ContainerGadget(#PB_Any,45,54,232,384)
  tab(1) = cont1
  SetGadgetColor(cont1,#PB_Gadget_BackColor,$CDF4FE)
  ButtonGadget(20,10,10,100,30,"test #1")
  CloseGadgetList()
  
  AddTab(tc, 2, "Audio")
  cont2 = ContainerGadget(#PB_Any,45,54,232,384)
  tab(2) = cont2
  SetGadgetColor(cont2,#PB_Gadget_BackColor,$FCFECD)
  ButtonGadget(30,10,10,100,30,"test #2")
  CloseGadgetList()
  
  AddTab(tc, 3, "Subtitles")
  cont3 = ContainerGadget(#PB_Any,45,54,232,384)
  tab(3) = cont3
  SetGadgetColor(cont3,#PB_Gadget_BackColor,$FCFECD)
  ButtonGadget(40,10,10,100,30,"test #3")
  CloseGadgetList()
  SetWindowLongPtr_(tc, #GWL_STYLE, GetWindowLongPtr_(tc, #GWL_STYLE) |#TCS_HOTTRACK)
  
  For ntab = 0 To 3
    HideGadget(tab(ntab),1)
  Next
  HideGadget(tab(0),0)
  
  Repeat
    EventID.i = WaitWindowEvent()
    Select EventID
      Case #PB_Event_CloseWindow
        DeleteTabControl(tc)
        Quit = 1
        
      Case #WM_LBUTTONDOWN
        If IsMouseOver(tc)
          temp = SendMessage_(tc, #TCM_GETCURSEL, 0, 0)
          For ntab = 0 To 3
            HideGadget(tab(ntab),1)
          Next
          HideGadget(tab(temp),0)
        EndIf
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 10,20,30,40
            Debug EventGadget()
        EndSelect
        
    EndSelect    
  Until Quit = 1
  
EndIf

Egypt my love
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: Create vertical panel tabs in Purebasic ?

Post by BarryG »

Thanks, Rashad! I could've sworn there was an example in these forums but I couldn't find it, so yours is a welcome addition here. 8)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Create vertical panel tabs in Purebasic ?

Post by Kwai chang caine »

Very nice, thanks RASHAD 8)
ImageThe happiness is a road...
Not a destination
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: Create vertical panel tabs in Purebasic ?

Post by RASHAD »

@BarryG
@KCC
Guys you are welcome :)
Egypt my love
Post Reply