Mouse Events

Just starting out? Need help? Post your questions and find answers here.
nci
User
User
Posts: 28
Joined: Mon Jul 28, 2003 6:03 pm

Mouse Events

Post by nci »

Does anyone know how to get mouse events for Gadgets?
like if you move the mouse over an image the image will change, or
if you press down or up on a button the image will change also?

I don't want to have to define coords like:

IF mouse > gadgetX and mouse < gadget width ect......

But if this is the only way. I guess i will have to use it :cry:

Also how to you get the mouse coords from the inside of the gadget list
and not the window?

Thanks
Neptune Century Inc.
Eric Butler, CEO, Lead programmer

"The road to happiness never ends..."
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Code: Select all

Procedure IsMouseOverGadget(Gadget)
  GetWindowRect_(GadgetID(Gadget),GadgetRect.RECT)
  GetCursorPos_(mouse.POINT)
  If mouse\x>=GadgetRect\Left And mouse\x<=GadgetRect\right And mouse\y>=GadgetRect\Top And mouse\y<=GadgetRect\bottom
    ProcedureReturn #True
  Else
    ProcedureReturn #False
  EndIf
EndProcedure
Some note: Windows send a #wm_mousemove, wenn the mouse is moved over one of your windows. (You can get this message with WaitWindowEvent())
nci
User
User
Posts: 28
Joined: Mon Jul 28, 2003 6:03 pm

Mouse

Post by nci »

Thanks GPI! Works like a charm!
Neptune Century Inc.
Eric Butler, CEO, Lead programmer

"The road to happiness never ends..."
Post Reply