急!请教一个画矩形并在其中填写文本的问题,谢谢

gloomyCat 2003-09-13 03:17:00
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);var
rect1:Trect;
begin
canvas.Rectangle(x,y,x+100,y+20);
rect1.left:=x;
rect1.Top:=y;
rect1.Right:=x+100;
rect1.Bottom:=y+20;
canvas.textrect(rect1,x,y,InputBox('请输入字符串','字符串',''));
end;
当我画了矩形并填写了一行字符串后,会出现矩形的部分或全部边框消失的情况,请问这
是什么原因,是不是有什么输出文本范围的属性要设置啊,非常感谢!!!!
...全文
31 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
gloomyCat 2003-09-16
  • 打赏
  • 举报
回复
procedure TForm1.FormMouseDown
~~~~~~~~~~~~~~但这里写的是MouseDown啊
cmain83 2003-09-16
  • 打赏
  • 举报
回复
注意:

Image 控件的 Visible 属性设为 False;

Image 就看不见了呀..

我上边不是说了嘛
cmain83 2003-09-15
  • 打赏
  • 举报
回复
这样吧.

在 Form 上放一个 Image 控件.
Image 控件的 Align 属性设为 alClient;
Visible 属性设为 False;


上边的代码改为以下
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);var
rect1:Trect;
begin
Image1.Canvas.Brush.Style := Canvas.Brush.Style;
Image1.Canvas.Brush.color := canvas.Brush.Color;
Image1.canvas.Rectangle(x,y,x+100,y+20);
canvas.Rectangle(x,y,x+100,y+20);
rect1.left:=x + 1;
rect1.Top:= y + 1;
rect1.Right:=x+99;
rect1.Bottom:=y+19;
Image1.canvas.textrect(rect1,x,y,InputBox('请输入字符串','字符串',''));
canvas.CopyRect(Rect(x,y,x+100,y+20), Image1.Canvas, Rect(x,y,x+100,y+20));
end;


gdfd 2003-09-15
  • 打赏
  • 举报
回复
image也有MOUSEDOWN吧……
gloomyCat 2003-09-15
  • 打赏
  • 举报
回复
不过image组件的Align属性设为了alclient,程序运行时,image充满了整个form内,点击form时根本就无法激发FormMouseDown事件啊,
gloomyCat 2003-09-13
  • 打赏
  • 举报
回复
我现在知道了,是被inputbox覆盖掉了,当inputbox消失以后form重新画了该部分,所以我想问一下怎样才能不被inputbox覆盖掉,是否能设置某些属性?谢谢
gloomyCat 2003-09-13
  • 打赏
  • 举报
回复
非常感谢,不过如果在同一个form上多画一些矩形并填写文本时(没有重叠),仍然会出现某些矩形边框被覆盖的情况,请问这是怎么回事,再次表示感谢
cmain83 2003-09-13
  • 打赏
  • 举报
回复
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);var
rect1:Trect;
begin
canvas.Rectangle(x,y,x+100,y+20);
rect1.left:=x + 1;
rect1.Top:= y + 1;
rect1.Right:=x+99;
rect1.Bottom:=y+19;
canvas.textrect(rect1,x,y,InputBox('请输入字符串','字符串',''));
end;

这样才不会把边框填了.
因为 textrect 过程是用当前画布颜色来填充的

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi GAME,图形处理/多媒体
社区管理员
  • GAME,图形处理/多媒体社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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