;
x,y,i:integer;
begin
x:=0;y:=0;
form1.canvas.pen.width:=1;
fori:=0to8do
begin
form1.canvas.pen.color:=$00a0a0a0;
form1.canvas.moveto(Button1.left+Button1.width+x,
Button1.top+y);
form1.canvas.lineto(Button1.left+Button1.width+x,
Button1.top+button1.height+y);
form1.canvas.pen.color:=$00606060;
form1.canvas.moveto(Button1.left+x,
Button1.top+Button1.height+y);
form1.canvas.lineto(Button1.left+Button1.width+x,
Button1.top+button1.height+y);
x:=x+1;
y:=y+1;
end;
end;
procedure TForm1.Button3Click(Sender:TObject);
var
x,y,i:integer;
begin
x:=0;y:=0;
form1.canvas.pen.width:=1;
fori:=0to8do
begin
form1.canvas.pen.color:=$00404040;
form1.canvas.moveto(Button1.left+Button1.width+x,
Button1.top+8);
form1.canvas.lineto(Button1.left+Button1.width+x,
Button1.top+button1.height+8);
form1.canvas.moveto(Button1.left+8,
Button1.top+Button1.height+y);
form1.canvas.lineto(Button1.left+Button1.width+8,
Button1.top+button1.height+y);
x:=x+1;
y:=y+1;
end;
end;
2.为控件加上边框:DELPHI中有很多控件无边框属性,利用CANVAS
可以为任意的控件填加边框,使其轮廓清楚;具体操作时,可先定
义出画笔的颜色、画笔的宽度(边框宽度),之后用polyline()命
令根据相应控件的位置、尺寸自动定位四角坐标,一次可完成一
个固定宽度矩形的绘制工作,如果需要多种颜色或者具有立体效
果的边框,可多次定义画笔颜色,画出连续的多个矩形,通过调
整相邻矩形的颜色来实现特殊效果的边框绘制工作;比如在窗体
中安放两个按钮,分别在MOUSEMOVE事件中填加如下代码,之后每
当鼠标移到相应的按钮上时,相应的按钮就会出现特殊颜色的边
框,当鼠标移到窗口空白处时,则窗口会出现明显的边线,起到特
殊的提示效果;
procedure TForm1.Button1MouseMove
(Sender:TObject;Shift:TShiftState;X,Y:Integer);
begin