演示效果:

添加控件:Form1,Button1,Label1,Label2,Timer1

GetCapture:返回当前捕获鼠标输入的窗口的句柄
SetCapture():通过句柄设置指定窗口来捕获鼠标的输入
ReleaseCapture:释放当前捕获鼠标的窗口的捕获功能
同一时间只能有一个前景窗口可以捕获鼠标。当在控件上按下鼠标时,会自动执行SetCapture(),这时该控件的鼠标移动事件在全屏都会触发,松开鼠标按键时自动执行ReleaseCapture释放捕获

代码文件:

unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, ExtCtrls, StdCtrls;typeTForm1 = class(TForm)Button1: TButton;Label1: TLabel;Label2: TLabel;Timer1: TTimer;procedure Timer1Timer(Sender: TObject);procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);private{ Private declarations }public{ Public declarations }end;varForm1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
beginif GetCapture=Button1.Handle thenLabel2.Caption:='Get'elseLabel2.Caption:='Release'
end;procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
beginLabel1.Caption:=Format('%d,%d',[x,y]);
end;end.

窗体文件:


object Form1: TForm1 Left = 412 Top = 202 Width = 262 Height = 164 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 16 Top = 8 Width = 24 Height = 13 Caption = '坐标' end object Label2: TLabel Left = 16 Top = 32 Width = 32 Height = 13 Caption = 'Label2' end object Button1: TButton Left = 16 Top = 56 Width = 75 Height = 57 Caption = 'Button1' TabOrder = 0 OnMouseMove = Button1MouseMove end object Timer1: TTimer Interval = 100 OnTimer = Timer1Timer Left = 208 Top = 8 end end


转载于:https://www.cnblogs.com/mashang/archive/2009/03/17/1414767.html

API - SetCapture(),ReleaseCapture与GetCapture - 鼠标移动的捕获与释放相关推荐

  1. 理解SetCapture、ReleaseCapture、GetCapture(控制了消息发往哪个窗口,是理解消息的关键)

    理解SetCapture.ReleaseCapture.GetCapture 正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪 ...

  2. CWnd::SetCapture, ReleaseCapture, GetCapture

    一般,只有鼠标在CWnd的客户区内,你才能接受到鼠标消息.调用SetCapture后,即使鼠标移动出客户区,你也可以接受到鼠标消息.不过系统中只能有一个程序调用SetCapture,所以你需要在不使用 ...

  3. SetCapture、ReleaseCapture、GetCapture

    正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪,鼠标消息都发给指定的这个窗口,直到调用ReleaseCapture或者调用S ...

  4. SetCapture, ReleaseCapture, GetCapture

    来自:http://blog.csdn.net/weiwangchao_/article/details/6955970 一般,只有鼠标在CWnd的客户区内,你才能接受到鼠标消息.调用SetCaptu ...

  5. 理解SetCapture、ReleaseCapture、GetCapture

    正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪,鼠标消息都发给指定的这个窗口,直到调用ReleaseCapture或者调用S ...

  6. MFC中的SetCapture、ReleaseCapture、GetCapture函数

    转载地址:http://blog.csdn.net/laowu_/article/details/6839345 正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetC ...

  7. CWnd SetCapture ReleaseCapture GetCapture

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 一般,只 ...

  8. 理解SetCapture、ReleaseCapture、GetCapture(控制了消息发往哪个窗口,是理解消息的关键)...

    理解SetCapture.ReleaseCapture.GetCapture 正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪 ...

  9. SetCapture/ReleaseCapture 使用场景

    说明1  ::SetCapture(GetDlgItem(IDC_XX)->m_hWnd); or GetDlgItem(IDC_XX)->SetCapture(); 要与ReleaseC ...

最新文章

  1. R语言删除ggplot可视化图中的所有x轴轴标签实战:ggplot可视化默认包含所有x轴轴标签、删除ggplot可视化图中的所有x轴轴标签实战
  2. 微软Windows Azure Platform技术解析
  3. nodemanager_如何使用NodeManager来控制WebLogic Server
  4. 面向数据流的设计方法
  5. java web 调度_javaweb车辆调度信息管理平台
  6. xml中的if和截取字符串
  7. 令人失望的智器Smart Q5
  8. LAMP架构简介与配置
  9. Clearcase no version selected issue
  10. 微信,你的野心到底有多大?
  11. Centos 7 设置静态IP地址
  12. 数学建模论文、代码降重小技巧
  13. 135编辑器点击换图html,这5种换图姿势,只有排版高手才会!
  14. android 常用机型尺寸_安卓手机屏幕多大合适?6.4英寸是“黄金尺寸”吗?
  15. java 视频录制软件有哪些_有哪些好用的视频录制工具?
  16. eclipse怎么在包里建一个包
  17. 免费的艺术二维码生成器
  18. FFplay文档解读-7-比特流过滤器
  19. 历经24小时,依靠全球定位,帮女朋友找回丢失的华为手机!
  20. ARM嵌入式系统开发:软件设计与优化--第二章ARM处理器基础

热门文章

  1. prometheus监控软件的使用
  2. 传统图像分割——分水岭算法(watershed)
  3. 聚类分析在用户行为中的实例_网站用户行为分析案例
  4. 互联网公司的应届生情况
  5. [笔记分享] [遥控器]Android红外及蓝牙遥控器适配流程
  6. 蓝桥杯国信长天单片机实战--交通灯设计
  7. PTA 7-14 十六进制转十进制
  8. 爆笑三国之火烧博望坡
  9. 小米以“不能胜任工作”为由辞退员工,两次上诉均败诉
  10. C++ lq 长整型、字符运算