CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2003
    Location
    Spain
    Posts
    52

    rectangle around windowfrompoint handle

    Hi
    I want to draw a rectangle border around the window returned by windowfrompoint. I use GetWindowRect in that handle and then draw a red rectangle onto getdc(0). Can you tell me how to erase the previous rectangle when user moves mouse over other window. I'm trying to achieve the same effect as in camtasia when selecting the target to capture

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: rectangle around windowfrompoint handle

    You need to display the rectangle in XOR mode.

    Look at ::SetROP2().

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: rectangle around windowfrompoint handle

    Check out the DrawFocusRect api in Msdn.

  4. #4
    Join Date
    Dec 2003
    Location
    Spain
    Posts
    52

    Re: rectangle around windowfrompoint handle

    Thank you both !! The two ways work fine :

    rectangle + setrop2
    DrawFocusRect, calling it a second time to remove the same rectangle

    I'm facing another problem now that i want to draw onto each window instead of the entire screen.
    I make a GetDC over the handle of windowfrompoint but when i draw the rectangle, it doesn't fit to borders. There seems to be an offset between coordinates of GetWindowRect and the hdc ones
    Some help please?
    Last edited by chals1; April 4th, 2008 at 06:34 AM.

  5. #5
    Join Date
    Feb 2002
    Posts
    4,640

    Re: rectangle around windowfrompoint handle

    I believe that GetWindowRect gets the bounding box for the entire window, where the HDC of a window is just the client area.

    Viggy

  6. #6
    Join Date
    Dec 2003
    Location
    Spain
    Posts
    52

    Re: rectangle around windowfrompoint handle

    Quote Originally Posted by MrViggy
    I believe that GetWindowRect gets the bounding box for the entire window, where the HDC of a window is just the client area.

    Viggy
    Then i assume i have to get that offset between the rectangles of getclientrect and getwindowrect, and include it when drawing onto hdc ??
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured