Page 1 of 1
Handle of a paneltab
Posted: Sat Mar 12, 2005 12:07 am
by Hroudtwolf
Hello comunity,
Do anyone knows how to get the handle of a tab in a panelgadget?
A tab is a clientwindow linke a panelgadget. If i can get the handle of
the panelgadget, then i could get the handle of a tab. But i don't know how to do it.
Posted: Sat Mar 12, 2005 1:32 am
by Xombie
Hmmmm... I can give you some ugly code I use to detect right-mouse clicks on a panelgadget to see if it can get you started. Unfortunately, it's a piece of larger code so it may be confusing to look at. Just imagine that the panelgadget is inside of a containergadget which is inside of a splitter gadget

My code is most likely not the best route to go but it works for me. I use it for a pop-up window on my panelgadget with right-clicks.
Code: Select all
If fTypeMain\EventID = #WM_RBUTTONDOWN
GetCursorPos_(@cursor_pos.POINT)
ScreenToClient_(WindowID(0),@cursor_pos)
hChild = ChildWindowFromPoint_(WindowID(0), cursor_pos\X,cursor_pos\Y)
If hChild = GadgetID(#SplitMain)
GetCursorPos_(@cursor_pos.POINT)
ScreenToClient_(hChild,@cursor_pos)
hChild = ChildWindowFromPoint_(hChild, cursor_pos\X,cursor_pos\Y)
If hChild = GadgetID(#ContainerLines)
GetCursorPos_(@cursor_pos.POINT)
ScreenToClient_(hChild,@cursor_pos)
hChild = ChildWindowFromPoint_(hChild, cursor_pos\X,cursor_pos\Y)
If GetDlgCtrlID_(hChild) = #PanelSections
bFormMainProcessEvents = #False
DisplayPopupMenu(#MenuPopupSections,WindowID())
Else
bFormMainProcessEvents = #True
EndIf
EndIf
EndIf
EndIf
I use this before the main processing of events so there's a little boolean in there to prevent event checking if this is valid. Hope it's a little helpful ^_^;;
Posted: Sat Mar 12, 2005 8:13 pm
by Henrik
** Edit**Oh forgot:
Use the Winapi EnumChildWindows function with the handler from the panelgadget
Quote from WinApi
Code: Select all
BOOL EnumChildWindows( HWND hWndParent, // handle of parent window WNDENUMPROC lpEnumFunc, // address of callback function LPARAM lParam // application-defined value );
PB Example of how to get the handler of the tabs..
Code: Select all
; PureBasic Visual Designer v3.90 build 1361
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Panel_0
EndEnumeration
Global PHwnd.l,Number.l
Number.l=0
Procedure WNDENUMPROC (Hwnd, LPARAM)
Debug Hwnd
Debug "-----"
SetGadgetItemText(#Panel_0,Number.l, "Tab_Hnd: = "+Str(Hwnd),0)
Number.l+1
EnumChildWindows_(Hwnd, @WNDENUMPROC(), LPARAM+1)
ProcedureReturn #TRUE
EndProcedure
Procedure Open_Window_0()
If OpenWindow(#Window_0, 275, 258, 600, 300, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Tab")
If CreateGadgetList(WindowID())
;- Panel0
PHwnd=PanelGadget(#Panel_0, 60, 40, 435, 200)
AddGadgetItem(#Panel_0, -1, "Tab 1")
AddGadgetItem(#Panel_0, -1, "Tab 2")
AddGadgetItem(#Panel_0, -1, "Tab 3")
CloseGadgetList()
EndIf
EndIf
EndProcedure
Open_Window_0()
EnumChildWindows_( PHwnd, @WNDENUMPROC(), 0)
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
;Debug "WindowID: " + Str(EventWindowID())
GadgetID = EventGadgetID()
If GadgetID = #Panel_0
; Debug "GadgetID: #Panel_0"
EndIf
EndIf
Until Event = #PB_EventCloseWindow
End
Henrik
Posted: Sat Mar 12, 2005 8:37 pm
by Hroudtwolf
Yeah..I thank you very much.