Moves the code to set the initial dir for win32 from the LCL to the win32 widgetset. Fixes bug #17772

git-svn-id: trunk@28055 -
This commit is contained in:
sekelsenmat 2010-11-03 10:54:18 +00:00
parent 65fda5bbfe
commit 56f71a1c43
3 changed files with 11 additions and 8 deletions

View File

@ -113,7 +113,6 @@ type
FFilterIndex: Integer;
FHistoryList: TStrings;
FInitialDir: string;
FOldWorkingDir: string;
FOnHelpClicked: TNotifyEvent;
FOnTypeChange: TNotifyEvent;
procedure SetDefaultExt(const AValue: string);

View File

@ -56,13 +56,7 @@ end;
{------------------------------------------------------------------------------}
function TFileDialog.Execute : boolean;
begin
FOldWorkingDir:=GetCurrentDirUTF8;
if FInitialDir<>'' then SetCurrentDirUTF8(FInitialDir);
try
Result:=inherited Execute;
finally
SetCurrentDirUTF8(FOldWorkingDir);
end;
Result:=inherited Execute;
end;
{------------------------------------------------------------------------------

View File

@ -723,11 +723,15 @@ end;
class procedure TWin32WSOpenDialog.ShowModal(const ACommonDialog: TCommonDialog);
var
State: TApplicationState;
lOldWorkingDir, lInitialDir: string;
begin
if ACommonDialog.Handle <> 0 then
begin
State := SaveApplicationState;
lOldWorkingDir:=GetCurrentDirUTF8;
try
lInitialDir := TOpenDialog(ACommonDialog).InitialDir;
if lInitialDir <>'' then SetCurrentDirUTF8(lInitialDir);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
@ -740,6 +744,7 @@ begin
GetOpenFileName(LPOPENFILENAME(ACommonDialog.Handle)));
{$endif}
finally
SetCurrentDirUTF8(lOldWorkingDir);
RestoreApplicationState(State);
end;
end;
@ -750,11 +755,15 @@ end;
class procedure TWin32WSSaveDialog.ShowModal(const ACommonDialog: TCommonDialog);
var
State: TApplicationState;
lOldWorkingDir, lInitialDir: string;
begin
if ACommonDialog.Handle <> 0 then
begin
State := SaveApplicationState;
lOldWorkingDir:=GetCurrentDirUTF8;
try
lInitialDir := TSaveDialog(ACommonDialog).InitialDir;
if lInitialDir <>'' then SetCurrentDirUTF8(lInitialDir);
{$ifdef WindowsUnicodeSupport}
if UnicodeEnabledOS then
ProcessFileDialogResult(TOpenDialog(ACommonDialog),
@ -767,6 +776,7 @@ begin
GetSaveFileName(LPOPENFILENAME(ACommonDialog.Handle)));
{$endif}
finally
SetCurrentDirUTF8(lOldWorkingDir);
RestoreApplicationState(State);
end;
end;