Get PanelGadget tab size or position relative?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Caronte3D
Addict
Addict
Posts: 1027
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Get PanelGadget tab size or position relative?

Post by Caronte3D »

Is there a way to get it?

I have a PanelGadget with several (dynamic) tabs and I want to know how many pixels the selected one are from the left of the PanelGadget it self.
I need this because I want to draw someting below the selected tab.

Thanks in advance :wink:
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Get PanelGadget tab size or position relative?

Post by chi »

This should get you started (Win)

Code: Select all

OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

PanelGadget(0, 5, 5, 310, 190)
  AddGadgetItem(0, -1, "Main Panel")
  AddGadgetItem(0, -1, "Another Panel")
  AddGadgetItem(0, -1, "Help")
CloseGadgetList()

hPanel = GadgetID(0)
pText$ = Space(255)
pan.TC_ITEM
pan\Mask = #TCIF_TEXT
pan\pszText = @pText$
pan\cchTextMax = 255

Repeat
  event = WaitWindowEvent()
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case 0
          ClearDebugOutput()
          cPanel = SendMessage_(hPanel, #TCM_GETITEMCOUNT, 0, 0) - 1
          sPanel = SendMessage_(hPanel, #TCM_GETCURSEL, 0, 0)
          hdc = GetDC_(hPanel)
          For i=0 To cPanel
            SendMessage_(hPanel, #TCM_GETITEM, i, @pan)
            SendMessage_(hPanel, #TCM_GETITEMRECT, i, pRect.RECT)
            SetDCBrushColor_(hdc, #Red)
            FrameRect_(hdc, pRect, GetStockObject_(#DC_BRUSH))
            If sPanel = i
              Debug ">> " + PeekS(pan\pszText)
            Else
              Debug "-- " + PeekS(pan\pszText)
            EndIf
            Debug "L: " + #TAB$ + pRect\left
            Debug "T: " + #TAB$ + pRect\top
            Debug "R: " + #TAB$ + pRect\right
            Debug "B: " + #TAB$ + pRect\bottom
            Debug ""
          Next
          ReleaseDC_(hPanel, hdc)
          
      EndSelect
  EndSelect
Until event = #PB_Event_CloseWindow
Et cetera is my worst enemy
User avatar
Caronte3D
Addict
Addict
Posts: 1027
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: Get PanelGadget tab size or position relative?

Post by Caronte3D »

Thank you very much, Chi, it's exactly what I need :D
User avatar
chi
Addict
Addict
Posts: 1028
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Get PanelGadget tab size or position relative?

Post by chi »

np :wink:
Et cetera is my worst enemy
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Get PanelGadget tab size or position relative?

Post by BarryG »

Thanks chi! Code saved in case I need it in future (it looks handy).
Post Reply