4 * Copyright 2000 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/debug.h"
30 #include "shell32_main.h"
31 #include "undocshell.h"
37 LPCSTR lpstrDirectory ;
39 LPCSTR lpstrDescription ;
43 typedef BOOL (*LPFNOFN) (OPENFILENAMEA *) ;
45 WINE_DEFAULT_DEBUG_CHANNEL(shell);
46 BOOL CALLBACK RunDlgProc (HWND, UINT, WPARAM, LPARAM) ;
47 void FillList (HWND, char *) ;
50 /*************************************************************************
51 * PickIconDlg [SHELL32.62]
54 BOOL WINAPI PickIconDlg(
58 LPDWORD lpdwIconIndex)
60 FIXME("(%08x,%s,%08lx,%p):stub.\n",
61 hwndOwner, lpstrFile, nMaxFile,lpdwIconIndex);
65 /*************************************************************************
66 * RunFileDlg [SHELL32.61]
69 * Original name: RunFileDlg (exported by ordinal)
71 void WINAPI RunFileDlg(
74 LPCSTR lpstrDirectory,
76 LPCSTR lpstrDescription,
80 RUNFILEDLGPARAMS rfdp = {hwndOwner, hIcon, lpstrDirectory, lpstrTitle, lpstrDescription, uFlags} ;
85 if(!(hRes = FindResourceA(shell32_hInstance, "SHELL_RUN_DLG", RT_DIALOGA)))
87 MessageBoxA (hwndOwner, "Couldn't find dialog.", "Nix", MB_OK) ;
90 if(!(template = (LPVOID)LoadResource(shell32_hInstance, hRes)))
92 MessageBoxA (hwndOwner, "Couldn't load dialog.", "Nix", MB_OK) ;
96 DialogBoxIndirectParamA(GetWindowLongA( hwndOwner, GWL_HINSTANCE ),
97 template, hwndOwner, RunDlgProc, (LPARAM)&rfdp);
101 /* Dialog procedure for RunFileDlg */
102 BOOL CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
105 char *psz, szMsg[256] ;
106 static RUNFILEDLGPARAMS *prfdp = NULL ;
111 prfdp = (RUNFILEDLGPARAMS *)lParam ;
112 SetWindowTextA (hwnd, prfdp->lpstrTitle) ;
113 SetClassLongA (hwnd, GCL_HICON, prfdp->hIcon) ;
114 SendMessageA (GetDlgItem (hwnd, 12297), STM_SETICON, (WPARAM)LoadIconA ((HINSTANCE)NULL, IDI_WINLOGOA), 0) ;
115 FillList (GetDlgItem (hwnd, 12298), NULL) ;
116 SetFocus (GetDlgItem (hwnd, 12298)) ;
122 PROCESS_INFORMATION pi ;
124 si.cb = sizeof (STARTUPINFOA) ;
125 si.lpReserved = NULL ;
126 si.lpDesktop = NULL ;
132 si.dwXCountChars = 0 ;
133 si.dwYCountChars = 0 ;
134 si.dwFillAttribute = 0 ;
137 si.lpReserved2 = NULL ;
139 switch (LOWORD (wParam))
143 HWND htxt = (HWND)NULL ;
144 if ((ic = GetWindowTextLengthA (htxt = GetDlgItem (hwnd, 12298))))
146 psz = malloc (ic + 2) ;
147 GetWindowTextA (htxt, psz, ic + 1) ;
149 if (!CreateProcessA (NULL, psz, NULL, NULL, TRUE,
150 NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
152 char *pszSysMsg = NULL ;
154 FORMAT_MESSAGE_ALLOCATE_BUFFER |
155 FORMAT_MESSAGE_FROM_SYSTEM |
156 FORMAT_MESSAGE_IGNORE_INSERTS,
157 NULL, GetLastError (),
158 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
159 (LPSTR)&pszSysMsg, 0, NULL
161 sprintf (szMsg, "Error: %s", pszSysMsg) ;
162 LocalFree ((HLOCAL)pszSysMsg) ;
163 MessageBoxA (hwnd, szMsg, "Nix", MB_OK | MB_ICONEXCLAMATION) ;
166 SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
169 FillList (htxt, psz) ;
171 EndDialog (hwnd, 0) ;
176 EndDialog (hwnd, 0) ;
181 HMODULE hComdlg = (HMODULE)NULL ;
182 LPFNOFN ofnProc = NULL ;
183 static char szFName[1024] = "", szFileTitle[256] = "", szInitDir[768] = "" ;
184 static OPENFILENAMEA ofn =
186 sizeof (OPENFILENAMEA),
189 "Executable Files\0*.exe\0All Files\0*.*\0\0\0\0",
199 OFN_ENABLESIZING | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
208 ofn.hwndOwner = hwnd ;
210 if ((HMODULE)NULL == (hComdlg = LoadLibraryExA ("comdlg32", (HANDLE)NULL, 0)))
212 MessageBoxA (hwnd, "Unable to display dialog box (LoadLibraryEx) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ;
216 if ((LPFNOFN)NULL == (ofnProc = (LPFNOFN)GetProcAddress (hComdlg, "GetOpenFileNameA")))
218 MessageBoxA (hwnd, "Unable to display dialog box (GetProcAddress) !", "Nix", MB_OK | MB_ICONEXCLAMATION) ;
224 SetFocus (GetDlgItem (hwnd, IDOK)) ;
225 SetWindowTextA (GetDlgItem (hwnd, 12298), szFName) ;
226 SendMessageA (GetDlgItem (hwnd, 12298), CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
227 SetFocus (GetDlgItem (hwnd, IDOK)) ;
229 FreeLibrary (hComdlg) ;
238 /* This should be DefDlgProcA, but that doesn't work */
242 /* This grabs the MRU list from the registry and fills the combo for the "Run" dialog above */
243 void FillList (HWND hCb, char *pszLatest)
246 /* char szDbgMsg[256] = "" ; */
247 char *pszList = NULL, *pszCmd = NULL, cMatch = 0, cMax = 0x60, szIndex[2] = "-" ;
248 DWORD icList = 0, icCmd = 0 ;
251 SendMessageA (hCb, CB_RESETCONTENT, 0, 0) ;
253 if (ERROR_SUCCESS != RegCreateKeyExA (
254 HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
255 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL))
256 MessageBoxA (hCb, "Unable to open registry key !", "Nix", MB_OK) ;
258 if (ERROR_SUCCESS != RegQueryValueExA (hkey, "MRUList", NULL, NULL, NULL, &icList))
259 MessageBoxA (hCb, "Unable to grab size for MRUList !", "Nix", MB_OK) ;
262 pszList = malloc (icList) ;
263 if (ERROR_SUCCESS != RegQueryValueExA (hkey, "MRUList", NULL, NULL, pszList, &icList))
264 MessageBoxA (hCb, "Unable to grab MRUList !", "Nix", MB_OK) ;
268 pszList = malloc (icList = 1) ;
272 for (Nix = 0 ; Nix < icList - 1 ; Nix++)
274 if (pszList[Nix] > cMax)
275 cMax = pszList[Nix] ;
277 szIndex[0] = pszList[Nix] ;
279 if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, NULL, &icCmd))
280 MessageBoxA (hCb, "Unable to grab size of index", "Nix", MB_OK) ;
281 pszCmd = realloc (pszCmd, icCmd) ;
282 if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, pszCmd, &icCmd))
283 MessageBoxA (hCb, "Unable to grab index", "Nix", MB_OK) ;
285 if (NULL != pszLatest)
287 if (!strcasecmp (pszCmd, pszLatest))
290 sprintf (szDbgMsg, "Found existing (%d).\n", Nix) ;
291 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
293 SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszCmd) ;
294 SetWindowTextA (hCb, pszCmd) ;
295 SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
297 cMatch = pszList[Nix] ;
298 memmove (&pszList[1], pszList, Nix) ;
299 pszList[0] = cMatch ;
304 if (26 != icList - 1 || icList - 2 != Nix || cMatch || NULL == pszLatest)
307 sprintf (szDbgMsg, "Happily appending (%d).\n", Nix) ;
308 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
310 SendMessageA (hCb, CB_ADDSTRING, 0, (LPARAM)pszCmd) ;
313 SetWindowTextA (hCb, pszCmd) ;
314 SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
321 sprintf (szDbgMsg, "Doing loop thing.\n") ;
322 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
324 SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest) ;
325 SetWindowTextA (hCb, pszLatest) ;
326 SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
328 cMatch = pszList[Nix] ;
329 memmove (&pszList[1], pszList, Nix) ;
330 pszList[0] = cMatch ;
331 szIndex[0] = cMatch ;
332 RegSetValueExA (hkey, szIndex, 0, REG_SZ, pszLatest, strlen (pszLatest) + 1) ;
336 if (!cMatch && NULL != pszLatest)
339 sprintf (szDbgMsg, "Simply inserting (increasing list).\n") ;
340 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
342 SendMessageA (hCb, CB_INSERTSTRING, 0, (LPARAM)pszLatest) ;
343 SetWindowTextA (hCb, pszLatest) ;
344 SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
347 pszList = realloc (pszList, ++icList) ;
348 memmove (&pszList[1], pszList, icList - 1) ;
349 pszList[0] = cMatch ;
350 szIndex[0] = cMatch ;
351 RegSetValueExA (hkey, szIndex, 0, REG_SZ, pszLatest, strlen (pszLatest) + 1) ;
354 RegSetValueExA (hkey, "MRUList", 0, REG_SZ, pszList, strlen (pszList) + 1) ;
360 /*************************************************************************
361 * ExitWindowsDialog [SHELL32.60]
364 * exported by ordinal
366 void WINAPI ExitWindowsDialog (HWND hWndOwner)
368 TRACE("(0x%08x)\n", hWndOwner);
369 if (MessageBoxA( hWndOwner, "Do you want to exit WINE?", "Shutdown", MB_YESNO|MB_ICONQUESTION) == IDYES)
371 SendMessageA ( hWndOwner, WM_QUIT, 0, 0);