rfwoolf
asked on
Remove Rectangles after painting them on "DeskTopWindow" or screen
I am drawing a rectangle around buttons in my application by using this funny method below.
The problem is that after I draw these rectangles I cannot clear them (unless I 'drag' my form off the screen and back on again).
I have tried calling canvas.repaint / canvas.refresh but it doesn't work.
The problem is that after I draw these rectangles I cannot clear them (unless I 'drag' my form off the screen and back on again).
I have tried calling canvas.repaint / canvas.refresh but it doesn't work.
procedure BorderMyControl(DaControl : TControl);
var
C : TCanvas;
DeskTopWindowDC : HDC;
begin
C := TCanvas.Create;
with C do
try
DeskTopWindowDC := GetWindowDC(GetDeskTopWindow);
try
Handle := DeskTopWindowDC;
Brush.Style := bsClear;
Pen.Width := 3;
Rectangle(Rect(DaControl.Left - 2, DaControl.Top - 2, DaControl.Left + DaControl.Width + 2, DaControl.Top + DaControl.Height + 2));
finally
ReleaseDC(GetDesktopWindow, DeskTopWindowDC);
end;
finally
Free;
end;
end;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry I wasn't clear above, what I'm trying to say Hypo is this:
Your solution is a great workaround for my particular problem, but,
what if I did want to draw on the desktop, and what if I did have trouble removing the squares on the desktop window handle? Your answer doesn't address this.
Anyways, I would prefer to draw on the form instead of the desktop so let's just move on :p
Your solution is a great workaround for my particular problem, but,
what if I did want to draw on the desktop, and what if I did have trouble removing the squares on the desktop window handle? Your answer doesn't address this.
Anyways, I would prefer to draw on the form instead of the desktop so let's just move on :p
ASKER