Basic Univers
#Container = 0
#Button1 = 1
#Text1 = 2
#Panel = 3
#Button2 = 4
#Text2 = 5
#MouseIn = 256
#MouseOut = 512
Global MouseQuit
Procedure MouseOver(Window)
Static message, MemGadget.w = 65535, MemParent.l = 0, MemHandle.l
Repeat
GetCursorPos_(@point.POINT)
handle = WindowFromPoint_(point\X, point\Y)
Thread1 = GetWindowThreadProcessId_(Window, @Pid1)
Parent = GetParent_(handle)
Thread2 = GetWindowThreadProcessId_(Parent, @Pid2)
GadgetID = GetDlgCtrlID_(handle)
If Thread1 = Thread2
If MemGadget <> GadgetID
message = 1
PostMessage_(MemParent, #WM_COMMAND, #MouseOut<<16 + MemGadget, MemHandle)
PostMessage_(Parent, #WM_COMMAND, #MouseIn<<16 + GadgetID, handle)
MemGadget = GadgetID
MemParent = Parent
MemHandle = handle
EndIf
Else
If message = 1
PostMessage_(MemParent, #WM_COMMAND, #MouseOut<<16 + MemGadget, MemHandle)
MemGadget = 65535
message = 0
EndIf
EndIf
Delay(50)
Until MouseQuit = 1
EndProcedure
If OpenWindow(0, 0, 0, 320, 360, "ContainerGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateThread(@MouseOver(), WindowID(0))
CreateGadgetList(WindowID(0))
ContainerGadget(#Container, 8, 8, 306, 133, #PB_Container_Raised)
ButtonGadget(#Button1, 10, 20, 120, 20, "Bouton 1", #PB_Text_Border)
TextGadget(#Text1, 130, 20, 120, 20, "Bouton 2", #PB_Text_Border)
SetGadgetText(#Button1, "Bouton 1")
SetGadgetText(#Text1, "Texte2")
CloseGadgetList()
PanelGadget(#Panel, 10, 160, 300, 100)
AddGadgetItem(#Panel, - 1, "Onglet 1")
ButtonGadget(4, 10, 15, 120, 20, "Bouton 1")
TextGadget(5, 130, 15, 120, 20, "Bouton 2", #PB_Text_Border)
CloseGadgetList()
Repeat
Event.l = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case #Button1
Select EventType()
Case #PB_EventType_LeftClick
Debug "Click1"
Case #MouseIn
SetGadgetText(#Button1, "Mouse over Bouton 1")
Case #MouseOut
SetGadgetText(#Button1, "Mouse quit Bouton 1")
EndSelect
Case #Text1
Select EventType()
Case #MouseIn
SetGadgetText(#Text1, "Mouse over Texte 1")
Case #MouseOut
SetGadgetText(#Text1, "Mouse quit Texte 1")
EndSelect
Case #Button2
Select EventType()
Case #PB_EventType_LeftClick
Debug "Click2"
Case #MouseIn
SetGadgetText(#Button2, "Mouse over Bouton 2")
Case #MouseOut
SetGadgetText(#Button2, "Mouse quit Bouton 2")
EndSelect
Case #Text2
Select EventType()
Case #MouseIn
SetGadgetText(#Text2, "Mouse over Texte 2")
Case #MouseOut
SetGadgetText(#Text2, "Mouse quit Texte 2")
EndSelect
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
MouseQuit = 1
EndIf
End
Global Button.l
Procedure IsMouseOver(wnd)
GetWindowRect_(wnd, re.RECT)
re\left = re\left
re\top = re\top
re\right = re\right
re\bottom = re\bottom
GetCursorPos_(pt.POINT)
Result = PtInRect_(re, pt\X, pt\Y)
ProcedureReturn Result
EndProcedure
If OpenWindow(0, 200, 200, 480, 320, "MouseOver" , #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget )
CreateStatusBar(0, WindowID(0))
If CreateGadgetList( WindowID(0))
Button = ButtonGadget(0, 10, 10, 80, 24, "OK" )
EndIf
Repeat
EventID.l = WaitWindowEvent()
If IsMouseOver(Button)
StatusBarText(0, 0, "Maus über Button" )
Else
StatusBarText(0, 0, "" )
EndIf
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End