ImageEn, unit ieopensavedlg |
|
TOpenImageEnDialog.OnCreateCustomControls
Declaration
property OnCreateCustomControls: TNotifyEvent;
Description
Occurs immediately before an open/save dialog is executed (shown).
This event is often used to add your own controls to the dialog. You should free custom controls in
OnDestroyCustomControls event.
Example 1
// Add a Paste button to the Open Image dialog
procedure TfrmMain.dlgOpenImageCreateCustomControls(Sender: TObject);
const
BUTTON_TOP = 0;
BUTTON_LEFT = 420;
BUTTON_WIDTH = 140;
BUTTON_HEIGHT = 25;
var
p: TWinControl;
btn: TButton;
begin
p := (sender as TOpenImageEnDialog).InfoPanel;
btn := TButton.Create(p);
btn.Parent := p;
btn.Caption := 'Paste from Clipboard';
// Note: Need to handle screen scaling
btn.SetBounds( BUTTON_LEFT, BUTTON_TOP, BUTTON_WIDTH, BUTTON_HEIGHT );
btn.OnClick := OpenDialogPasteBtnClick;
end;
procedure TfrmMain.OpenDialogPasteBtnClick(Sender: TObject);
var
dialogHandle: HWND;
begin
dialogHandle := GetActiveWindow;
if ImageEnView1.Proc.CanPasteFromClipboard() = False then
begin
MessageDlg( 'There is no image on the clipboard', mtInformation, [ mbOK ], 0 );
SetForegroundWindow( dialogHandle ); // Bring to front
end
else
begin
// Close the Open Dialog
if dialogHandle <> 0 then
EndDialog( dialogHandle, IDCANCEL );
ImageEnView1.Proc.PasteFromClipboard()
end;
end;
Example 2
// Add a checkbox to the Open dialog
procedure TForm1.OpenImageEnDialogCreateCustomControls(Sender: TObject);
var
p: TWinControl;
MyCbx : TCheckBox;
begin
p := (sender as TOpenImageEnDialog).InfoPanel;
MyCbx := TCheckBox.Create(p);
MyCbx.parent := p;
MyCbx.Caption := 'Test';
MyCbx.SetBounds(280, 0, 130, 23);
MyCbx.OnClick := OpenDialogCheckboxClick;
end;
Example 3
// Uncheck the "Show Preview" checkbox
procedure TForm1.OpenImageEnDialogCreateCustomControls(Sender: TObject);
begin
(sender as TOpenImageEnDialog).PreviewCheckBox.Checked := False;
end;