• 通过控件移动窗体 标签: integer 20080520 16:13 342人阅读 评论(0) 收藏


    所谓通过控件移动窗体,常用于无边框窗口的移动,需要通过拖动某个控件来使整个窗体移动。

    简单总结下两种方法

    方法1:HTCLIENT转换为HTCAPTION

    函数定义
      private
        { Private declarations }
        procedure WMNCHitTest(var Msg:TWMNCHitTest);message WM_NCHITTEST;
    函数实现
    procedure TmForm.WMNCHitTest(var Msg:TWMNCHitTest);
    var
      p: TPoint;
    begin
      DefaultHandler(Msg);

      
    if Msg.Result = HTCLIENT then begin
      with JvHTLabel1 
    do begin
        p.X:
    = Left; p.Y:= Top;
        p :
    = Application.MainForm.ClientToScreen(p);
        
    if (Msg.XPos > p.X) and (Msg.XPos < p.X + Width) and
           (Msg.YPos 
    > p.Y) and (Msg.YPos < p.Y + Height) then
        begin
          Msg.Result:
    = HTCAPTION;
          SetCursor(LoadCursor(
    0,IDC_SIZEALL));
        end;
      end;
      end;
    end;

    方法2:发送系统消息

    给目标控件添加OnMouseDown消息处理函数,实现方法很简单

    procedure TmForm.JvHTLabel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      ReleaseCapture;
      SetCursor(LoadCursor(0,IDC_SIZEALL));
      Perform(WM_SYSCOMMAND,$F012,0);
    end;
  • 相关阅读:
    Helpers Overview
    Validation
    Support Facades
    Session Store
    位运算(参考百科)
    开源项目_可能使用到的开源项目集合
    秒杀系统架构分析与实战(转)
    shell命令之根据字符串查询文件对应行记录
    MySQL做为手动开启事务用法
    spring 加载bean过程源码简易解剖(转载)
  • 原文地址:https://www.cnblogs.com/zerofire/p/7162176.html
Copyright © 2020-2023  润新知