Skip to content

Commit

Permalink
Fixes from Sieghard for msefilegialog.pas and msefiledialogx.pas.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredvs committed May 8, 2024
1 parent 0fb4546 commit e026fb4
Show file tree
Hide file tree
Showing 4 changed files with 2,136 additions and 2,121 deletions.
12 changes: 7 additions & 5 deletions lib/common/dialogs/msefiledialog.pas
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ tfiledialogcontroller = class(tlinkedpersistent)
foptions: filedialogoptionsty;
////////////////////////////////////
fwindowrect: rectty;
////////////////////////////////////
public
////////////////////////////////////
DialogPlacement: dialogposty;
Expand Down Expand Up @@ -579,8 +580,8 @@ tfiledialogfo = class (tdialogform) // tmseform)
procedure afterclosedrop(const sender: TObject);

////////////////////////////////////////////
procedure StateRead (const sender: TObject; const reader: tStatReader);
procedure StateWrite (const sender: TObject; const writer: tStatWriter);
procedure StateRead (const sender: TObject; const reader: tStatReader); VIRTUAL;
procedure StateWrite (const sender: TObject; const writer: tStatWriter); VIRTUAL;
////////////////////////////////////////////
// procedure resized (const sender: TObject);
////////////////////////////////////////////
Expand Down Expand Up @@ -2128,9 +2129,10 @@ function tfiledialogcontroller.execute (dialogkind: filedialogkindty;
po1:= nil;
end;
////////////////////////////////////
if assigned (providedform)
then fo:= providedform
else fo:= tfiledialogfo.create ({?nil?}fowner, DialogPlacement);
if assigned (providedform) then begin
fo:= providedform; fo.setposition (DialogPlacement);
end
else fo:= tfiledialogfo.create ({?nil?}fowner, DialogPlacement);
fwindowrect:= fo.widgetrect;
////////////////////////////////////
// fo:= tfiledialogfo.create(nil);
Expand Down
2 changes: 2 additions & 0 deletions lib/common/dialogs/msefiledialogx.mfm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ object filedialogxfo: Tfiledialogxfo
oncreated = onformcreated
onkeydown = listviewonkeydown
onresize = onresize
onstatread = StateRead
onstatwrite = StateWrite
onlayout = layoutev
left = 239
top = 138
Expand Down
63 changes: 36 additions & 27 deletions lib/common/dialogs/msefiledialogx.pas
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,12 @@ tfiledialogxfo = class (tdialogform) // tmseform)
procedure onpain(const sender: twidget; const acanvas: tcanvas);

////////////////////////////////////////////
procedure StateRead (const sender: TObject; const reader: tStatReader);
procedure StateWrite (const sender: TObject; const writer: tStatWriter);
procedure StateRead (const sender: TObject; const reader: tStatReader); VIRTUAL;
procedure StateWrite (const sender: TObject; const writer: tStatWriter); VIRTUAL;
////////////////////////////////////////////
// procedure resized (const sender: TObject);
////////////////////////////////////////////
// procedure componentevent(const event: tcomponentevent); override;
////////////////////////////////////////////

private
Expand Down Expand Up @@ -1391,6 +1395,7 @@ procedure tfileitemlist.createitem(out item: tlistitem);
BEGIN
INHERITED Create (Sender, StatName, where);
fcontroller:= tfiledialogxcontroller.create (Self);
fcontroller.DialogPlacement:= where;
END;

CONSTRUCTOR tfiledialogxfo.Create (CONST Sender: TComponent; where: dialogposty);
Expand Down Expand Up @@ -3074,10 +3079,10 @@ procedure tfiledialogxcontroller.checklink;
fowner.sendrootcomponentevent(tcomponentevent.Create(self), True);
end;

// function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty; const acaption: msestring; aoptions: filedialogoptionsty): modalresultty; overload;
// function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty; const acaption: msestring; aoptions: filedialogoptionsty): modalresultty;
////////////////////////////////////
function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty; const acaption: msestring; aoptions: filedialogoptionsty;
providedform: tfiledialogxfo = nil): modalresultty; overload;
providedform: tfiledialogxfo = nil): modalresultty;
////////////////////////////////////
var
po1: pmsestringarty;
Expand Down Expand Up @@ -3111,9 +3116,13 @@ function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty; const aca
po1 := nil;

////////////////////////////////////
if assigned (providedform)
then fo:= providedform
else fo:= tfiledialogxfo.create ({?nil?}fowner, DialogPlacement);
if assigned (providedform) then begin
fo:= providedform; fo.setposition (DialogPlacement);
writeln ('Using provided form');
end
else begin fo:= tfiledialogxfo.create ({?nil?}fowner, DialogPlacement);
writeln ('Using NEW form');
end;
fwindowrect:= fo.widgetrect;
////////////////////////////////////
// fo:= tfiledialogxfo.create(nil);
Expand Down Expand Up @@ -3391,13 +3400,13 @@ function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty; const aca
end;
end;

// function tfiledialogxcontroller.Execute (const dialogkind: filedialogkindty; const acaption: msestring): modalresultty; overload;
// function tfiledialogxcontroller.Execute (const dialogkind: filedialogkindty; const acaption: msestring): modalresultty;
////////////////////////////////////
function tfiledialogxcontroller.Execute (const dialogkind: filedialogkindty; const acaption: msestring;
providedform: tfiledialogxfo = nil): modalresultty; overload;
providedform: tfiledialogxfo = nil): modalresultty;
////////////////////////////////////
begin
Result := Execute(dialogkind, acaption, foptions);
Result := Execute(dialogkind, acaption, foptions, providedform);
end;

