Page 1 of 1

MouseMove Event

Posted: Wed Aug 22, 2007 10:19 am
by karim_jouini
Hi,
I'm using wx.NET
And i can't get any MouseMove Event.
I tryed on a StaticBox and a StaticBitmap

What are the components that can catch mousemove events (and also have a picture on them) ?
Thanks

Karim

Posted: Tue Aug 28, 2007 6:58 pm
by protocol
Not sure, but a work around is... You can get the mouse events that are raised by the frame, and then test the coords against the bounds of the target control.

best regards.

Re: MouseMove Event

Posted: Wed Aug 29, 2007 7:09 am
by upCASE
Hi!
karim_jouini wrote:And i can't get any MouseMove Event.
I tryed on a StaticBox and a StaticBitmap
Did you derive your class from these and implemented an event table?

I remember that I had some problems with that as well.
karim_jouini wrote:What are the components that can catch mousemove events (and also have a picture on them) ?
Most, if not all, wxWindow derived classes should be able to handle mouse events. The only class with an image on it is wxStaticBitmap.

I'm not sure about wx.NET, but in C++ there is a simple solution for this. All you have to do is create the wxStaticBitmap as normal and then Connect() the event handler to it instead of creating an event table entry.
Like

Code: Select all

wxStaticBitmap* st1 = new wxStaticBitmap(this,-1,wxBitmap(img));
st1->Connect( wxID_ANY, wxEVT_MOTION , wxMouseEventHandler(MyFrame::OnMouse),NULL,this );
The event handler itself just works like it would when used in an event table. I'm able to display images and have motion events posted.