在paintbox上画图,怎么才能使画出的图能完全填充paintbox
我的表格画完后,会在旁边多出一些没用的线条
怎么才能去掉这些多余的线条
本来是想按paintbox的大小来平均等分,但那样做依然会在旁边多出线条
请问各位高人,该如何实现?procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
with paintbox1 do
begin
i:=left;
while i<=left+width do
begin
canvas.MoveTo(i,top);
canvas.LineTo(i,top+height);
inc(i,trunc(width/20));
end;j:=top;
while j<=top+height do
begin
canvas.MoveTo(left,j);
canvas.LineTo(left+width,j);
inc(j,trunc(width/20));
end;
end;end;
我的表格画完后,会在旁边多出一些没用的线条
怎么才能去掉这些多余的线条
本来是想按paintbox的大小来平均等分,但那样做依然会在旁边多出线条
请问各位高人,该如何实现?procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
with paintbox1 do
begin
i:=left;
while i<=left+width do
begin
canvas.MoveTo(i,top);
canvas.LineTo(i,top+height);
inc(i,trunc(width/20));
end;j:=top;
while j<=top+height do
begin
canvas.MoveTo(left,j);
canvas.LineTo(left+width,j);
inc(j,trunc(width/20));
end;
end;end;
到最后判断一下剩下的空间,如果需要画就画,不需要就不画了
怎么才能画出最下和最右的线,请大虾指点
i,j:integer;
begin
with paintbox1 do
begin
canvas.MoveTo(left,top);
canvas.LineTo(left,height);
canvas.MoveTo(width-1,top);
canvas.LineTo(width-1,height);
canvas.MoveTo(left,top);
canvas.LineTo(width,top);
canvas.MoveTo(left,height-1);
canvas.LineTo(width,height-1);
i := 0;
while i < width do
begin
canvas.MoveTo(left+i,top);
canvas.LineTo(left+i,height);
inc(i,trunc(width/20));
end;
j := 0;
while j < height do
begin
canvas.MoveTo(left,top+j);
canvas.LineTo(width,top+j);
inc(j,trunc(height/20));
end;
end;
end;