根据鼠标移动 获取控件名称

nottinghill 2004-11-10 04:22:36
怎么做啊??比如多个按钮 在多个分页的form上,鼠标点到那个,就显示空间名称,怎么做啊??
...全文
324 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
nottinghill 2004-11-11
  • 打赏
  • 举报
回复
再次谢谢各位大侠
nottinghill 2004-11-11
  • 打赏
  • 举报
回复
呵呵,我用as也可以
jinjazz 2004-11-10
  • 打赏
  • 举报
回复
〉〉MD。。昨晚去验光。。近视深了。。烦。。配个眼镜去掉400多大洋~~日!~~!猛不起来了

哈哈,让你在和俺抢分..
hottey 2004-11-10
  • 打赏
  • 举报
回复
哈哈,再次崇拜。
cnhgj 2004-11-10
  • 打赏
  • 举报
回复
var
pos:Tpoint;
namestr:string;
begin
GetCursorPos(pos);
if FindVCLWindow(pos) is TButton then
begin
namestr:=FindVCLWindow(pos).Name;
listbox1.Items.add(namestr);
end;
end;
nottinghill 2004-11-10
  • 打赏
  • 举报
回复
FindVCLWindow返回的结果是Twincontrol 非 Tbutton ,无法调用,有办法 downcast么??
hottey 2004-11-10
  • 打赏
  • 举报
回复
崇拜楼上的JR们^_^
cnhgj 2004-11-10
  • 打赏
  • 举报
回复
MD。。昨晚去验光。。近视深了。。烦。。配个眼镜去掉400多大洋~~日!~~!猛不起来了
劣势 2004-11-10
  • 打赏
  • 举报
回复
var
pos:Tpoint;
namestr:string;
begin
GetCursorPos(pos);
namestr:=FindVCLWindow(pos).Name;
listbox1.Items.add(namestr);
end;

如果我只显示TBUTTOND的呢??

如果只显示TButton
var
pos:Tpoint;
namestr:string;
begin
GetCursorPos(pos);
namestr:=FindVCLWindow(pos).Name;
if FindVCLWindow(pos) is TButton then listbox1.Items.add(namestr);//ok了
end;

nottinghill 2004-11-10
  • 打赏
  • 举报
回复
var
pos:Tpoint;
namestr:string;
begin
GetCursorPos(pos);
namestr:=FindVCLWindow(pos).Name;
listbox1.Items.add(namestr);
end;

如果我只显示TBUTTOND的呢??
jinjazz 2004-11-10
  • 打赏
  • 举报
回复
楼上的昨天还号称猛男,今天就近视了??
cnhgj 2004-11-10
  • 打赏
  • 举报
回复
var
pos:Tpoint;
namestr:string;
begin
GetCursorPos(pos);
namestr:=FindVCLWindow(pos).Name;
listbox1.Items.add(namestr);
end;
jinjazz 2004-11-10
  • 打赏
  • 举报
回复
procedure TFormMain.Timer1Timer(Sender: TObject);
var
p:tpoint;
curwin:longint;
Parwin:longint;
text,textp:array[0..255] of Char;
var start:cardinal;
begin
getcursorpos(p);
curwin:=windowfrompoint(p);
if (listbox1.Handle=curwin) or (Handle=curwin) then exit;
getclassname(curwin,text,255);
parWin:=GetParent(curwin);
getclassname(parWin,textp,255);
Listbox1.Items.Add(inttostr(curwin)+':'+text+' parent:'+inttostr(parWin)+':'+textp);
listbox1.ItemIndex:=listbox1.Count-1;
end;
cnhgj 2004-11-10
  • 打赏
  • 举报
回复
TButton(sender).Name;
luke5678 2004-11-10
  • 打赏
  • 举报
回复
Hint

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