代碼文件:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ImgList;
type
TForm1 = class(TForm)
ImageList1: TImageList;
ButtonedEdit1: TButtonedEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure ButtonedEdit1LeftButtonClick(Sender: TObject);
procedure ButtonedEdit1RightButtonClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ButtonedEdit1.Alignment := taCenter; {居中顯示文本}
ButtonedEdit1.Images := ImageList1; {對應的圖像列表}
ButtonedEdit1.LeftButton.Visible := True; {允許顯示 LeftButton}
ButtonedEdit1.LeftButton.HotImageIndex := 0; {左: 鼠標懸停時的圖標}
ButtonedEdit1.LeftButton.ImageIndex := 1; {左: 正常顯示時的圖標}
ButtonedEdit1.LeftButton.PressedImageIndex := 2; {左: 鼠標點下時的圖標}
ButtonedEdit1.LeftButton.DisabledImageIndex := 6; {LeftButton 不可用時的圖標}
ButtonedEdit1.RightButton.Visible := True; {允許顯示 RightButton}
ButtonedEdit1.RightButton.HotImageIndex := 3; {右: 鼠標懸停時的圖標}
ButtonedEdit1.RightButton.ImageIndex := 4; {右: 正常顯示時的圖標}
ButtonedEdit1.RightButton.PressedImageIndex := 5; {右: 鼠標點下時的圖標}
ButtonedEdit1.RightButton.DisabledImageIndex := 6; {RightButton 不可用時的圖標}
end;
{點擊 LeftButton 的事件: OnLeftButtonClick}
procedure TForm1.ButtonedEdit1LeftButtonClick(Sender: TObject);
begin
ButtonedEdit1.Text := ' LeftButton ';
ButtonedEdit1.SelectAll;
end;
{點擊 RightButton 的事件: OnRightButtonClick}
procedure TForm1.ButtonedEdit1RightButtonClick(Sender: TObject);
begin
ButtonedEdit1.Text := ' RightButton ';
ButtonedEdit1.SelectAll;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ButtonedEdit1.LeftButton.Enabled := not ButtonedEdit1.LeftButton.Enabled;
ButtonedEdit1.RightButton.Enabled := not ButtonedEdit1.RightButton.Enabled;
end;
end.