Border color

m_adil
m_adil used Ask the Experts™
on
Hi,
How can I change border color of TForm. I want to use my own color instead of windows default. how can I do this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Override WM_NCPAINT message.

Example:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
    procedure WMNCPaint(var Msg : TMessage); message WM_NCPAINT;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.WMNCPaint(var Msg: TMessage);
Var
  Canvas : TCanvas;
begin
  Canvas := TCanvas.Create;
  Canvas.Handle := GetWindowDC(Handle);

  // sample border
  Canvas.Brush.Style := bsClear;
  Canvas.Pen.Color   := clRed;
  Canvas.Pen.Width   := 3;
  Canvas.Rectangle(0, 0, Width, Height);

  Canvas.Free;
  Msg.Result := 0;
end;

end.

Author

Commented:
Great!!! it worked

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial