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. Capture control

Capture control

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 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.
  • C Offline
    C Offline
    capint
    wrote on last edited by
    #1

    I write a program to capture window controls. I used global mouse hook to catch mouse message. I want that when I move my mouse to a control, there's a rectangle around that control. I got the handle of the control, drew the rectangle but my problem is when I move to another control, the previous rectangle hasn't disappeared yet. I tried RedrawWindow() like this but there was no effect :

    CDC *hScrDC;
    hScrDC = CDC::FromHandle ( ::GetDCEx(NULL, NULL, 0));
    //Tmp is the CDC * of the control
    Tmp->RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
    RECT rect;
    Tmp->GetWindowRect(&rect);
    int nX = rect.left;
    int nY = rect.top;
    int nX2 = rect.right;
    int nY2 = rect.bottom;
    hScrDC->Rectangle(nX, nY, nX2, nY2);

    Some one plz help me :rose:

    A N 2 Replies Last reply
    0
    • C capint

      I write a program to capture window controls. I used global mouse hook to catch mouse message. I want that when I move my mouse to a control, there's a rectangle around that control. I got the handle of the control, drew the rectangle but my problem is when I move to another control, the previous rectangle hasn't disappeared yet. I tried RedrawWindow() like this but there was no effect :

      CDC *hScrDC;
      hScrDC = CDC::FromHandle ( ::GetDCEx(NULL, NULL, 0));
      //Tmp is the CDC * of the control
      Tmp->RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
      RECT rect;
      Tmp->GetWindowRect(&rect);
      int nX = rect.left;
      int nY = rect.top;
      int nX2 = rect.right;
      int nY2 = rect.bottom;
      hScrDC->Rectangle(nX, nY, nX2, nY2);

      Some one plz help me :rose:

      A Offline
      A Offline
      achainard
      wrote on last edited by
      #2

      If you draw the border around the button, you draw on his parent so try to made an InvalidateRect on his parent, thinks to increst the rect from the border width and use ClientToScreen ScreenToClient to adjust position of rect on parent. Bye...

      ...

      1 Reply Last reply
      0
      • C capint

        I write a program to capture window controls. I used global mouse hook to catch mouse message. I want that when I move my mouse to a control, there's a rectangle around that control. I got the handle of the control, drew the rectangle but my problem is when I move to another control, the previous rectangle hasn't disappeared yet. I tried RedrawWindow() like this but there was no effect :

        CDC *hScrDC;
        hScrDC = CDC::FromHandle ( ::GetDCEx(NULL, NULL, 0));
        //Tmp is the CDC * of the control
        Tmp->RedrawWindow(NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
        RECT rect;
        Tmp->GetWindowRect(&rect);
        int nX = rect.left;
        int nY = rect.top;
        int nX2 = rect.right;
        int nY2 = rect.bottom;
        hScrDC->Rectangle(nX, nY, nX2, nY2);

        Some one plz help me :rose:

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        capint wrote:

        RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);

        Try combining these two flags RDW_ERASENOW, RDW_UPDATENOW along with above ones.

        Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

        C 1 Reply Last reply
        0
        • N Nibu babu thomas

          capint wrote:

          RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);

          Try combining these two flags RDW_ERASENOW, RDW_UPDATENOW along with above ones.

          Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

          C Offline
          C Offline
          capint
          wrote on last edited by
          #4

          Thanks so much Nibu babu thomas, I got it :D

          N 1 Reply Last reply
          0
          • C capint

            Thanks so much Nibu babu thomas, I got it :D

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #5

            capint wrote:

            Thanks so much Nibu babu thomas, I got it

            Welcome! :) FYI Reason for above behavior... From MSDN: The system sends this message when there are no other messages in the application's message queue. So we here just forced a paint by adding those flags! Another way to do this will be to first call Invalidate() and then call UpdateWindow() which is similar to what we did!

            Nibu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

            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