我将image放在一个panel上了,设置为alclient
procedure TForm1.FrameWindow(Wnd: HWnd);
var
Rect: TRect;
DC: hDC;
OldPen, Pen: hPen;
OldBrush, Brush: hBrush;
X2, Y2: Integer;
begin
GetWindowRect(Wnd, Rect);
DC := GetWindowDC(Wnd);
SetROP2(DC, R2_NOT);
Pen := CreatePen(PS_InsideFrame, 4, 0);
OldPen := SelectObject(DC, Pen);
Brush := GetStockObject(Null_Brush);
OldBrush := SelectObject(DC, Brush);
X2 := Rect.Right - Rect.Left;
Y2 := Rect.Bottom - Rect.Top;
Rectangle(DC, 0, 0, X2, Y2);
SelectObject(DC, OldBrush);
SelectObject(DC, OldPen);
ReleaseDC(Wnd, DC);
DeleteObject(Pen);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FrameWindow(Panel1.handle);
end;