拖动没有标题栏的窗体

http://delphi.about.com/od/windowsshellapi/a/dragnocaption.htm
步骤如下:
1、在窗体的private声明中写下:
procedure WMNCHitTest( var Msg: TWMNCHitTest) ; message WM_NCHitTest;
2、在implement声明:
procedure  TForm1.WMNCHitTest( var  Msg: TWMNCHitTest) ;
begin
   inherited;
   
if  Msg.Result  =  htClient  then  Msg.Result : =  htCaption; // 欺骗windows
end

以上代码,只有鼠标是在窗体上移动拖拉时才有效。如果窗体上有panel,而且是alClient,那么以上代码则无效。
需要加入以下代码:

procedure  TForm1.Panel1MouseDown
   (Sender: TObject; Button: TMouseButton;
   Shift: TShiftState; X, Y: Integer) ;
begin
   ReleaseCapture;
   SendMessage(Form1.Handle, WM_SYSCOMMAND, 
61458 0 ) ;
end

 

还有其他变通情况:
if Msg.Result = htClose then Msg.Result := htNowhere;
if Msg.Result = htCaption then Msg.Result := htClient;// 不给移动窗体

转载于:https://www.cnblogs.com/samsonleung/archive/2008/07/02/1234205.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值