BusinessSkinForm皮肤做的界面,如何给标题栏加入一个自定义的按钮呢
解决方案 »
- 如何用TGifImage取出一个gif动画的每一帧,并显示
- 请教一个由句柄获取对象实例的问题
- 如何在memo或richedit中读取文件中特定的行??
- 请问要修改文件的内容用什么函数,介绍一下fileSeek的用法,我看帮助不是很清楚
- 她就这样的离开了我~~~
- 捕获数字键输入的问题
- 请教一下,如何判断SQLServer2000中数据库master是否存在某个存储过程?
- 菜鸟问题,调用外部程序的API函数忘了
- 各位英雄,我实在解决不了这个问题了!
- 哪儿有好的杀毒软件下载(win2000server)
- Intraweb开发BS软件 用report machine做报表找不到数据源
- 本人求购屏幕画笔源代码
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,Buttons;type
TForm1 = class(TForm)
procedure FormResize(Sender: TObject);
private
{ Private declarations }
CaptionBtn: TRect ;
Procedure DrawCaptButton;
Procedure 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{$R *.dfm}{ TForm1 }const
HtCaptionBtn = HtSizeLast + 1;
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-5*xSize+2, yFrame+2, xSize+13, 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-5*xSize+3, yFrame+3, xSize+10, ySize-7);
With CaptionBtn Do
Canvas.TextRect(R, R.Left, R.Top, 'New');
finally
ReleaseDC(self.Handle, Canvas.Handle);
Canvas.Handle:= 0;
end;
end;
Procedure TForm1.WMNCActivate(var Msg: TWMNCActivate);
begin
inherited;
DrawCaptButton;
end;Procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
inherited;
With Msg Do
if PtInRect(CaptionBtn, Point(xPos-Left, yPos-Top)) then
Result := HtCaptionBtn;
end;
Procedure TForm1.WMNCLButtonDown(var Msg: TWMNCLButtonDown);
begin
inherited;
if (Msg.HitTest = HtCaptionBtn) then
ShowMessage('添加您要执行的代码');
end;Procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
begin
inherited;
DrawCaptButton;
end;Procedure TForm1.WMSetText(var Msg: TWMSetText);
begin
inherited;
DrawCaptButton;
end;procedure TForm1.FormResize(Sender: TObject);
begin
Perform(WM_NCActivate, Word(Active), 0);
end;
end.