• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3545
  • Last Modified:

Form (Window) border color

How do I change the color of the border of the form/window of my application?

Sometimes the client area will be transparent and the normal btncolor border is hard to see.

There will also be several instances of the application and I want each to have a different border color.

0
frog
Asked:
frog
1 Solution
 
Ivanov_GCommented:
procedure TForm1.FormCreate(Sender: TObject);
begin
  BorderStyle := bsNone;
end;

procedure TForm1.FormPaint(Sender: TObject);
var
  Rect     : TRect;
begin
  // get the form rectangle
  Rect.Left   := 0;
  Rect.Top    := 0;
  Rect.Bottom := ClientHeight;
  Rect.Right  := ClientWidth;
  // draw the whole area
  with Canvas do
    begin
      // form color
      Brush.Color := clBlue;
      // set border color
      Pen.Color := clBlack;
      Rectangle(0, 0, ClientWidth, ClientHeight);
    end;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  // move the form without caption bar
  if Button = mbLeft then
    begin
      ReleaseCapture;
      SendMessage(Self.Handle, WM_SYSCOMMAND, 61458, 0);
    end;
end;
0
 
frogAuthor Commented:
Thanks  Ivanov_G
It doesn't quite work but I guess it's because of how I'm removing/showing the client.
I get the idea though, so I'll paint a fake border around the edge of the client and reduce my 'client' by the width of that border.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now