程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi 2009的TButtonedEdit實例(2)

Delphi 2009的TButtonedEdit實例(2)

編輯:Delphi

代碼文件:

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.

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved