Title: How to write the caption bar of your form as a different way?
Question: Writing a different caption bar
Answer:
To write a different caption bar, you must override WMNCPaint message, like this:
.............
In the form's PRIVATE section enter:
procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT;
.............
You can try this function:
procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
var
ACanvas : TCanvas;
begin
inherited;
ACanvas := TCanvas.Create;
try
ACanvas.Handle := GetWindowDC(Form1.Handle);
with ACanvas do begin
Brush.Color := clActiveCaption;
Font.Name := 'Tahoma';
Font.Size := 8;
Font.Color := clred;
Font.Style := [fsItalic, fsBold];
TextOut(GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CXBORDER),
Round((GetSystemMetrics(SM_CYCAPTION) - Abs(Font.Height))/2) +1,' Hello');//As well, must be Form1.Caption:='';
end;
finally
ReleaseDC(Form1.Handle, ACanvas.Handle);
ACanvas.Free;
end;
end;