Главная страница | назад





Article #16079: Draw on frame

 Question and Answer Database
FAQ1079D.txt Draw on frame
Category :VCL
Platform :All
Product :All 32 bit
Question:
Is it possible to draw on the frame of a form?
Answer:
Create a message handler for the Windows Message WM_NCPAINT
message. The following example paints a 1 pixel red border around the
frame of the form.
Example:
type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMNCPaint(var Msg : TWMNCPaint); message WM_NCPAINT;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
var
dc : hDc;
Pen : hPen;
OldPen : hPen;
OldBrush : hBrush;
begin
inherited;
dc := GetWindowDC(Handle);
msg.Result := 1;
Pen := CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
OldPen := SelectObject(dc, Pen);
OldBrush := SelectObject(dc, GetStockObject(NULL_BRUSH));
Rectangle(dc, 0,0, Form1.Width, Form1.Height);
SelectObject(dc, OldBrush);
SelectObject(dc, OldPen);
DeleteObject(Pen);
ReleaseDC(Handle, Canvas.Handle);
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99