Detecting mouse over button
Posted: Mon Nov 06, 2006 7:15 am
I have a window with a button and a text gadget. I want the text gadget to change from "test" to "Mouse over button" when the mouse cursor is over the button. I am trying to understand the winapi but I am confused.
Any help will be appreciated. I have been using PB 4.0 for over 2 weeks now. I mostly interested in using database applications with nice gui's.
thanks.
Code: Select all
Structure wndMain
window.l
btnClose.l
btnViewParents.l
txtMessage.l
EndStructure
MainWindow.wndMain
;assign Id's
MainWindow\window=0
MainWindow\btnClose=1
MainWindow\btnViewParents=2
MainWindow\txtMessage=3
;Create window
OpenWindow(mainWindow\window,0,0,500,200,"TEST",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(mainWindow\window))
ButtonGadget(MainWindow\btnClose,400,150,40,30,"CLOSE")
TextGadget(MainWindow\txtMessage,10,10,200,30,"TEST")
Repeat
event.l=WaitWindowEvent(10) ;catch all events from any window
If event=#PB_Event_Gadget ;If event is from a gadget
Select EventGadget() ; get the gadget number
Case MainWindow\btnClose
[b]If #BCN_HOTITEMCHANGE [/b] ;I am confused here
SetGadgetText(MainWindow\txtMessage,""Mouse over button"")
EndIf
EndSelect
EndIf
Until event=#PB_Event_CloseWindow And EventWindow()=MainWindow\window
thanks.