1.自己做
2.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Psock, NMsmtp;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure WMNCPAint(var Mes : TWMNCPaint); message WM_NCPAINT;
end;var
Form1: TForm1;implementation{$R *.DFM}{ TForm1 }procedure TForm1.WMNCPAint(var Mes: TWMNCPaint);
var
ACanvas : TCanvas;
begin
Inherited;
ACanvas := TCanvas.Create;
try
ACanvas.Handle := GetWindowDC(Form1.Handle);
with ACanvas do begin
Brush.Color := clActiveCaption;
Font.Name := 'Times New Roman';
Font.Size := 10;
Font.Color := clCaptionText;
Font.Style := [fsItalic, fsBold];
TextOut(GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CXBORDER),
Round((GetSystemMetrics(SM_CYCAPTION) - Abs(Font.Height))/2) +1,
' Your title here!');
end;
finally
ReleaseDC(Form1.Handle, ACanvas.Handle);
ACanvas.Free;
end;end;end.
2.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Psock, NMsmtp;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure WMNCPAint(var Mes : TWMNCPaint); message WM_NCPAINT;
end;var
Form1: TForm1;implementation{$R *.DFM}{ TForm1 }procedure TForm1.WMNCPAint(var Mes: TWMNCPaint);
var
ACanvas : TCanvas;
begin
Inherited;
ACanvas := TCanvas.Create;
try
ACanvas.Handle := GetWindowDC(Form1.Handle);
with ACanvas do begin
Brush.Color := clActiveCaption;
Font.Name := 'Times New Roman';
Font.Size := 10;
Font.Color := clCaptionText;
Font.Style := [fsItalic, fsBold];
TextOut(GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CXBORDER),
Round((GetSystemMetrics(SM_CYCAPTION) - Abs(Font.Height))/2) +1,
' Your title here!');
end;
finally
ReleaseDC(Form1.Handle, ACanvas.Handle);
ACanvas.Free;
end;end;end.
SystemParametersInfo(SPI_GETICONTITLELOGFONT,sizeof(hFont),@hFont,0);
hFont.lfFaceName:='Fixedsys';
NM.cbSize:=sizeof(nm);
NM.lfMenuFont:=hFont;
NM.lfMessageFont:=hFont;
SystemParametersInfo(SPI_SETNONCLIENTMETRICS,sizeof(NM),@NM,SPIF_UPDATEINIFILE);
另外“Your title here”的背景跟标题栏的背景不同。
2.由于窗体的Caption的颜色是渐变的
问题在Brush.Color := clActiveCaption;
可以解决
不过,麻烦,你自己思考吧
"另外“Your title here”的背景跟标题栏的背景不同。"
try
ACanvas.Handle := GetWindowDC(Form1.Handle);
with ACanvas do begin
Brush.Color := clActiveCaption;
Brush.Style := bsClear;//解决上述问题
Font.Name := 'Times New Roman';
Font.Size := 10;
Font.Color := clCaptionText;
Font.Style := [fsItalic, fsBold];