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. Other Discussions
  3. The Weird and The Wonderful
  4. 100% Bug Free - 0% Logic

100% Bug Free - 0% Logic

Scheduled Pinned Locked Moved The Weird and The Wonderful
c++collaborationhelpquestion
7 Posts 5 Posters 6 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.
  • P Offline
    P Offline
    Parthi_Appu
    wrote on last edited by
    #1

    The below code was written by two of my team mates in two different projects. Below code in MFC.

    ...::OnMouseMove(...)
    {
    CRect rc; GetClientRect(rc);
    ClientToScreen(rc);
    POINT pt; GetCursorPos(&pt);
    if (rc.PtInRect(pt))
    {
    /* Proceed */
    }
    /* return */
    }

    What they are tryin is, checking the mouse pointer is over the window in OnMouseMove Handler... What to say?...I think one should Cut and Copy the above logic!!!..


    Do your Duty and Don't expect the Result
    Rate this Post, if I helped You

    D M V 3 Replies Last reply
    0
    • P Parthi_Appu

      The below code was written by two of my team mates in two different projects. Below code in MFC.

      ...::OnMouseMove(...)
      {
      CRect rc; GetClientRect(rc);
      ClientToScreen(rc);
      POINT pt; GetCursorPos(&pt);
      if (rc.PtInRect(pt))
      {
      /* Proceed */
      }
      /* return */
      }

      What they are tryin is, checking the mouse pointer is over the window in OnMouseMove Handler... What to say?...I think one should Cut and Copy the above logic!!!..


      Do your Duty and Don't expect the Result
      Rate this Post, if I helped You

      D Offline
      D Offline
      Don Miguel
      wrote on last edited by
      #2

      Brilliant piece of being sure!! :laugh:

      1 Reply Last reply
      0
      • P Parthi_Appu

        The below code was written by two of my team mates in two different projects. Below code in MFC.

        ...::OnMouseMove(...)
        {
        CRect rc; GetClientRect(rc);
        ClientToScreen(rc);
        POINT pt; GetCursorPos(&pt);
        if (rc.PtInRect(pt))
        {
        /* Proceed */
        }
        /* return */
        }

        What they are tryin is, checking the mouse pointer is over the window in OnMouseMove Handler... What to say?...I think one should Cut and Copy the above logic!!!..


        Do your Duty and Don't expect the Result
        Rate this Post, if I helped You

        M Offline
        M Offline
        Mike Dimmick
        wrote on last edited by
        #3

        Check whether they've used SetCapture anywhere. If the mouse is captured, you will get mouse event messages outside the window's client rectangle. Also, note that GetCursorPos tells you the current position - a WM_MOUSEMOVE message tells you that the mouse moved when captured or when over the window at some point in the past. Perhaps they were trying to filter out old events? This would only be a problem if the application isn't very responsive to window messages, however. If you want to know the cursor position when the message was generated, that appears in the WM_MOUSEMOVE message's lParam parameter. This is actually relative to the client rectangle already, so ClientToScreen is not required. MFC's OnMouseMove function extracts the lParam message parameter to the point parameter. Do note however that Windows limits the rate at which it sends WM_MOUSEMOVE messages so that applications aren't overwhelmed, if the application is busy. You used to be able to see this effect in Windows Paint if you moved the mouse very rapidly while drawing - the line would be in lots of straight segments, rather than being smooth - but modern PCs are well up to the demands of Paint, so you don't see it any more. (Personally I would use ScreenToClient on the cursor's location and then use client rectangle-relative co-ordinates throughout, rather than converting the other way).

        Stability. What an interesting concept. -- Chris Maunder

        C P 2 Replies Last reply
        0
        • M Mike Dimmick

          Check whether they've used SetCapture anywhere. If the mouse is captured, you will get mouse event messages outside the window's client rectangle. Also, note that GetCursorPos tells you the current position - a WM_MOUSEMOVE message tells you that the mouse moved when captured or when over the window at some point in the past. Perhaps they were trying to filter out old events? This would only be a problem if the application isn't very responsive to window messages, however. If you want to know the cursor position when the message was generated, that appears in the WM_MOUSEMOVE message's lParam parameter. This is actually relative to the client rectangle already, so ClientToScreen is not required. MFC's OnMouseMove function extracts the lParam message parameter to the point parameter. Do note however that Windows limits the rate at which it sends WM_MOUSEMOVE messages so that applications aren't overwhelmed, if the application is busy. You used to be able to see this effect in Windows Paint if you moved the mouse very rapidly while drawing - the line would be in lots of straight segments, rather than being smooth - but modern PCs are well up to the demands of Paint, so you don't see it any more. (Personally I would use ScreenToClient on the cursor's location and then use client rectangle-relative co-ordinates throughout, rather than converting the other way).

          Stability. What an interesting concept. -- Chris Maunder

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Yeah, that's exactly what I was thinking as I read the code. I wonder what the truth of the matter is....

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          P 1 Reply Last reply
          0
          • M Mike Dimmick

            Check whether they've used SetCapture anywhere. If the mouse is captured, you will get mouse event messages outside the window's client rectangle. Also, note that GetCursorPos tells you the current position - a WM_MOUSEMOVE message tells you that the mouse moved when captured or when over the window at some point in the past. Perhaps they were trying to filter out old events? This would only be a problem if the application isn't very responsive to window messages, however. If you want to know the cursor position when the message was generated, that appears in the WM_MOUSEMOVE message's lParam parameter. This is actually relative to the client rectangle already, so ClientToScreen is not required. MFC's OnMouseMove function extracts the lParam message parameter to the point parameter. Do note however that Windows limits the rate at which it sends WM_MOUSEMOVE messages so that applications aren't overwhelmed, if the application is busy. You used to be able to see this effect in Windows Paint if you moved the mouse very rapidly while drawing - the line would be in lots of straight segments, rather than being smooth - but modern PCs are well up to the demands of Paint, so you don't see it any more. (Personally I would use ScreenToClient on the cursor's location and then use client rectangle-relative co-ordinates throughout, rather than converting the other way).

            Stability. What an interesting concept. -- Chris Maunder

            P Offline
            P Offline
            Parthi_Appu
            wrote on last edited by
            #5

            Mike Dimmick wrote:

            Check whether they've used SetCapture anywhere

            No they didn't use it. Actually what the requirement is, 1) for the 1st project to change the dialog apperiance while the mouse hovers in it. That is the dialog will be in small size, but if the mouse hovers then the size will be enlarged. 2) for the 2nd project, it is a custom button class, to give the XP effect they are catching WM_MOUSEMOVE messsage and redraw the button accordingly.


            Do your Duty and Don't expect the Result
            Rate this Post, if I helped You

            1 Reply Last reply
            0
            • C Christian Graus

              Yeah, that's exactly what I was thinking as I read the code. I wonder what the truth of the matter is....

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              P Offline
              P Offline
              Parthi_Appu
              wrote on last edited by
              #6

              Christian Graus wrote:

              I wonder what the truth of the matter is....

              Here the truth...[^]


              Do your Duty and Don't expect the Result
              Rate this Post, if I helped You

              1 Reply Last reply
              0
              • P Parthi_Appu

                The below code was written by two of my team mates in two different projects. Below code in MFC.

                ...::OnMouseMove(...)
                {
                CRect rc; GetClientRect(rc);
                ClientToScreen(rc);
                POINT pt; GetCursorPos(&pt);
                if (rc.PtInRect(pt))
                {
                /* Proceed */
                }
                /* return */
                }

                What they are tryin is, checking the mouse pointer is over the window in OnMouseMove Handler... What to say?...I think one should Cut and Copy the above logic!!!..


                Do your Duty and Don't expect the Result
                Rate this Post, if I helped You

                V Offline
                V Offline
                Vasudevan Deepak Kumar
                wrote on last edited by
                #7

                Parthi_Appu wrote:

                ...::OnMouseMove(...){

                and just say return; That would enhance performance too by not creating objects. Isn't it? :)

                Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                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