mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 15:59:15 +02:00
win32: fix incorrect filename return in TSaveDialog
git-svn-id: trunk@16870 -
This commit is contained in:
parent
fce2a78da2
commit
862affa6fe
@ -138,7 +138,7 @@ type
|
|||||||
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function OpenFileDialogCallBack(hWnd: Handle; uMsg: UINT; wParam: WPARAM;
|
function OpenFileDialogCallBack(Wnd: HWND; uMsg: UINT; wParam: WPARAM;
|
||||||
lParam: LPARAM): UINT; stdcall;
|
lParam: LPARAM): UINT; stdcall;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -325,6 +325,44 @@ begin
|
|||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure UpdateStorage(Wnd: HWND; OpenFile: LPOPENFILENAME);
|
||||||
|
var
|
||||||
|
FilesSize: SizeInt;
|
||||||
|
FolderSize: SizeInt;
|
||||||
|
DialogRec: POpenFileDialogRec;
|
||||||
|
begin
|
||||||
|
DialogRec := POpenFileDialogRec(OpenFile^.lCustData);
|
||||||
|
{$ifdef WindowsUnicodeSupport}
|
||||||
|
if UnicodeEnabledOS then
|
||||||
|
begin
|
||||||
|
FolderSize := CommDlg_OpenSave_GetFolderPathW(GetParent(Wnd), nil, 0);
|
||||||
|
FilesSize := CommDlg_OpenSave_GetSpecW(GetParent(Wnd), nil, 0);
|
||||||
|
SetLength(DialogRec^.UnicodeFolderName, FolderSize - 1);
|
||||||
|
CommDlg_OpenSave_GetFolderPathW(GetParent(Wnd),
|
||||||
|
PWideChar(DialogRec^.UnicodeFolderName),
|
||||||
|
FolderSize);
|
||||||
|
|
||||||
|
SetLength(DialogRec^.UnicodeFileNames, FilesSize - 1);
|
||||||
|
CommDlg_OpenSave_GetSpecW(GetParent(Wnd),
|
||||||
|
PWideChar(DialogRec^.UnicodeFileNames),
|
||||||
|
FilesSize);
|
||||||
|
end else
|
||||||
|
{$endif}
|
||||||
|
begin
|
||||||
|
FolderSize := CommDlg_OpenSave_GetFolderPath(GetParent(Wnd), nil, 0);
|
||||||
|
FilesSize := CommDlg_OpenSave_GetSpec(GetParent(Wnd), nil, 0);
|
||||||
|
SetLength(DialogRec^.AnsiFolderName, FolderSize - 1);
|
||||||
|
CommDlg_OpenSave_GetFolderPath(GetParent(Wnd),
|
||||||
|
PChar(DialogRec^.AnsiFolderName),
|
||||||
|
FolderSize);
|
||||||
|
|
||||||
|
SetLength(DialogRec^.AnsiFileNames, FilesSize - 1);
|
||||||
|
CommDlg_OpenSave_GetSpec(GetParent(Wnd),
|
||||||
|
PChar(DialogRec^.AnsiFileNames),
|
||||||
|
FilesSize);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{Common code for OpenDialog and SaveDialog}
|
{Common code for OpenDialog and SaveDialog}
|
||||||
|
|
||||||
{The API of the multiselect open file dialog is a bit problematic.
|
{The API of the multiselect open file dialog is a bit problematic.
|
||||||
@ -356,7 +394,7 @@ end;
|
|||||||
retrieving the files is used.
|
retrieving the files is used.
|
||||||
}
|
}
|
||||||
|
|
||||||
function OpenFileDialogCallBack(hWnd: Handle; uMsg: UINT; wParam: WPARAM;
|
function OpenFileDialogCallBack(Wnd: HWND; uMsg: UINT; wParam: WPARAM;
|
||||||
lParam: LPARAM): UINT; stdcall;
|
lParam: LPARAM): UINT; stdcall;
|
||||||
|
|
||||||
procedure Reposition(ADialogWnd: Handle);
|
procedure Reposition(ADialogWnd: Handle);
|
||||||
@ -382,90 +420,34 @@ var
|
|||||||
OpenFileNotify: LPOFNOTIFY;
|
OpenFileNotify: LPOFNOTIFY;
|
||||||
OpenFileName: Windows.POPENFILENAME;
|
OpenFileName: Windows.POPENFILENAME;
|
||||||
DialogRec: POpenFileDialogRec;
|
DialogRec: POpenFileDialogRec;
|
||||||
FilesSize: SizeInt;
|
|
||||||
FolderSize: SizeInt;
|
|
||||||
begin
|
begin
|
||||||
if uMsg = WM_INITDIALOG then
|
if uMsg = WM_INITDIALOG then
|
||||||
begin
|
begin
|
||||||
// Windows asks us to initialize dialog. At this moment controls are not
|
// Windows asks us to initialize dialog. At this moment controls are not
|
||||||
// arranged and this is that moment when we should set bounds of our dialog
|
// arranged and this is that moment when we should set bounds of our dialog
|
||||||
Reposition(GetParent(hWnd));
|
Reposition(GetParent(Wnd));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if uMsg = WM_NOTIFY then
|
if uMsg = WM_NOTIFY then
|
||||||
begin
|
begin
|
||||||
OpenFileNotify := LPOFNOTIFY(lParam);
|
OpenFileNotify := LPOFNOTIFY(lParam);
|
||||||
if OpenFileNotify <> nil then
|
if OpenFileNotify = nil then
|
||||||
begin
|
Exit;
|
||||||
|
|
||||||
OpenFileName := OpenFileNotify^.lpOFN;
|
OpenFileName := OpenFileNotify^.lpOFN;
|
||||||
DialogRec := POpenFileDialogRec(OpenFileName^.lCustData);
|
DialogRec := POpenFileDialogRec(OpenFileName^.lCustData);
|
||||||
end
|
UpdateStorage(Wnd, OpenFileName);
|
||||||
else
|
UpdateFileProperties(OpenFileName);
|
||||||
begin
|
|
||||||
OpenFileName := nil;
|
|
||||||
DialogRec := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
case OpenFileNotify^.hdr.code of
|
case OpenFileNotify^.hdr.code of
|
||||||
CDN_SELCHANGE:
|
CDN_SELCHANGE:
|
||||||
begin
|
|
||||||
// NeededSize is the size that the lpStrFile buffer must have.
|
|
||||||
// the lpstrFile buffer contains the directory and a list of files
|
|
||||||
// for example 'c:\winnt'#0'file1.txt'#0'file2.txt'#0#0.
|
|
||||||
// GetFolderPath returns upper limit for the path, GetSpec for the files.
|
|
||||||
// This is not exact because the GetSpec returns the size for
|
|
||||||
// '"file1.txt" "file2.txt"', so that size will be two chars per filename
|
|
||||||
// more than needed in the lpStrFile buffer.
|
|
||||||
{$ifdef WindowsUnicodeSupport}
|
|
||||||
if UnicodeEnabledOS then
|
|
||||||
begin
|
|
||||||
FolderSize := CommDlg_OpenSave_GetFolderPathW(GetParent(hwnd), nil, 0);
|
|
||||||
FilesSize := CommDlg_OpenSave_GetSpecW(GetParent(hwnd), nil, 0);
|
|
||||||
SetLength(DialogRec^.UnicodeFolderName, FolderSize-1);
|
|
||||||
CommDlg_OpenSave_GetFolderPathW(GetParent(hwnd),
|
|
||||||
PWideChar(DialogRec^.UnicodeFolderName),
|
|
||||||
FolderSize);
|
|
||||||
|
|
||||||
SetLength(DialogRec^.UnicodeFileNames, FilesSize - 1);
|
|
||||||
CommDlg_OpenSave_GetSpecW(GetParent(hwnd),
|
|
||||||
PWideChar(DialogRec^.UnicodeFileNames),
|
|
||||||
FilesSize);
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
FolderSize := CommDlg_OpenSave_GetFolderPath(GetParent(hwnd), nil, 0);
|
|
||||||
FilesSize := CommDlg_OpenSave_GetSpec(GetParent(hwnd), nil, 0);
|
|
||||||
SetLength(DialogRec^.AnsiFolderName, FolderSize-1);
|
|
||||||
CommDlg_OpenSave_GetFolderPath(GetParent(hwnd),
|
|
||||||
PChar(DialogRec^.AnsiFolderName),
|
|
||||||
FolderSize);
|
|
||||||
|
|
||||||
SetLength(DialogRec^.AnsiFileNames, FilesSize - 1);
|
|
||||||
CommDlg_OpenSave_GetSpec(GetParent(hwnd),
|
|
||||||
PChar(DialogRec^.AnsiFileNames),
|
|
||||||
FilesSize);
|
|
||||||
end;
|
|
||||||
{$else}
|
|
||||||
FolderSize := CommDlg_OpenSave_GetFolderPath(GetParent(hwnd), nil, 0);
|
|
||||||
FilesSize := CommDlg_OpenSave_GetSpec(GetParent(hwnd), nil, 0);
|
|
||||||
SetLength(DialogRec^.AnsiFolderName, FolderSize-1);
|
|
||||||
CommDlg_OpenSave_GetFolderPath(GetParent(hwnd),
|
|
||||||
PChar(DialogRec^.AnsiFolderName),
|
|
||||||
FolderSize);
|
|
||||||
|
|
||||||
SetLength(DialogRec^.AnsiFileNames, FilesSize - 1);
|
|
||||||
CommDlg_OpenSave_GetSpec(GetParent(hwnd),
|
|
||||||
PChar(DialogRec^.AnsiFileNames),
|
|
||||||
FilesSize);
|
|
||||||
{$endif}
|
|
||||||
UpdateFileProperties(OpenFileName);
|
|
||||||
TOpenDialog(DialogRec^.Dialog).DoSelectionChange;
|
TOpenDialog(DialogRec^.Dialog).DoSelectionChange;
|
||||||
end;
|
CDN_FOLDERCHANGE:
|
||||||
|
TOpenDialog(DialogRec^.Dialog).DoFolderChange;
|
||||||
CDN_TYPECHANGE:
|
CDN_TYPECHANGE:
|
||||||
begin
|
|
||||||
DialogRec^.Dialog.IntfFileTypeChanged(OpenFileNotify^.lpOFN^.nFilterIndex);
|
DialogRec^.Dialog.IntfFileTypeChanged(OpenFileNotify^.lpOFN^.nFilterIndex);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user