正在阅读:在窗口标题区添加按钮在窗口标题区添加按钮

2004-02-14 09:34 出处:电脑爱好者 作者:南京 邹莉 责任编辑:pjl
unit Unit1; interface uses Windows, Buttons, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormResize(Sender: TObject); private { Private declarations } CaptionBtn:TRect; procedure DrawCaptButton; rocedure WMNCPaint(var Msg:TWMNCPaint);message WM_NCPaint; procedure WMNCActivate(var Msg:TWMNCActivate);message WM_NCActivate; procedure WMSetText(var Msg:TWMSetText);message WM_SetText; procedure WMNCHitTest(var Msg:TWMNCHitTest);message WM_NCHittest; procedure WMNCLButtonDown(var Msg:TWMNCLButtonDown);message WM_NCLButtonDown; public { Public declarations } end; var Form1: TForm1; implementation const htCaptionBtn=htSizeLast+1; {$R *.DFM} procedure TForm1.DrawCaptButton; var xFrame,yFrame,xSize,ySize:Integer; R:TRect; begin xFrame:=GetSystemMetrics(SM_CXFRAME); yFrame:=GetSystemMetrics(SM_CYFRAME); xSize:=GetSystemMetrics(SM_CXSIZE); ySize:=GetSystemMetrics(SM_CYSIZE); CaptionBtn:=Bounds(Width-xFrame-4*xSize+2,yFrame+2,xSize+1,ySize-4); Canvas.Handle:=GetWindowDC(Self.Handle); Canvas.Font.Name:='宋体'; Canvas.Font.Color:=clBlack; Canvas.Pen.Color:=clYellow; Canvas.Brush.Color:=clBtnFace; try DrawButtonFace(Canvas,CaptionBtn,1,bsAutoDetect,False,False,False); R:=Bounds(Width-xFrame-4*xSize+3,yFrame+3,xSize-2,ySize-7); with CaptionBtn do Canvas.TextRect(R,R.Left+2,R.Top+2,'?'); finally ReleaseDC(Self.Handle,Canvas.Handle); Canvas.Handle:=0; end; end;
键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品