有个示范,不是我写的.<br>你看看就知道了很简单<br>unit Unit1;<br>interface <br>uses <br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; <br>type <br> TForm1 = class(TForm) <br> private <br> procedure WMNCPaint(var Msg : TWMNCPaint); message WM_NCPAINT; <br> { Private declarations } <br> public <br> { Public declarations } <br> end; <br>var <br> Form1: TForm1; <br>implementation <br>{$R *.DFM} <br>{ TForm1 } <br>procedure TForm1.WMNCPaint(var Msg: TWMNCPaint); <br>var <br> dc : hDc; <br> Pen : hPen; <br> OldPen : hPen; <br> OldBrush : hBrush; <br>begin <br> inherited; <br> dc := GetWindowDC(Handle);<br> msg.Result := 1; <br> Pen := CreatePen(PS_SOLID, 5, RGB(255, 0, 0));<br> OldPen := SelectObject(dc, Pen); <br> OldBrush := SelectObject(dc, GetStockObject(NULL_BRUSH)); <br> Rectangle(dc, 0,0, Form1.Width, Form1.Height); <br> SelectObject(dc, OldBrush); <br> SelectObject(dc, OldPen);<br> DeleteObject(Pen);<br> ReleaseDC(Handle, Canvas.Handle); <br>end; <br>end.