H
highsnow
Unregistered / Unconfirmed
GUEST, unregistred user!
程序的目的是:窗体改变大小时自动修改坐标系。但当窗体便大时,坐标系画不全,窗体变小可以。为什么?
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
procedure DrawCoordinate(CHeight,CWidth: Integer);
procedure ClearCanvas;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.DrawCoordinate(CHeight,CWidth: Integer);
var
x : Integer;
y : Integer;
begin
Canvas.Pen.Width:=1;
Canvas.Pen.Color := clRed;
x := 0;
y := Trunc(CHeight/2)-10;
Canvas.MoveTo(x,y);
x := CWidth;
Canvas.LineTo(x, y);
x := 0;
y := Trunc(CHeight/2);
Canvas.MoveTo(x,y);
x := CWidth;
Canvas.LineTo(x, y);
x := 0;
y := CHeight-10;
Canvas.MoveTo(x,y);
x := CWidth;
Canvas.LineTo(x, y);
x := CWidth-30;
y := 0;
Canvas.MoveTo(x,y);
y := CHeight;
Canvas.LineTo(x, y);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DrawCoordinate(Self.ClientHeight,Self.ClientWidth);
end;
procedure TForm1.ClearCanvas;
begin
with Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := clWhite;
FillRect(ClientRect);
Canvas.Refresh;
end;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
ClearCanvas;
DrawCoordinate(Self.ClientHeight,Self.ClientWidth);
end;
end.
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
procedure DrawCoordinate(CHeight,CWidth: Integer);
procedure ClearCanvas;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.DrawCoordinate(CHeight,CWidth: Integer);
var
x : Integer;
y : Integer;
begin
Canvas.Pen.Width:=1;
Canvas.Pen.Color := clRed;
x := 0;
y := Trunc(CHeight/2)-10;
Canvas.MoveTo(x,y);
x := CWidth;
Canvas.LineTo(x, y);
x := 0;
y := Trunc(CHeight/2);
Canvas.MoveTo(x,y);
x := CWidth;
Canvas.LineTo(x, y);
x := 0;
y := CHeight-10;
Canvas.MoveTo(x,y);
x := CWidth;
Canvas.LineTo(x, y);
x := CWidth-30;
y := 0;
Canvas.MoveTo(x,y);
y := CHeight;
Canvas.LineTo(x, y);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DrawCoordinate(Self.ClientHeight,Self.ClientWidth);
end;
procedure TForm1.ClearCanvas;
begin
with Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := clWhite;
FillRect(ClientRect);
Canvas.Refresh;
end;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
ClearCanvas;
DrawCoordinate(Self.ClientHeight,Self.ClientWidth);
end;
end.