main.pas

来自「delphi6 programming example」· PAS 代码 · 共 68 行

PAS
68
字号
unit Main;

interface

uses Windows, Classes, Graphics, Forms, Controls,
     StyleD, ListD, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    StyleButton: TButton;
    Bevel1: TBevel;
    procedure LabelDoubleClick(Sender: TObject);
    procedure LabelClick(Sender: TObject);
    procedure StyleButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.LabelDoubleClick(Sender: TObject);
begin
  with ListDial.Listbox1 do
  begin
    // select current the name in the listbox
    ItemIndex := Items.IndexOf ((Sender as TLabel).Caption);
    // show the modal dialog box, checking the return value
    if (ListDial.ShowModal = mrOk) and (ItemIndex >= 0) then
      // if OK, then copy the selected item of the list to the label
      (Sender as TLabel).Caption := Items [ItemIndex];
  end;
end;

procedure TForm1.LabelClick(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to ComponentCount - 1 do
   if (Components[I] is TLabel) and
       (Components[I].Tag = 1) then
     TLabel (Components[I]).Font.Color := clBlack;

  // set the color of the clicked label to red
  (Sender as TLabel).Font.Color := clRed;
end;

procedure TForm1.StyleButtonClick(Sender: TObject);
begin
  // run modeless dialog
  StyleDial.Show;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?