CWnd and CStatic Based Windows, How to detect mouse leaving the w

G

Guest

Hello,

I am creating a new window class based on CWnd. I am placing it on the View
(CFormView). How can I get the notification or any other indication that
the cursor/mouse is not on this window?

I also tried the same to create a new window based on CStatic but I was not
able to detect when the mouse leaves the window.

Regards,
Eitan
 
D

David Lowndes

I am creating a new window class based on CWnd. I am placing it on the View
(CFormView). How can I get the notification or any other indication that
the cursor/mouse is not on this window?

Have you tried TrackMouseEvent?

Dave
 
M

Martin Richter [MVP]

Hallo Eitan!
I am creating a new window class based on CWnd. I am placing it on
the View (CFormView). How can I get the notification or any other
indication that the cursor/mouse is not on this window?
I also tried the same to create a new window based on CStatic but I
was not able to detect when the mouse leaves the window.


Mouse messages are sent to the parent for CStatic windows. You can
override WM_NCHITTEST and return HTCLIENT. But AFAIK it is enough to set
the style SS_NOTIFY.

You can use TrackMouseEvent to get a message when the cursor leaves the
window.

Also you can get the current position of the cursor and you can compare
it with your window rect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top