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
Get PanelGadget tab size or position relative?
Re: Get PanelGadget tab size or position relative?
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
Re: Get PanelGadget tab size or position relative?
Thank you very much, Chi, it's exactly what I need
Re: Get PanelGadget tab size or position relative?
Thanks chi! Code saved in case I need it in future (it looks handy).