Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Where is the mouse??

Where is the mouse??

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasehelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dimitris Vikeloudas
    wrote on last edited by
    #1

    I have an application with plenty of windows. Some of them a re CView subclasses others are controls etc. My views usually track the mouse using the mouse events like the CWnd::OnMouseMove messages (which I have properly mapped etc). Reading the OnMouseMove help says that: 'The framework calls this member function when the mouse cursor moves. If the mouse is not captured, the WM_MOUSEMOVE message is received by the CWnd object beneath the mouse cursor; otherwise, the message goes to the window that has captured the mouse.' I would like to know at a given point where the mouse is, or actually if the recepient of the next mouse input message is the current CWnd or not (i.e. is it still beneath the cursor?). I 'd like to write code like MyClass::OnMouseMove(....) { DoMyInitialAction(); _//an application action_ if( MouseInputStillOnMe() ) DoSomeOtherAction(....); _//another application action_ } If my DoMyInitialAction creates a new view it is likely that the next mouse input message will go on that one. I do not want to capture the mouse and receive any event related to it just in case that the DoMyInitialAction does that (It's a black box. I do not know what will do). Thus is it possible to write a MouseInputStillOnMe() query which will not post any message to my message queues but will tell me that under the current circumanstances I 'll receive the next mouse input message? I assume that I can use the CWnd *CWnd::GetCapture( ) to find if another CWnd in my thread receives the mouse events but this does not answer if my window is still the one beneath the cursor. How do I found if it is? Thanks a lot for any help.... Dimitris...more you ask, more you learn

    B R 2 Replies Last reply
    0
    • D Dimitris Vikeloudas

      I have an application with plenty of windows. Some of them a re CView subclasses others are controls etc. My views usually track the mouse using the mouse events like the CWnd::OnMouseMove messages (which I have properly mapped etc). Reading the OnMouseMove help says that: 'The framework calls this member function when the mouse cursor moves. If the mouse is not captured, the WM_MOUSEMOVE message is received by the CWnd object beneath the mouse cursor; otherwise, the message goes to the window that has captured the mouse.' I would like to know at a given point where the mouse is, or actually if the recepient of the next mouse input message is the current CWnd or not (i.e. is it still beneath the cursor?). I 'd like to write code like MyClass::OnMouseMove(....) { DoMyInitialAction(); _//an application action_ if( MouseInputStillOnMe() ) DoSomeOtherAction(....); _//another application action_ } If my DoMyInitialAction creates a new view it is likely that the next mouse input message will go on that one. I do not want to capture the mouse and receive any event related to it just in case that the DoMyInitialAction does that (It's a black box. I do not know what will do). Thus is it possible to write a MouseInputStillOnMe() query which will not post any message to my message queues but will tell me that under the current circumanstances I 'll receive the next mouse input message? I assume that I can use the CWnd *CWnd::GetCapture( ) to find if another CWnd in my thread receives the mouse events but this does not answer if my window is still the one beneath the cursor. How do I found if it is? Thanks a lot for any help.... Dimitris...more you ask, more you learn

      B Offline
      B Offline
      Blake Miller
      wrote on last edited by
      #2

      I think you should look into using TrackMouseEvent The TrackMouseEvent function posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time. I've seen better runs in my shorts! - Patches O'Houlihan

      1 Reply Last reply
      0
      • D Dimitris Vikeloudas

        I have an application with plenty of windows. Some of them a re CView subclasses others are controls etc. My views usually track the mouse using the mouse events like the CWnd::OnMouseMove messages (which I have properly mapped etc). Reading the OnMouseMove help says that: 'The framework calls this member function when the mouse cursor moves. If the mouse is not captured, the WM_MOUSEMOVE message is received by the CWnd object beneath the mouse cursor; otherwise, the message goes to the window that has captured the mouse.' I would like to know at a given point where the mouse is, or actually if the recepient of the next mouse input message is the current CWnd or not (i.e. is it still beneath the cursor?). I 'd like to write code like MyClass::OnMouseMove(....) { DoMyInitialAction(); _//an application action_ if( MouseInputStillOnMe() ) DoSomeOtherAction(....); _//another application action_ } If my DoMyInitialAction creates a new view it is likely that the next mouse input message will go on that one. I do not want to capture the mouse and receive any event related to it just in case that the DoMyInitialAction does that (It's a black box. I do not know what will do). Thus is it possible to write a MouseInputStillOnMe() query which will not post any message to my message queues but will tell me that under the current circumanstances I 'll receive the next mouse input message? I assume that I can use the CWnd *CWnd::GetCapture( ) to find if another CWnd in my thread receives the mouse events but this does not answer if my window is still the one beneath the cursor. How do I found if it is? Thanks a lot for any help.... Dimitris...more you ask, more you learn

        R Offline
        R Offline
        Roger Allen
        wrote on last edited by
        #3

        Or you could make use of the GetCursorPos() function and then indowFromPoint() to find out if the mouse is still over your window or not. If you vote me down, my score will only get lower

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups