读书人

delphi中关于TRect解决办法

发布时间: 2012-12-29 10:28:09 作者: rapoo

delphi中关于TRect


var
r:TRect;
begin

r:=ClientRect;
r.TopLeft:=Parent.ScreenToClient(ClientToScreen(r.TopLeft));
r.BottomRight:=Parent.ScreenToClient(ClientToScreen(r.BottomRight));
end;


TRect成员没有TopLeft或者是BottomRight啊,写成C++应该是什么样的呢?

[解决办法]
TRect r = ClientRect;
TPoint pt;

pt.x = r.Left;
pt.y = r.Top;
pt = Parent->ScreenToClient(ClientToScreen(pt));
r.Left = pt.x;
r.Top = pt.y;

pt.x = r.Right;
pt.y = r.Bottom;
pt = Parent->ScreenToClient(ClientToScreen(pt));
r.Right = pt.x;
r.Bottom = pt.y;


PS: 高版本的C++Builder中, TRect就有了TopLeft和BottomRight成员了.

读书人网 >C++ Builder

热点推荐