API - SetCapture(),ReleaseCapture与GetCapture - 鼠标移动的捕获与释放
演示效果:
添加控件: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 - 鼠标移动的捕获与释放相关推荐
- 理解SetCapture、ReleaseCapture、GetCapture(控制了消息发往哪个窗口,是理解消息的关键)
理解SetCapture.ReleaseCapture.GetCapture 正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪 ...
- CWnd::SetCapture, ReleaseCapture, GetCapture
一般,只有鼠标在CWnd的客户区内,你才能接受到鼠标消息.调用SetCapture后,即使鼠标移动出客户区,你也可以接受到鼠标消息.不过系统中只能有一个程序调用SetCapture,所以你需要在不使用 ...
- SetCapture、ReleaseCapture、GetCapture
正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪,鼠标消息都发给指定的这个窗口,直到调用ReleaseCapture或者调用S ...
- SetCapture, ReleaseCapture, GetCapture
来自:http://blog.csdn.net/weiwangchao_/article/details/6955970 一般,只有鼠标在CWnd的客户区内,你才能接受到鼠标消息.调用SetCaptu ...
- 理解SetCapture、ReleaseCapture、GetCapture
正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪,鼠标消息都发给指定的这个窗口,直到调用ReleaseCapture或者调用S ...
- MFC中的SetCapture、ReleaseCapture、GetCapture函数
转载地址:http://blog.csdn.net/laowu_/article/details/6839345 正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetC ...
- CWnd SetCapture ReleaseCapture GetCapture
分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 一般,只 ...
- 理解SetCapture、ReleaseCapture、GetCapture(控制了消息发往哪个窗口,是理解消息的关键)...
理解SetCapture.ReleaseCapture.GetCapture 正常情况下,鼠标指针位于哪个窗口区域内,鼠标消息就自动发给哪个窗口.如果调用了SetCapture,之后无论鼠标的位置在哪 ...
- SetCapture/ReleaseCapture 使用场景
说明1 ::SetCapture(GetDlgItem(IDC_XX)->m_hWnd); or GetDlgItem(IDC_XX)->SetCapture(); 要与ReleaseC ...
最新文章
- R语言删除ggplot可视化图中的所有x轴轴标签实战:ggplot可视化默认包含所有x轴轴标签、删除ggplot可视化图中的所有x轴轴标签实战
- 微软Windows Azure Platform技术解析
- nodemanager_如何使用NodeManager来控制WebLogic Server
- 面向数据流的设计方法
- java web 调度_javaweb车辆调度信息管理平台
- xml中的if和截取字符串
- 令人失望的智器Smart Q5
- LAMP架构简介与配置
- Clearcase no version selected issue
- 微信,你的野心到底有多大?
- Centos 7 设置静态IP地址
- 数学建模论文、代码降重小技巧
- 135编辑器点击换图html,这5种换图姿势,只有排版高手才会!
- android 常用机型尺寸_安卓手机屏幕多大合适?6.4英寸是“黄金尺寸”吗?
- java 视频录制软件有哪些_有哪些好用的视频录制工具?
- eclipse怎么在包里建一个包
- 免费的艺术二维码生成器
- FFplay文档解读-7-比特流过滤器
- 历经24小时,依靠全球定位,帮女朋友找回丢失的华为手机!
- ARM嵌入式系统开发:软件设计与优化--第二章ARM处理器基础