本文整理自网络,侵删。
代码文件:
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.
相关阅读 >>
更多相关阅读请进入《Delphi》频道 >>