,可先定
义出画笔的颜色、画笔的宽度(边框宽度),之后用polyline()命
令根据相应控件的位置、尺寸自动定位四角坐标,一次可完成一
个固定宽度矩形的绘制工作,如果需要多种颜色或者具有立体效
果的边框,可多次定义画笔颜色,画出连续的多个矩形,通过调
整相邻矩形的颜色来实现特殊效果的边框绘制工作;比如在窗体
中安放两个按钮,分别在MOUSEMOVE事件中填加如下代码,之后每
当鼠标移到相应的按钮上时,相应的按钮就会出现特殊颜色的边
框,当鼠标移到窗口空白处时,则窗口会出现明显的边线,起到特
殊的提示效果;
procedureTForm1.Button1MouseMove
(Sender:TObject;Shift:TShiftState;X,Y:Integer);
begin
form1.repaint;
form1.Canvas.pen.color:=clGreen;
form1.Canvas.pen.width:=5;
form1.Canvas.polyline([point(Button1.left,Button1.top),
point(Button1.left+Button1.width,Button1.top),
point(Button1.left+Button1.width,Button1.top+Button1.hei
ght),
point(Button1.left,Button1.top+Button1.height),
point(Button1.left,Button1.top)]);
end;
procedureTForm1.Button2MouseMove
(Sender:TObject;Shift:TShiftState;X,
Y:Integer);
begin
form1.repaint;
form1.Canvas.pen.color:=clBlue;
form1.Canvas.pen.width:=5;
form1.Canvas.polyline([point(Button2.left,Button2.top),
point(Button2.left+Button2.width,Button2.top),
point(Button2.left+Button2.width,Button2.top+Button2.hei
ght),
point(Button2.left,Button2.top+Button2.height),
point(Button2.left,Button2.top)]);
end;
procedureTForm1.FormMouseMove
(Sender:TObject;Shift:TShiftState;X,
Y:Integer);
begin
form1.repaint;
form1.Canvas.pen.color:=clRed;
form1.Canvas.pen.width:=3;
form1.Canvas.polyline([point(0,0),point(form1.width-
10,0),
point(form1.width-10,form1.height-30),
point(0,form1.height-30),point(0,0)]);
end;
3.为图形按钮或其它控件安装动态帮助功能,此处主要使用它的
字符串显示功能,也就是当鼠标移到指定控件上时,在其周围适当
位置显示相应的字符串,当鼠标离开时通过图像覆盖动作使字符
串消失,也可以使用一个简单的命令完成即form1.repaint,它的