TImageEnMView.AddThumbButtons
Declaration
procedure AddThumbButtons(Count: Integer;
Width, Height: Integer;
GetButtonEvent: TIEGetButtonEvent;
ButtonClickEvent: TIEButtonClickEvent;
Position : TIEMCheckboxPos = iecpAutomatic;
AlignVert: Boolean = False;
HMargin: Integer = 4; VMargin: Integer = 4;
Spacing: Integer = 4);
Description
Draw buttons over the thumbnail that the user can click to adjust the image.
Note:
◼Any existing buttons are cleared
◼Buttons do not take the control's enabled state into account, or handle their own enabled state. In your events, supply a different image for disabled state, and check whether enabled before processing a click event
◼To display a hint when hovering over the button use
OnGetHint
◼Add spacing to avoid drawing over the thumbnail using
LeftGap or
RightGap
◼Buttons will auto-hide if there is not enough space to show them
Parameter | Description |
Count | Number of buttons to draw |
Width, Height | Size of the button (in pixels) |
GetButtonEvent | Event where you provide an image to use for the button |
ButtonClickEvent | Event that will fire when a button is clicked (by the left mouse button) |
Position | Position of the buttons |
VertAlign | Align multiple buttons vertically, instead of horizontally |
HMargin, VMargin | Spacing between edge-most button and the side of the thumbnail |
Spacing | Spacing between buttons |
| Demos\Multi\ThumbButtons\ThumbButtons.dpr |
procedure TMainForm.FormCreate(Sender: TObject);
begin
// Add Three buttons at top right of thumbnail
ImageEnMView1.AddThumbButtons( 3,
ImageList1.Width, ImageList1.Height,
GetThumbButton,
ThumbButtonClick,
iecpTopRight );
end;
function TMainForm.ThumbButtonEnabled(ButtonIndex: Integer) : Boolean;
begin
Result := ImageEnMView1.Enabled;
if ( ButtonIndex = 0 ) and not ShowPreviewAvailable() then
Result := False
else
if ( ButtonIndex = 1 ) and not FixColorAvailable() then
Result := False
else
if ( ButtonIndex = 2 ) and not SaveImageAvailable() then
Result := False;
end;
procedure TMainForm.GetThumbButton(Sender: TObject; ThumbIndex, ButtonIndex: Integer; var Bitmap: TIEBitmap);
var
imgIndex: Integer;
ico: TIcon;
begin
// Get bitmap from TImageList
imgIndex := ButtonIndex;
if not ThumbButtonEnabled( ButtonIndex ) then
inc( imgIndex, 3 );
// Can do this if don't need alpha transparency
// ImageList1.GetBitmap( imgIndex, Bitmap.VclBitmap );
ico := TIcon.create;
TImageList( ImageList1 ).GetIcon( imgIndex , ico );
Bitmap.Assign( ico );
ico.Free;
end;
procedure TMainForm.ThumbButtonClick(Sender: TObject; ThumbIndex, ButtonIndex: Integer);
begin
if not ThumbButtonEnabled( ButtonIndex ) then
exit;
if ButtonIndex = 0 then
ShowPreview( ThumbIndex )
else
if ButtonIndex = 1 then
FixColor( ThumbIndex )
else
if ButtonIndex = 2 then
SaveImage( ThumbIndex );
end;