1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
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 ***on}
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; |
Partager