您现在的位置:首页 >> 界面报表 >> 界面报表 >> 内容

Delphi中在窗体标题栏画自定义文字

时间:2011/9/3 15:24:06 点击:

  核心提示:600) this.width = 600;'>type TCustomCaptionForm = class(TForm) private procedure WMNCPaint(var Msg:...

600) this.width = 600;">

type
   TCustomCaptionForm = class(TForm)
   private
     procedure WMNCPaint(var Msg: TWMNCPaint) ; message WM_NCPAINT;
     procedure WMNCACTIVATE(var Msg: TWMNCActivate) ; message WM_NCACTIVATE;
     procedure DrawCaptionText() ;
   end;

...

implementation


procedure TCustomCaptionForm .DrawCaptionText;
const
   captionText = 'delphi.about.com';
var
   canvas: TCanvas;
begin
   canvas := TCanvas.Create;
   try
     canvas.Handle := GetWindowDC(Self.Handle) ;
     with canvas do
     begin
       Brush.Style := bsClear;
       Font.Color := clMaroon;
       TextOut(Self.Width - 110, 6, captionText) ;
     end;
   finally
     ReleaseDC(Self.Handle, canvas.Handle) ;
     canvas.Free;
   end;
end;

procedure TCustomCaptionForm.WMNCACTIVATE(var Msg: TWMNCActivate) ;
begin
   inherited;
   DrawCaptionText;
end;

procedure TCustomCaptionForm.WMNCPaint(var Msg: TWMNCPaint) ;
begin
   inherited;
   DrawCaptionText;
end;

作者:站长 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号