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.
procedure BorderMyControl(DaControl : TControl);
C : TCanvas;
DeskTopWindowDC : HDC;
C := TCanvas.Create;
with C do
DeskTopWindowDC := GetWindowDC(GetDeskTopWindow);
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));