Mega Code Archive

 
Categories / Delphi / Graphic
 

How to draw a color outline around TForm

Title: How to draw a color outline around TForm unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) private { Private-Deklarationen } procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT; public { Public-Deklarationen } 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; //Change the RGB value to change the color 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; end.