mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-08 22:38:26 +02:00
LCL: implement PromptForFileName in a Delphi compatible way (even though the function is badly designed IMHO). Issue #39740.
This commit is contained in:
parent
be5453fbcb
commit
09584a03b9
@ -730,6 +730,10 @@ function DefaultMessageBox(Text, Caption: PChar; Flags: Longint) : Integer;// wi
|
|||||||
function InputBox(const ACaption, APrompt, ADefault : string) : string;
|
function InputBox(const ACaption, APrompt, ADefault : string) : string;
|
||||||
function PasswordBox(const ACaption, APrompt : string) : string;
|
function PasswordBox(const ACaption, APrompt : string) : string;
|
||||||
|
|
||||||
|
function PromptForFileName(var AFileName: string; const AFilter: string = ''; const ADefaultExt: string = '';
|
||||||
|
const ATitle: string = ''; const AInitialDir: string = ''; AIsSaveDialog: Boolean = False): Boolean;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TCustomCopyToClipboardDialog = class(TForm)
|
TCustomCopyToClipboardDialog = class(TForm)
|
||||||
protected
|
protected
|
||||||
|
@ -259,6 +259,33 @@ begin
|
|||||||
ResolveLinks;
|
ResolveLinks;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function PromptForFileName(var AFileName: string;
|
||||||
|
const AFilter: string = '';
|
||||||
|
const ADefaultExt: string = '';
|
||||||
|
const ATitle: string = '';
|
||||||
|
const AInitialDir: string = '';
|
||||||
|
AIsSaveDialog: Boolean = False): Boolean;
|
||||||
|
var
|
||||||
|
Dlg: TOpenDialog;
|
||||||
|
begin
|
||||||
|
if AIsSaveDialog then
|
||||||
|
Dlg := TSaveDialog.Create(nil)
|
||||||
|
else
|
||||||
|
Dlg := TOpenDialog.Create(nil);
|
||||||
|
try
|
||||||
|
Dlg.FileName := AFileName;
|
||||||
|
Dlg.Filter := AFilter;
|
||||||
|
Dlg.DefaultExt := ADefaultExt;
|
||||||
|
Dlg.Title := ATitle;
|
||||||
|
Dlg.InitialDir := AInitialDir;
|
||||||
|
Result := Dlg.Execute;
|
||||||
|
if Result then
|
||||||
|
AFileName := Dlg.FileName;
|
||||||
|
finally
|
||||||
|
Dlg.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
//Helper function
|
//Helper function
|
||||||
function GetExtensionFromFilterAtIndex(Filter: String; Index: Integer): String;
|
function GetExtensionFromFilterAtIndex(Filter: String; Index: Integer): String;
|
||||||
|
Loading…
Reference in New Issue
Block a user