TButtonedEdit (Delphi)
Description
This example shows how to use the TButtonedEdit class. This example implements a component, such as TButtonedEdit search, that can be found in the tool pallete window. Entering the control enables the right button; the left button will display a MessageDlg and the right button will clear the input text.
Code
procedure TForm4.btnEditEnter(Sender: Tobject);
begin
btnEdit.Text := '';
btnEdit.RightButton.Visible := true;
end;
procedure TForm4.btnEditLeftClick(Sender: Tobject);
begin
MessageDlg('Left button pressed with: ' + btnEdit.Text,
mtInformation, [mbYes], 0);
end;
procedure TForm4.btnEditRightClick(Sender: Tobject);
begin
//Resetting to default state
btnEdit.Text := 'Default';
btnEdit.RightButton.Visible := false;
end;
procedure TForm4.FormCreate(Sender: TObject);
var
imList : TImageList;
bmap : TBitmap;
myBalloon : TBalloonHint;
begin
//Declaring an instance
btnEdit := TButtonedEdit.Create(Self);
//Setting the parent to auto delete itself
btnEdit.Parent := Self;
//Positioning
btnEdit.Left := 10;
btnEdit.Top := 10;
//Creating a TImageList and using it for the button
imList := TImageList.Create(Self);
myBalloon := TBalloonHint.Create(Self);
bmap := TBitmap.Create();
bmap.LoadFromFile('littleB_16.bmp');
imList.Add(bmap,nil);
bmap.LoadFromFile('little_logo_16.bmp');
imList.Add(bmap,nil);
btnEdit.Images := imList;
myBalloon.Images := imList;
myBalloon.Tag := 1;
//Selecting the image for the left button and enabling it
btnEdit.LeftButton.Visible := true;
btnEdit.LeftButton.Enabled := true;
btnEdit.LeftButton.CustomHint := myBalloon;
btnEdit.LeftButton.Hint := 'short|long hint|1';
btnEdit.LeftButton.ImageIndex := 0;
btnEdit.LeftButton.DisabledImageIndex := 0;
btnEdit.LeftButton.PressedImageIndex := 0;
btnEdit.LeftButton.HotImageIndex := 0;
//Selecting the image for the right button.
//This will be enabled when the content changes.
btnEdit.RightButton.Visible := true;
btnEdit.RightButton.Enabled := true;
btnEdit.RightButton.Hint := 'Right';
btnEdit.RightButton.ImageIndex := 1;
btnEdit.RightButton.DisabledImageIndex := 1;
btnEdit.RightButton.PressedImageIndex := 1;
btnEdit.RightButton.HotImageIndex := 1;
//Selecting action for the buttoned edit to take
btnEdit.OnEnter := btnEditEnter;
btnEdit.OnRightButtonClick := btnEditRightClick;
btnEdit.OnLeftButtonClick := btnEditLeftClick;
btnEdit.ShowHint := True;
//Default text in the edit
btnEdit.Text := 'Default';
btnEdit.Constraints.MinHeight := 16;
btnEdit.Height := 16;
//Displaying the button
btnEdit.Show();
end;
Uses
- Vcl.ExtCtrls.TButtonedEdit ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton ( fr | de | ja )
- Vcl.ExtCtrls.TCustomButtonedEdit.LeftButton ( fr | de | ja )
- Vcl.ExtCtrls.TCustomButtonedEdit.RightButton ( fr | de | ja )
- Vcl.ExtCtrls.TCustomButtonedEdit.Images ( fr | de | ja )
- Vcl.ExtCtrls.TCustomButtonedEdit.OnLeftButtonClick ( fr | de | ja )
- Vcl.ExtCtrls.TCustomButtonedEdit.OnRightButtonClick ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton.Enabled ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton.ImageIndex ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton.DisabledImageIndex ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton.PressedImageIndex ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton.HotImageIndex ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton.Hint ( fr | de | ja )
- Vcl.ExtCtrls.TEditButton.CustomHint ( fr | de | ja )