function tfiledialogxcontroller.actcaption (const dialogkind: filedialogkindty): msestring;
Expand All @@ -3418,21 +3427,21 @@ function tfiledialogxcontroller.actcaption (const dialogkind: filedialogkindty):
end;
end;

// function tfiledialogxcontroller.Execute (const dialogkind: filedialogkindty; const aoptions: filedialogoptionsty): modalresultty; overload;
// function tfiledialogxcontroller.Execute (const dialogkind: filedialogkindty; const aoptions: filedialogoptionsty): modalresultty;
////////////////////////////////////
function tfiledialogxcontroller.Execute (const dialogkind: filedialogkindty; const aoptions: filedialogoptionsty;
providedform: tfiledialogxfo = nil): modalresultty; overload;
providedform: tfiledialogxfo = nil): modalresultty;
////////////////////////////////////
begin
if fdo_directory in aoptions then
Result := Execute(dialogkind, fcaptiondir, aoptions) else
Result := Execute(dialogkind, actcaption(dialogkind), aoptions);
Result := Execute(dialogkind, fcaptiondir, aoptions, providedform) else
Result := Execute(dialogkind, actcaption(dialogkind), aoptions, providedform);
end;

// function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty = fdk_none): modalresultty; overload;
// function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty = fdk_none): modalresultty;
////////////////////////////////////
function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty = fdk_none;
providedform: tfiledialogxfo = nil): modalresultty; overload;
providedform: tfiledialogxfo = nil): modalresultty;
////////////////////////////////////
begin
if dialogkind = fdk_none then
Expand All @@ -3442,13 +3451,13 @@ function tfiledialogxcontroller.Execute (dialogkind: filedialogkindty = fdk_none
dialogkind := fdk_none;
if fdo_directory in foptions then
Result := Execute(dialogkind, fcaptiondir) else
Result := Execute(dialogkind, actcaption(dialogkind));
Result := Execute(dialogkind, actcaption(dialogkind), providedform);
end;

// function tfiledialogxcontroller.Execute (var avalue: filenamety; dialogkind: filedialogkindty = fdk_none): Boolean; overload;
// function tfiledialogxcontroller.Execute (var avalue: filenamety; dialogkind: filedialogkindty = fdk_none): Boolean;
////////////////////////////////////
function tfiledialogxcontroller.Execute (var avalue: filenamety; dialogkind: filedialogkindty = fdk_none;
providedform: tfiledialogxfo = nil): Boolean; overload;
providedform: tfiledialogxfo = nil): Boolean;
////////////////////////////////////
begin
if dialogkind = fdk_none then
Expand All @@ -3458,14 +3467,14 @@ function tfiledialogxcontroller.Execute (var avalue: filenamety; dialogkind: fil
dialogkind := fdk_none;

if fdo_directory in foptions then
Result := Execute(avalue, dialogkind, fcaptiondir) else
Result := Execute(avalue, dialogkind, actcaption(dialogkind));
Result := Execute(avalue, dialogkind, fcaptiondir, providedform) else
Result := Execute(avalue, dialogkind, actcaption(dialogkind), providedform);
end;

// function tfiledialogxcontroller.Execute (var avalue: filenamety; const dialogkind: filedialogkindty; const acaption: msestring; aoptions: filedialogoptionsty): Boolean; overload;
// function tfiledialogxcontroller.Execute (var avalue: filenamety; const dialogkind: filedialogkindty; const acaption: msestring; aoptions: filedialogoptionsty): Boolean;
////////////////////////////////////
function tfiledialogxcontroller.Execute (var avalue: filenamety; const dialogkind: filedialogkindty; const acaption: msestring; aoptions: filedialogoptionsty;
providedform: tfiledialogxfo = nil): Boolean; overload;
providedform: tfiledialogxfo = nil): Boolean;
////////////////////////////////////
var
wstr1: filenamety;
Expand All @@ -3479,7 +3488,7 @@ function tfiledialogxcontroller.Execute (var avalue: filenamety; const dialogkin
Exit;
end;
filename := avalue;
Result := Execute(dialogkind, acaption, aoptions) = mr_ok;
Result := Execute(dialogkind, acaption, aoptions, providedform) = mr_ok;
if Result then
begin
avalue := filename;
Expand Down Expand Up @@ -3514,13 +3523,13 @@ function tfiledialogxcontroller.canoverwrite(): Boolean;
{$endif}
end;

// function tfiledialogxcontroller.Execute (var avalue: filenamety; const dialogkind: filedialogkindty; const acaption: msestring): Boolean; overload;
// function tfiledialogxcontroller.Execute (var avalue: filenamety; const dialogkind: filedialogkindty; const acaption: msestring): Boolean;
////////////////////////////////////
function tfiledialogxcontroller.Execute (var avalue: filenamety; const dialogkind: filedialogkindty; const acaption: msestring;
providedform: tfiledialogxfo = nil): Boolean; overload;
providedform: tfiledialogxfo = nil): Boolean;
////////////////////////////////////
begin
Result := Execute(avalue, dialogkind, acaption, foptions);
Result := Execute(avalue, dialogkind, acaption, foptions, providedform);
end;

function tfiledialogxcontroller.getfilename: filenamety;
Expand Down
Loading

0 comments on commit e026fb4

Please sign in to comment.