当前位置:主页>仓库管理软件> 列表

如何判断一个控件是否在选中的区域中? 找管家进销存破解版

记账软件版1楼: 我画了一个矩形框,我要判断一下界面上的哪些控件都被我这个框选中了,有api吗?

2楼: 没有吧,还得用土办法.认坐标. 如管家进销存破解版

3楼: 通过坐标来判断不就可以了吗
判断鼠标是否在控件的坐标区域内

4楼: 看来只能判断了,想偷个懒,有没有现成的算法啊,嘿嘿,谢谢啦!

二楼,判断鼠标好象不行吧,画区域的时候鼠标不一定经过的

5楼: 判断控件在屏幕的坐标.

6楼: 那现在问题就转换成了判断两个区域是否重叠了,看来是没api了,哪位有写过函数吗?

记账软件版7楼: 判断坐标怎么判断啊,选那个点呢?难道得上下左右四条边那么比较吗?我晕哦!

8楼: :)
VB有写过,Delphi就没有.现在也不用VB了.

9楼: 用最笨的办法写了一个,汗!
function GetRectIsOverlap(Rect1,Rect2:TRect):boolean;
begin
result := false;

if Rect2.Left > Rect1.Left then
begin
if Rect2.Left < Rect1.Right then
if Rect2.Top > Rect1.Top then
begin
if Rect2.Top < Rect1.Bottom then
result := true


end
else
begin
if Rect2.Bottom > Rect1.Top then
result := true;
end;
end
else
begin
if Rect1.Left < Rect2.Right then
if Rect2.Top > Rect1.Top then
begin
if Rect2.Top < Rect1.Bottom then
result := true
end
else
begin
if Rect2.Bottom > Rect1.Top then
result := true;
end;
end;
end;

10楼: 挺好,有的时候写程序就得这么笨.

11楼: 多人接受答案了。