main.pas
来自「《Kylix程序设计》一书中附带的例程源代码」· PAS 代码 · 共 90 行
PAS
90 行
unit Main;interfaceuses SysUtils, Types, Classes, Variants, QGraphics, QControls, QForms, QDialogs, QStdCtrls, QExtCtrls;type TFrmMain = class(TForm) BtnShow: TButton; procedure BtnShowClick(Sender: TObject); private { Private declarations } public { Public declarations } end;var FrmMain: TFrmMain;implementationuses Shapes;{$R *.xfm}procedure TFrmMain.BtnShowClick(Sender: TObject);var X, Y: Integer; str: string; Shape: TGeoShape; Point: TGeoPoint; Line: TGeoLine;begin X := 10; Y := 10; Shape := TGeoShape.Create(); str := Shape.Draw(); Canvas.TextOut( X, Y, '(TGeoShape)Shape:' ); Canvas.TextOut( X+270, Y, str ); FreeAndNil( Shape ); Inc( Y, 25 ); Point := TGeoPoint.Create(); str := Point.Draw(); Canvas.TextOut( X, Y, '(TGeoPoint)Point:' ); Canvas.TextOut( X+270, Y, str ); FreeAndNil( Point ); Inc( Y, 25 ); Line := TGeoLine.Create(); str := Line.Draw(); Canvas.TextOut( X, Y, '(TGeoLine)Line:' ); Canvas.TextOut( X+270, Y, str ); FreeAndNil( Line ); Inc( Y, 25 ); Shape := TGeoPoint.Create(); str := Shape.Draw(); Canvas.TextOut( X, Y, '(TGeoPoint)Shape:' ); Canvas.TextOut( X+270, Y, str ); FreeAndNil( Shape ); Inc( Y, 25 ); Shape := TGeoPoint.Create(); str := TGeoPoint( Shape ).Draw(); Canvas.TextOut( X, Y, '(TGeoPoint)TGeoPoint(Shape):' ); Canvas.TextOut( X+270, Y, str ); FreeAndNil( TGeoPoint( Shape ) ); Inc( Y, 25 );{ Shape := TGeoPoint.Create(); str := Shape.Draw( Canvas ); // Error. Too many parameters Canvas.TextOut( X, Y, '(TGeoPoint)Shape:' ); Canvas.TextOut( X+270, Y, str ); FreeAndNil( TGeoPoint( Shape ) ); Inc( Y, 25 );} Shape := TGeoPoint.Create(); str := TGeoPoint( Shape ).Draw( Canvas ); Canvas.TextOut( X, Y, '(TGeoPoint)TGeoPoint(Shape):' ); Canvas.TextOut( X+270, Y, str ); FreeAndNil( TGeoPoint( Shape ) ); Inc( Y, 25 );end;end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?