Re: Changing the color of the active title bar
- From: "Shiva" <gonzo@xxxxxxxxx>
- Date: Thu, 28 Jul 2005 10:52:32 +0200
Thanks Bob and Alan, I'll check out your suggestions!
<alanglloyd@xxxxxxx> wrote in message
news:1122494880.678637.212880@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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
>
.
- References:
- Changing the color of the active title bar
- From: Shiva
- Re: Changing the color of the active title bar
- From: alanglloyd@xxxxxxx
- Changing the color of the active title bar
- Prev by Date: Re: OpenPictureDialog Problems
- Next by Date: How Restore Docking on Undocked Window Close
- Previous by thread: Re: Changing the color of the active title bar
- Next by thread: Re: What's the proper way to share an object with several objects? (eg. a logging object)
- Index(es):