截获非客户区重画消息WM_NCPaint,自己画非客户区

解决方案 »

  1.   

    netlib(河外孤星) 的方法很佩服
    但_liangzi_() 可谓机智简洁,有意思。
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);  private
        { Private declarations }
        procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT;
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      Cap:String;
    implementation{$R *.dfm}procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
    var ACanvas: TCanvas;
        intLeftShift, intTopShift: Integer;
    begin
      inherited;  ACanvas := TCanvas.Create;
      try
        {to retrieve the device context for the Form1 window}
        ACanvas.Handle := GetWindowDC(Form1.Handle);
        with ACanvas do
        begin
          //Brush.Color := clNone ;//clActiveCaption;
          SetBkMode(ACanvas.Handle,TRANSPARENT);
          //Font.Style := [fsItalic];
          Font.Color := clWhite;
          Font.Style := [fsBold] ;      {calculate the left coordinate for caption drawing}
          intLeftShift := GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CXBORDER);
          {calculate the top coordinate for caption drawing}
          intTopShift := (GetSystemMetrics(SM_CYCAPTION) - Abs(Font.Height)) div 2 + 1;      {output the caption string}
          TextOut(intLeftShift+200, intTopShift, Cap);
        end;
      finally
        {to release the device context}
        ReleaseDC(Form1.Handle, ACanvas.Handle);
        ACanvas.Free
      end;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Cap:=Caption;
    Form1.Caption :='';
    end;end.
      

  3.   

    TextOut(intLeftShift+200, intTopShift, Cap);
    这步是输出文字,至于在Caption的中间么,自己算一下吧
      

  4.   

    Form.caption:='                  我最懒了            ’;