如何可知道当前控件在屏幕中的位置(Left,Top),而不是在其Parent中的位置?

Snakeguo 2001-11-26 11:06:12
...全文
224 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
王集鹄 2001-11-29
  • 打赏
  • 举报
回复
嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻
Snakeguo 2001-11-27
  • 打赏
  • 举报
回复
谢谢大家的热心帮助,特别感谢zswang(伴水)(伤心中)的热心,结贴了.
王集鹄 2001-11-26
  • 打赏
  • 举报
回复
GetWindowPos()
taxi 2001-11-26
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
p: Tpoint;
begin
P := Button1.Parent.ClientToScreen(Point(Button1.Left, Button1.Top));
ShowMessage(IntToStr(p.X) + '..' + IntToStr(p.Y));
end;
tikkypeng 2001-11-26
  • 打赏
  • 举报
回复
p, CP:TPoint ;
begin
dc := GetWindowDC(0);
p.x:= button1.Left;
p.y:= button1.Top;
CP:= ClientToScreen(p);
thedream 2001-11-26
  • 打赏
  • 举报
回复
噢错了,第二句应该是button1.top:=form1.top+button1.top;
thedream 2001-11-26
  • 打赏
  • 举报
回复
button1.left:=form1.left+button1.left;
button1.top:=form1.left+button1.top;
王集鹄 2001-11-26
  • 打赏
  • 举报
回复
我的方法不是最好的
如果是SpeedButton、Image这种非Win控件就不行
因为没有Handle了
王集鹄 2001-11-26
  • 打赏
  • 举报
回复
var
vRect: TRect;
begin
GetWindowRect(Button1.Handle, vRect);
(*
vRect.Left
vRect.Top
*)
end;
王集鹄 2001-11-26
  • 打赏
  • 举报
回复
GetWindowRect()
kevin_gao 2001-11-26
  • 打赏
  • 举报
回复
ClientToScreen(p);
iBear 2001-11-26
  • 打赏
  • 举报
回复
这些控件一般都有clienttoscreen和screentoclient两个方法进行相关的操作。
Snakeguo 2001-11-26
  • 打赏
  • 举报
回复
zswang(伴水)(伤心中):
GetWindowPos()?好像没有这个函数

5,388

社区成员

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

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