Commit 03242376 authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

shell32: RunFileDlg: the function should be Unicode on NT.

parent 33017b0d
...@@ -43,13 +43,13 @@ typedef struct ...@@ -43,13 +43,13 @@ typedef struct
{ {
HWND hwndOwner ; HWND hwndOwner ;
HICON hIcon ; HICON hIcon ;
LPCSTR lpstrDirectory ; LPCWSTR lpstrDirectory ;
LPCSTR lpstrTitle ; LPCWSTR lpstrTitle ;
LPCSTR lpstrDescription ; LPCWSTR lpstrDescription ;
UINT uFlags ; UINT uFlags ;
} RUNFILEDLGPARAMS ; } RUNFILEDLGPARAMS ;
typedef BOOL (*WINAPI LPFNOFN) (OPENFILENAMEA *) ; typedef BOOL (*WINAPI LPFNOFN) (OPENFILENAMEW *) ;
WINE_DEFAULT_DEBUG_CHANNEL(shell); WINE_DEFAULT_DEBUG_CHANNEL(shell);
static INT_PTR CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM) ; static INT_PTR CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM) ;
...@@ -72,20 +72,22 @@ BOOL WINAPI PickIconDlg( ...@@ -72,20 +72,22 @@ BOOL WINAPI PickIconDlg(
} }
/************************************************************************* /*************************************************************************
* RunFileDlg [SHELL32.61] * RunFileDlgW [internal]
* *
* NOTES * The Unicode function that is available as ordinal 61 on Windows NT/2000/XP/...
* Original name: RunFileDlg (exported by ordinal) *
* SEE ALSO
* RunFileDlgAW
*/ */
void WINAPI RunFileDlg( void WINAPI RunFileDlgW(
HWND hwndOwner, HWND hwndOwner,
HICON hIcon, HICON hIcon,
LPCSTR lpstrDirectory, LPCWSTR lpstrDirectory,
LPCSTR lpstrTitle, LPCWSTR lpstrTitle,
LPCSTR lpstrDescription, LPCWSTR lpstrDescription,
UINT uFlags) UINT uFlags)
{ {
static const WCHAR resnameW[] = {'S','H','E','L','L','_','R','U','N','_','D','L','G',0};
RUNFILEDLGPARAMS rfdp; RUNFILEDLGPARAMS rfdp;
HRSRC hRes; HRSRC hRes;
LPVOID template; LPVOID template;
...@@ -98,7 +100,7 @@ void WINAPI RunFileDlg( ...@@ -98,7 +100,7 @@ void WINAPI RunFileDlg(
rfdp.lpstrDescription = lpstrDescription; rfdp.lpstrDescription = lpstrDescription;
rfdp.uFlags = uFlags; rfdp.uFlags = uFlags;
if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_RUN_DLG", (LPSTR)RT_DIALOG))) if(!(hRes = FindResourceW(shell32_hInstance, resnameW, (LPWSTR)RT_DIALOG)))
{ {
MessageBoxA (hwndOwner, "Couldn't find dialog.", "Nix", MB_OK) ; MessageBoxA (hwndOwner, "Couldn't find dialog.", "Nix", MB_OK) ;
return; return;
...@@ -109,7 +111,7 @@ void WINAPI RunFileDlg( ...@@ -109,7 +111,7 @@ void WINAPI RunFileDlg(
return; return;
} }
DialogBoxIndirectParamA((HINSTANCE)GetWindowLongPtrW( hwndOwner, DialogBoxIndirectParamW((HINSTANCE)GetWindowLongPtrW( hwndOwner,
GWLP_HINSTANCE ), GWLP_HINSTANCE ),
template, hwndOwner, RunDlgProc, (LPARAM)&rfdp); template, hwndOwner, RunDlgProc, (LPARAM)&rfdp);
...@@ -118,15 +120,13 @@ void WINAPI RunFileDlg( ...@@ -118,15 +120,13 @@ void WINAPI RunFileDlg(
/* Dialog procedure for RunFileDlg */ /* Dialog procedure for RunFileDlg */
static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
int ic ;
char *psz, szMsg[256] ;
static RUNFILEDLGPARAMS *prfdp = NULL ; static RUNFILEDLGPARAMS *prfdp = NULL ;
switch (message) switch (message)
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
prfdp = (RUNFILEDLGPARAMS *)lParam ; prfdp = (RUNFILEDLGPARAMS *)lParam ;
SetWindowTextA (hwnd, prfdp->lpstrTitle) ; SetWindowTextW (hwnd, prfdp->lpstrTitle) ;
SetClassLongPtrW (hwnd, GCLP_HICON, (LPARAM)prfdp->hIcon) ; SetClassLongPtrW (hwnd, GCLP_HICON, (LPARAM)prfdp->hIcon) ;
SendMessageW (GetDlgItem (hwnd, 12297), STM_SETICON, SendMessageW (GetDlgItem (hwnd, 12297), STM_SETICON,
(WPARAM)LoadIconW (NULL, (LPCWSTR)IDI_WINLOGO), 0); (WPARAM)LoadIconW (NULL, (LPCWSTR)IDI_WINLOGO), 0);
...@@ -139,15 +139,18 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -139,15 +139,18 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
{ {
case IDOK : case IDOK :
{ {
HWND htxt = NULL ; int ic ;
if ((ic = GetWindowTextLengthA (htxt = GetDlgItem (hwnd, 12298)))) HWND htxt = GetDlgItem (hwnd, 12298); /* edit control */
if ((ic = GetWindowTextLengthW (htxt)))
{ {
psz = HeapAlloc( GetProcessHeap(), 0, (ic + 2) ); WCHAR *psz ;
GetWindowTextA (htxt, psz, ic + 1) ; psz = HeapAlloc( GetProcessHeap(), 0, (ic + 1)*sizeof(WCHAR) );
GetWindowTextW (htxt, psz, ic + 1) ;
if (ShellExecuteA(NULL, "open", psz, NULL, NULL, SW_SHOWNORMAL) < (HINSTANCE)33) if (ShellExecuteW(NULL, NULL, psz, NULL, NULL, SW_SHOWNORMAL) < (HINSTANCE)33)
{ {
char *pszSysMsg = NULL ; char *pszSysMsg = NULL ;
char szMsg[256];
FormatMessageA ( FormatMessageA (
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM |
...@@ -164,7 +167,11 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -164,7 +167,11 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
return TRUE ; return TRUE ;
} }
FillList (htxt, psz) ;
/* FillList is still ANSI */
GetWindowTextA (htxt, (LPSTR)psz, ic + 1) ;
FillList (htxt, (LPSTR)psz) ;
HeapFree(GetProcessHeap(), 0, psz); HeapFree(GetProcessHeap(), 0, psz);
EndDialog (hwnd, 0) ; EndDialog (hwnd, 0) ;
} }
...@@ -178,13 +185,15 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -178,13 +185,15 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
{ {
HMODULE hComdlg = NULL ; HMODULE hComdlg = NULL ;
LPFNOFN ofnProc = NULL ; LPFNOFN ofnProc = NULL ;
char szFName[1024] = "", szFileTitle[256] = "", szInitDir[768] = "" ; WCHAR szFName[1024] = {0}, szFileTitle[256] = {0}, szInitDir[768] = {0} ;
OPENFILENAMEA ofn = WCHAR szFilter[MAX_PATH], szCaption[MAX_PATH];
static const char ansiFilter[] = "Executable Files\0*.exe\0All Files\0*.*\0\0\0\0";
OPENFILENAMEW ofn =
{ {
sizeof (OPENFILENAMEA), sizeof (OPENFILENAMEW),
NULL, NULL,
NULL, NULL,
"Executable Files\0*.exe\0All Files\0*.*\0\0\0\0", szFilter,
NULL, NULL,
0, 0,
0, 0,
...@@ -192,8 +201,8 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -192,8 +201,8 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
1023, 1023,
szFileTitle, szFileTitle,
255, 255,
(LPCSTR)szInitDir, szInitDir,
"Browse", szCaption,
OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
0, 0,
0, 0,
...@@ -203,6 +212,8 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -203,6 +212,8 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
NULL NULL
} ; } ;
MultiByteToWideChar(CP_UTF8, 0, ansiFilter, sizeof(ansiFilter), szFilter, MAX_PATH);
MultiByteToWideChar(CP_UTF8, 0, "Browse", -1, szCaption, MAX_PATH);
ofn.hwndOwner = hwnd ; ofn.hwndOwner = hwnd ;
if (NULL == (hComdlg = LoadLibraryExA ("comdlg32", NULL, 0))) if (NULL == (hComdlg = LoadLibraryExA ("comdlg32", NULL, 0)))
...@@ -211,7 +222,7 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -211,7 +222,7 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
return TRUE ; return TRUE ;
} }
if (NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameA"))) if (NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameW")))
{ {
MessageBoxA (hwnd, "Unable to display dialog box (GetProcAddress) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ; MessageBoxA (hwnd, "Unable to display dialog box (GetProcAddress) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ;
return TRUE ; return TRUE ;
...@@ -220,8 +231,8 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR ...@@ -220,8 +231,8 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
ofnProc (&ofn) ; ofnProc (&ofn) ;
SetFocus (GetDlgItem (hwnd, IDOK)) ; SetFocus (GetDlgItem (hwnd, IDOK)) ;
SetWindowTextA (GetDlgItem (hwnd, 12298), szFName) ; SetWindowTextW (GetDlgItem (hwnd, 12298), szFName) ;
SendMessageA (GetDlgItem (hwnd, 12298), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ; SendMessageW (GetDlgItem (hwnd, 12298), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
SetFocus (GetDlgItem (hwnd, IDOK)) ; SetFocus (GetDlgItem (hwnd, IDOK)) ;
FreeLibrary (hComdlg) ; FreeLibrary (hComdlg) ;
...@@ -359,6 +370,59 @@ static void FillList (HWND hCb, char *pszLatest) ...@@ -359,6 +370,59 @@ static void FillList (HWND hCb, char *pszLatest)
HeapFree( GetProcessHeap(), 0, pszList) ; HeapFree( GetProcessHeap(), 0, pszList) ;
} }
/*************************************************************************
* RunFileDlgA [internal]
*
* The ANSI function that is available as ordinal 61 on Windows 9x/Me
*
* SEE ALSO
* RunFileDlgAW
*/
void WINAPI RunFileDlgA(
HWND hwndOwner,
HICON hIcon,
LPCSTR lpstrDirectory,
LPCSTR lpstrTitle,
LPCSTR lpstrDescription,
UINT uFlags)
{
WCHAR title[MAX_PATH]; /* longer string wouldn't be visible in the dialog anyway */
WCHAR description[MAX_PATH];
WCHAR directory[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, lpstrTitle, -1, title, MAX_PATH);
title[MAX_PATH - 1] = 0;
MultiByteToWideChar(CP_ACP, 0, lpstrDescription, -1, description, MAX_PATH);
description[MAX_PATH - 1] = 0;
if (!MultiByteToWideChar(CP_ACP, 0, lpstrDirectory, -1, directory, MAX_PATH))
directory[0] = 0;
RunFileDlgW(hwndOwner, hIcon, directory, title, description, uFlags);
}
/*************************************************************************
* RunFileDlgAW [SHELL32.61]
*
* An undocumented way to open the Run File dialog. A documented way is to use
* CLSID_Shell, IID_IShellDispatch (as of Wine 1.0, not implemented under Wine)
*
* Exported by ordinal. ANSI on Windows 9x and Unicode on Windows NT/2000/XP/etc
*
*/
void WINAPI RunFileDlgAW(
HWND hwndOwner,
HICON hIcon,
LPCVOID lpstrDirectory,
LPCVOID lpstrTitle,
LPCVOID lpstrDescription,
UINT uFlags)
{
if (SHELL_OsIsUnicode())
RunFileDlgW(hwndOwner, hIcon, lpstrDirectory, lpstrTitle, lpstrDescription, uFlags);
else
RunFileDlgA(hwndOwner, hIcon, lpstrDirectory, lpstrTitle, lpstrDescription, uFlags);
}
/************************************************************************* /*************************************************************************
* ConfirmDialog [internal] * ConfirmDialog [internal]
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
58 stdcall -noname ParseField(str long ptr long) ParseFieldAW 58 stdcall -noname ParseField(str long ptr long) ParseFieldAW
59 stdcall -noname RestartDialog(long wstr long) 59 stdcall -noname RestartDialog(long wstr long)
60 stdcall -noname ExitWindowsDialog(long) 60 stdcall -noname ExitWindowsDialog(long)
61 stdcall -noname RunFileDlg(long long long str str long) 61 stdcall -noname RunFileDlg(long long long str str long) RunFileDlgAW
62 stdcall -noname PickIconDlg(long long long long) 62 stdcall -noname PickIconDlg(long long long long)
63 stdcall -noname GetFileNameFromBrowse(long long long long str str str) 63 stdcall -noname GetFileNameFromBrowse(long long long long str str str)
64 stdcall -noname DriveType(long) 64 stdcall -noname DriveType(long)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment