请教Rect 的作用

rcaicc 2004-08-13 04:45:00
看书上有这么一段:
var
glassrect:Trect;
begin
Canvas.Brush.Color:=clwhite;
glassrect:=rect
(glassleft,glasstop,glassleft+glasswidth*unitwidth,glasstop+glassheight*unittheight);
//常量:glassleft画面在窗体中位置,glasswidth画面的横竖格数,unitwidth每格的长度
Canvas.FillRect(glassrect);
end;

刚学delphi,rect这个函数我看快一天了,还是没搞懂为什么用,怎么用,什么时候用.....好迷茫啊。请各位帮忙讲一下,小弟愚笨,请略讲的仔细一些。顺便问一下,帮助怎么看?我只看到了rect返回值和具有overload属性(还不知道对不对),再没看懂什么了。
...全文
327 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
drift1981 2004-08-13
  • 打赏
  • 举报
回复
没错,
你试验一下不就清楚了!
rcaicc 2004-08-13
  • 打赏
  • 举报
回复
感谢楼上的回复~

近几日D版不知道为什么同时出现不少败类,哎~到有可能起到减压的作用......

var
glassrect:Trect;
begin
Canvas.Brush.Color:=clwhite;
glassrect:=rect
(glassleft,glasstop,glassleft+glasswidth*unitwidth,glasstop+glassheight*unittheight); Canvas.FillRect(glassrect);
end;
那这段程序的作用就是先定义一个矩形区域,然后Canvas.FillRect填充clwhite对么?
luke5678 2004-08-13
  • 打赏
  • 举报
回复
刚去一贴骂了个败类,回答草率,请楼主见谅:

function Rect(Left, Top, Right, Bottom: Integer): TRect;

Description

Call Rect to create a TRect that represents the rectangle with the specified coordinates. Use Rect to construct parameters for functions that require TRect, rather than setting up local variables for each parameter.

example:
The following code displays the text 揌ello, world!?in a rectangle defined by the coordinates (10, 10) and (100, 100).

var

TheRect: TRect;
begin
TheRect := Rect(10,10,100,100);
Form1.Canvas.TextRect(TheRect,10,10,'Hello, world!');
end;
ztenv 2004-08-13
  • 打赏
  • 举报
回复
F1
happy1123 2004-08-13
  • 打赏
  • 举报
回复
TRect是用来表示一个矩形,而Rect用来定义一个举行结构,它的四个参数依次为,左、上、右、下的坐标
beyondtkl 2004-08-13
  • 打赏
  • 举报
回复
呵呵 需要再看看基本的语法
纯冰糖 2004-08-13
  • 打赏
  • 举报
回复
同意楼上的,你也可以看看delphi自带的例子
drift1981 2004-08-13
  • 打赏
  • 举报
回复
function Rect(ALeft, ATop, ARight, ABottom: Integer): TRect; overload;
返回一个矩形,它带的参数限制了这个矩形的位置,
overload是重载,它可以通过参数的不同区分两个同名的函数

5,388

社区成员

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

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