|
-
August 29th, 2011, 02:50 PM
#1
How to Draw Rectangles on Screen
Hi,
As part of research for a project I'm working on, I need to be able to locate hidden windows on my screen.
Ideally I would do something like draw a colored recangle on the sreen at the location where each hidden window is.
I've done some research and I know that DrawRectangle is available. As a pure guess, I created the code below.
Code:
public void drawRectangle(int x, int y, int width, int height )
{
// get desktop window
IntPtr desktopHwnd = GetDesktopWindow();
// Create a new pen.
Pen skyBluePen = new Pen(Brushes.DeepSkyBlue);
// Set the pen's width.
skyBluePen.Width = 8.0F;
// Set the LineJoin property.
skyBluePen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
Graphics.FromHwnd(desktopHwnd).DrawRectangle(skyBluePen, x, y, width, height);
skyBluePen.Dispose();
}
But when I call the function with valid coordinates, it does not draw a rectangle.
Thanks,
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|