Re: Changing the color of the active title bar
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: 27 Jul 2005 13:08:00 -0700
I did it like this, I had some problem drawing the system button so I
only painted up to the button.
in form type private declaration ...
procedure WMNCPaint(var Msg : TWMNCPaint); message WM_NCPAINT;
procedure WMActivate(var Msg : TWMActivate); message WM_ACTIVATE;
in implementation ...
// = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// Draw Red Titlebar
// = = = = = = = = = = = = = = = = = = = = = = = = = = = =
procedure TForm1.WMNCPaint(var Msg : TWMNCPaint);
begin
inherited;
DrawCaption;
end;
procedure TForm1.WMActivate(var Msg : TWMActivate);
begin
inherited;
DrawCaption;
end;
procedure TForm1.DrawCaption;
var
xFrame, yFrame, xSize, ySize : Integer;
begin
{get titlebar dimensions}
xFrame := GetSystemMetrics(SM_CXFRAME);
yFrame := GetSystemMetrics(SM_CYFRAME);
xSize := Self.Width - yFrame;
ySize := yFrame + GetSystemMetrics(SM_CYCAPTION);
{allocate device context handle to form's canvas}
with Self.Canvas do begin
Handle := GetWindowDC(Self.Handle);
with Font do begin
Name := 'Arial';
Size := 9;
Color := clBlue;
Style := [fsBold];
end;
if Self.Active then
Brush.Color := clRed;
{fill titlebar except for close button}
FillRect(Rect(xFrame, yFrame, xSize - ySize + (xFrame div 2),
ySize));
TextOut(xFrame + 4, yFrame + 2, Self.Caption);
{release device context ...}{ and set the canvas handle to default}
ReleaseDC(Self.Handle, Handle);
{... set the canvas handle to nil}
Handle := 0;
end;
end;
Alan Lloyd
.
- Follow-Ups:
- Re: Changing the color of the active title bar
- From: Shiva
- Re: Changing the color of the active title bar
- References:
- Changing the color of the active title bar
- From: Shiva
- Changing the color of the active title bar
- Prev by Date: Re: What's the proper way to share an object with several objects? (eg. a logging object)
- Next by Date: Re: OpenPictureDialog Problems
- Previous by thread: Re: Changing the color of the active title bar
- Next by thread: Re: Changing the color of the active title bar
- Index(es):