识别鼠标下的控件

更新时间:2023-06-25 02:03:41 阅读: 评论:0

在你的Delphi应用程序中,鼠标正在移动的时候,如果您需要知道鼠标“下”是什么样的控件,您可以使用RTL的FindVCLWindow函数
FindVCLWindow
该VCLWindow函数可以找到一个特定位置的窗口控件 - 例如鼠标指针的位置。当鼠标从一个控件移到另一个控件时,您可以使用FindVCLWindow来识别窗口控件。 pos参数指定要返回的窗口控件的位置。如果没有窗口下的pos参数控制,FindVCLWindow返回nil。
举个例子有带TApplicationEvents组件的应用程序窗体,它的OnIdle事件处理为:
//Handles OnIdle event of the ApplicationEvents1 control the MainForm
procedure TMainForm.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean) ;
var
humoresquectrl : TWinControl;
北京东直门>heartbeats歌词begin
ctrl := FindVCLWindow(Mou.CursorPos) ;
if ctrl <> nil then
begin
    Caption := ctrl.Name;
通常的英文
    //do something if mou is over TLabeledEdit高中毕业留学
    if ctrl is TLabeledEdit then
    begin
托福考试介绍      Caption := TLabeledEdit(ctrl).Text;
    end;
end;
end;

注:Mou.CursorPos返回鼠标指针在屏幕上的坐标到。
英文原文
vividly
If, in your Delphi application you need to know what control is "under" the mou while the mou is being moved over the application, you can u RTL's FindVCLWindow function.
FindVCLWindow
The VCLWindow function can locate the windowed control under a certain point - for example under the mou pointer. You can u FindVCLWindow to identify the windowed control that is under the mou from another control that has captured the mou. The Pos parameter specifies the location that must be over the returned windowed control. If there is no windowed control under the Pos parameter, FindVCLWindow returns nil.
2010年12月英语四级答案For an example have a TApplicationEvents component on the main form of the application and handle its OnIdle event as:
//Handles OnIdle event of the ApplicationEvents1 control the MainForm
procedure TMainForm.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean) ;
var
  ctrl : TWinControl;
begin
  ctrl := FindVCLWindow(Mou.CursorPos) ;

  if ctrl <> nil then
  begin
    Caption := ctrl.Name;ca是什么意思

    //do something if mou is over TLabeledEdit
    if ctrl is TLabeledEdit then
    begin回顾过去 展望未来
      Caption := TLabeledEdit(ctrl).Text;
    end;
  end;
end;


Note: Mou.CursorPos returns the coordinate of the mou pointer related to the screen.

本文发布于:2023-06-25 02:03:41,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1032984.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:鼠标   控件   位置
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图