Code: Select all
;=====================================================
;EnableExplicit
Import ""
PB_Gadget_SendGadgetCommand(hwnd, EventType)
EndImport
#HoverEvent_EnterGadget = #WM_USER + 100
#HoverEvent_LeaveGadget = #WM_USER + 101
Global hook
Procedure EnterGadgetID( )
Protected EnterGadgetID, GadgetID
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
Protected WindowID
Protected Cursorpos.q
GetCursorPos_( @Cursorpos )
WindowID = WindowFromPoint_( Cursorpos )
ScreenToClient_(WindowID, @Cursorpos)
GadgetID = ChildWindowFromPoint_( WindowID, Cursorpos )
GetCursorPos_( @Cursorpos )
WindowID = GetAncestor_( WindowID, #GA_ROOT )
ScreenToClient_(WindowID, @Cursorpos)
WindowID = ChildWindowFromPoint_( WindowID, Cursorpos )
If IsGadget( GetDlgCtrlID_( GadgetID ))
If GadgetID = GadgetID( GetDlgCtrlID_( GadgetID ))
WindowID = GadgetID
Else
; SpinGadget
If GetWindow_( GadgetID, #GW_HWNDPREV ) = GadgetID( GetDlgCtrlID_( GadgetID ))
If GetWindowLongPtr_( GadgetID, #GWL_STYLE ) & #WS_CLIPSIBLINGS = #False
SetWindowLongPtr_( GadgetID, #GWL_STYLE, GetWindowLongPtr_( GadgetID, #GWL_STYLE ) | #WS_CLIPSIBLINGS )
EndIf
WindowID = GetWindow_( GadgetID, #GW_HWNDPREV)
ElseIf GetWindow_( GadgetID, #GW_HWNDNEXT ) = GadgetID( GetDlgCtrlID_( GadgetID ))
If GetWindowLongPtr_( GadgetID, #GWL_STYLE ) & #WS_CLIPSIBLINGS = #False
SetWindowLongPtr_( GadgetID, #GWL_STYLE, GetWindowLongPtr_( GadgetID, #GWL_STYLE ) | #WS_CLIPSIBLINGS )
EndIf
WindowID = GetWindow_( GadgetID, #GW_HWNDNEXT)
EndIf
EndIf
Else
If GetParent_( GadgetID )
WindowID = GetParent_( GadgetID ) ; С веб гаджетом проблемы
;Debug WindowID ;
EndIf
EndIf
; SplitterGadget()
Protected RealClass.S = Space(13)
GetClassName_( GetParent_( WindowID ), @RealClass, Len( RealClass ))
If RealClass.S = "PureSplitter" : WindowID = GetParent_( WindowID ) : EndIf
;Debug WindowID
ProcedureReturn WindowID
CompilerEndSelect
EndProcedure
Procedure CallWndProc(nCode, wParam, lParam)
Static LeaveID
Protected EnterID = EnterGadgetID( )
If LeaveID <> EnterID
If LeaveID > 0 And LeaveID <> GetAncestor_( LeaveID, #GA_ROOT )
PB_Gadget_SendGadgetCommand(LeaveID, #HoverEvent_LeaveGadget)
EndIf
If EnterID > 0 And EnterID <> GetAncestor_( EnterID, #GA_ROOT )
PB_Gadget_SendGadgetCommand( EnterID, #HoverEvent_EnterGadget)
EndIf
LeaveID = EnterID
EndIf
ProcedureReturn CallNextHookEx_(0, nCode, wParam, lParam)
EndProcedure
ProcedureDLL InitHoverEvents(hwnd)
Shared hook
hook = SetWindowsHookEx_(#WH_MOUSE, @CallWndProc(), #Null, GetCurrentThreadId_())
If hook
ProcedureReturn 1
EndIf
EndProcedure
ProcedureDLL EndHoverEvents(hwnd)
Shared hook
If UnhookWindowsHookEx_(hook)
ProcedureReturn 1
EndIf
EndProcedure
;========================================================
; End of Library Code
;========================================================
CompilerIf #PB_Compiler_IsMainFile
OpenWindow(10, 0, 0, 640, 480, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
PanelGadget(0, 8, 8, 300, 300)
AddGadgetItem(0,0,"Tab 1")
ContainerGadget(30, 5,5,260,220,#PB_Container_Flat)
ContainerGadget(20, 15,15,220,180,#PB_Container_Flat)
ButtonGadget(10, 25, 25, 100, 30, "")
CloseGadgetList()
CloseGadgetList()
AddGadgetItem(0,1,"Tab 2")
ButtonGadget(11, 10, 40, 200, 30, "")
CloseGadgetList()
InitHoverEvents(WindowID(10))
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
If EventType() = #HoverEvent_EnterGadget
Debug "Entered Gadget " + EventGadget()
ElseIf EventType() = #HoverEvent_LeaveGadget
Debug "Left Gadget " + EventGadget()
EndIf
EndSelect
Until EventID = #PB_Event_CloseWindow
EndHoverEvents(WindowID(0))
CompilerEndIf