TImageEnMView.OnGetTextEx
Declaration
property OnGetTextEx: TIEGetTextExEvent;
Description
Occurs before text is output when drawing a thumbnail allowing you to insert or modify the displayed text and change the styling.
Note:
◼If
Style is
iemsColumns then
OnGetText is also called for the header row. The
Index will be -1.
◼If
default text has not been specified for any thumbnails, or you are increasing the size of the font, you may need to set
UpperGap/
BottomGap to allow space for the text
◼You cannot set the font color if the control is disabled
◼A simpler event,
OnGetText, can be used if you don't need to customize font styling
// Display the file as bold if it is JPEG
procedure TForm1.IEFolderMViewGetTextEx(Sender: TObject; Index: Integer; Position: TIEMTextPos; var Text: WideString;
var Font : TFont; var BackgroundStyle: TBrushStyle; var BackgroundColor: TColor;
var TruncSide: TIEMTruncSide);
begin
if ( Position <> iemtpBottom ) or ( Index = -1 ) then
exit;
sFileExt := ExtractFileExt( Text );
if IEExtToFileFormat( sFileExt ) = ioJPEG then
Font.Style := [fsBold]
else
Font.Style := [];
end;
// Give text on every thumb a random background color
procedure TForm1.IEFolderMViewGetTextEx(Sender: TObject; Index: Integer; Position: TIEMTextPos; var Text: WideString;
Font : TFont; var BackgroundStyle: TBrushStyle; var BackgroundColor: TColor;
var TruncSide: TIEMTruncSide);
begin
BackgroundColor := RGB( Random( 256 ), Random( 256 ), Random( 256 ));
BackgroundStyle := bsSolid;
end;
// Make text no wider than half the thumbnail width
procedure TForm1.ImageEnMViewGetText(Sender: TObject; Index: Integer; Position: TIEMTextPos; var Text: WideString);
begin
Text := IETruncateStr( Text, TruncSide, ImageEnMView1.GetCanvas, ImageEnMView1.ThumbWidth div 2 );
end;