DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: sy1012
今日帖子: 0
在线用户: 3
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 qingyun (qingyun) ★☆☆☆☆ -
盒子活跃会员
2004/1/10 16:21:51
标题:
下面这个软件右上角那个最小化按钮左边那个按钮是怎么做的 浏览:1302
加入我的收藏
楼主: 下面这个软件右上角那个最小化按钮左边那个按钮 我常在一些软件里看到,
它的功能是可以让窗体置在最前面,

有谁知道这个技术细节是怎么处理的。
我很想学习这个技巧

按此在新窗口浏览图片
----------------------------------------------
青云论坛
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/1/10 16:47:47
1楼: 拦消息自己画
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/1/10 16:48:30
2楼: 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;
    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

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-5*xSize+2,yFrame+2,xSize+13,ySize-4);
  Canvas.Handle:=GetWindowDC(Self.Handle);
  Canvas.Font.Name:='宋体';
  Canvas.Font.Color:=clBlue;
  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+2,R.Top,'TEST');
  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('good');
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.

----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行80.07813毫秒 RSS