歡迎光臨 Code²

Code Square, CodeSqaure, Pascal, Javascript

2008年12月12日星期五

完整範例 - Fontlist (2/10)

  就如一般的Delphi程序,我們要做的第一件事就是設計使用者界面。Fontlist的功能並不复雜,所以使用界面很簡單,我們只需要五個TButton和一個TDrawGrid,字型的樣本將顯示在TDrawGrid上。使用TDrawGrid並沒有特別的原因,改用TListBox可以。

  界面的截圖和dfm文件如下:

fontu.dfm顯示代碼

  這時我們仍然未有多少代碼,只是簡單地加上了退出的功能:procedure btnCloseClick(Sender: TObject);

fontu.pas隱藏代碼
unit Fontu;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Grids;

type
  TForm1 = class(TForm)
    btnSystem: TButton;
    btnFolder: TButton;
    btnSelectFolder: TButton;
    btnSaveBmp: TButton;
    btnClose: TButton;
    Grid: TDrawGrid;
    procedure btnCloseClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.btnCloseClick(Sender: TObject);
begin
  Close;
end;

end.

  FontList.dpr由Delphi自動產生,沒有任何變動。

FontList.dpr隱藏代碼
program FontList;

uses
  Forms,
  fontu in 'fontu.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

沒有留言:

發佈留言