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
22 #include "wine/port.h"
34 #include "wine/debug.h"
38 #include "shell32_main.h"
39 #include "undocshell.h"
45 LPCSTR lpstrDirectory
;
47 LPCSTR lpstrDescription
;
51 typedef BOOL (*LPFNOFN
) (OPENFILENAMEA
*) ;
53 WINE_DEFAULT_DEBUG_CHANNEL(shell
);
54 INT_PTR CALLBACK
RunDlgProc (HWND
, UINT
, WPARAM
, LPARAM
) ;
55 void FillList (HWND
, char *) ;
58 /*************************************************************************
59 * PickIconDlg [SHELL32.62]
62 BOOL WINAPI
PickIconDlg(
66 LPDWORD lpdwIconIndex
)
68 FIXME("(%p,%s,%08lx,%p):stub.\n",
69 hwndOwner
, lpstrFile
, nMaxFile
,lpdwIconIndex
);
73 /*************************************************************************
74 * RunFileDlg [SHELL32.61]
77 * Original name: RunFileDlg (exported by ordinal)
79 void WINAPI
RunFileDlg(
82 LPCSTR lpstrDirectory
,
84 LPCSTR lpstrDescription
,
88 RUNFILEDLGPARAMS rfdp
;
93 rfdp
.hwndOwner
= hwndOwner
;
95 rfdp
.lpstrDirectory
= lpstrDirectory
;
96 rfdp
.lpstrTitle
= lpstrTitle
;
97 rfdp
.lpstrDescription
= lpstrDescription
;
100 if(!(hRes
= FindResourceA(shell32_hInstance
, "SHELL_RUN_DLG", (LPSTR
)RT_DIALOG
)))
102 MessageBoxA (hwndOwner
, "Couldn't find dialog.", "Nix", MB_OK
) ;
105 if(!(template = (LPVOID
)LoadResource(shell32_hInstance
, hRes
)))
107 MessageBoxA (hwndOwner
, "Couldn't load dialog.", "Nix", MB_OK
) ;
111 DialogBoxIndirectParamA((HINSTANCE
)GetWindowLongA( hwndOwner
,
113 template, hwndOwner
, RunDlgProc
, (LPARAM
)&rfdp
);
117 /* Dialog procedure for RunFileDlg */
118 INT_PTR CALLBACK
RunDlgProc (HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
121 char *psz
, szMsg
[256] ;
122 static RUNFILEDLGPARAMS
*prfdp
= NULL
;
127 prfdp
= (RUNFILEDLGPARAMS
*)lParam
;
128 SetWindowTextA (hwnd
, prfdp
->lpstrTitle
) ;
129 SetClassLongA (hwnd
, GCL_HICON
, (LPARAM
)prfdp
->hIcon
) ;
130 SendMessageA (GetDlgItem (hwnd
, 12297), STM_SETICON
,
131 (WPARAM
)LoadIconA (NULL
, (LPSTR
)IDI_WINLOGO
), 0);
132 FillList (GetDlgItem (hwnd
, 12298), NULL
) ;
133 SetFocus (GetDlgItem (hwnd
, 12298)) ;
139 PROCESS_INFORMATION pi
;
141 si
.cb
= sizeof (STARTUPINFOA
) ;
142 si
.lpReserved
= NULL
;
143 si
.lpDesktop
= NULL
;
149 si
.dwXCountChars
= 0 ;
150 si
.dwYCountChars
= 0 ;
151 si
.dwFillAttribute
= 0 ;
154 si
.lpReserved2
= NULL
;
156 switch (LOWORD (wParam
))
161 if ((ic
= GetWindowTextLengthA (htxt
= GetDlgItem (hwnd
, 12298))))
163 psz
= malloc (ic
+ 2) ;
164 GetWindowTextA (htxt
, psz
, ic
+ 1) ;
166 if (!CreateProcessA (NULL
, psz
, NULL
, NULL
, TRUE
,
167 NORMAL_PRIORITY_CLASS
, NULL
, NULL
, &si
, &pi
))
169 char *pszSysMsg
= NULL
;
171 FORMAT_MESSAGE_ALLOCATE_BUFFER
|
172 FORMAT_MESSAGE_FROM_SYSTEM
|
173 FORMAT_MESSAGE_IGNORE_INSERTS
,
174 NULL
, GetLastError (),
175 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
176 (LPSTR
)&pszSysMsg
, 0, NULL
178 sprintf (szMsg
, "Error: %s", pszSysMsg
) ;
179 LocalFree ((HLOCAL
)pszSysMsg
) ;
180 MessageBoxA (hwnd
, szMsg
, "Nix", MB_OK
| MB_ICONEXCLAMATION
) ;
183 SendMessageA (htxt
, CB_SETEDITSEL
, 0, MAKELPARAM (0, -1)) ;
186 FillList (htxt
, psz
) ;
188 EndDialog (hwnd
, 0) ;
193 EndDialog (hwnd
, 0) ;
198 HMODULE hComdlg
= NULL
;
199 LPFNOFN ofnProc
= NULL
;
200 static char szFName
[1024] = "", szFileTitle
[256] = "", szInitDir
[768] = "" ;
201 static OPENFILENAMEA ofn
=
203 sizeof (OPENFILENAMEA
),
206 "Executable Files\0*.exe\0All Files\0*.*\0\0\0\0",
216 OFN_ENABLESIZING
| OFN_FILEMUSTEXIST
| OFN_HIDEREADONLY
| OFN_PATHMUSTEXIST
,
225 ofn
.hwndOwner
= hwnd
;
227 if (NULL
== (hComdlg
= LoadLibraryExA ("comdlg32", NULL
, 0)))
229 MessageBoxA (hwnd
, "Unable to display dialog box (LoadLibraryEx) !", "Nix", MB_OK
| MB_ICONEXCLAMATION
) ;
233 if ((LPFNOFN
)NULL
== (ofnProc
= (LPFNOFN
)GetProcAddress (hComdlg
, "GetOpenFileNameA")))
235 MessageBoxA (hwnd
, "Unable to display dialog box (GetProcAddress) !", "Nix", MB_OK
| MB_ICONEXCLAMATION
) ;
241 SetFocus (GetDlgItem (hwnd
, IDOK
)) ;
242 SetWindowTextA (GetDlgItem (hwnd
, 12298), szFName
) ;
243 SendMessageA (GetDlgItem (hwnd
, 12298), CB_SETEDITSEL
, 0, MAKELPARAM (0, -1)) ;
244 SetFocus (GetDlgItem (hwnd
, IDOK
)) ;
246 FreeLibrary (hComdlg
) ;
257 /* This grabs the MRU list from the registry and fills the combo for the "Run" dialog above */
258 void FillList (HWND hCb
, char *pszLatest
)
261 /* char szDbgMsg[256] = "" ; */
262 char *pszList
= NULL
, *pszCmd
= NULL
, cMatch
= 0, cMax
= 0x60, szIndex
[2] = "-" ;
263 DWORD icList
= 0, icCmd
= 0 ;
266 SendMessageA (hCb
, CB_RESETCONTENT
, 0, 0) ;
268 if (ERROR_SUCCESS
!= RegCreateKeyExA (
269 HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU",
270 0, "", REG_OPTION_NON_VOLATILE
, KEY_ALL_ACCESS
, NULL
, &hkey
, NULL
))
271 MessageBoxA (hCb
, "Unable to open registry key !", "Nix", MB_OK
) ;
273 RegQueryValueExA (hkey
, "MRUList", NULL
, NULL
, NULL
, &icList
) ;
277 pszList
= malloc (icList
) ;
278 if (ERROR_SUCCESS
!= RegQueryValueExA (hkey
, "MRUList", NULL
, NULL
, pszList
, &icList
))
279 MessageBoxA (hCb
, "Unable to grab MRUList !", "Nix", MB_OK
) ;
283 pszList
= malloc (icList
= 1) ;
287 for (Nix
= 0 ; Nix
< icList
- 1 ; Nix
++)
289 if (pszList
[Nix
] > cMax
)
290 cMax
= pszList
[Nix
] ;
292 szIndex
[0] = pszList
[Nix
] ;
294 if (ERROR_SUCCESS
!= RegQueryValueExA (hkey
, szIndex
, NULL
, NULL
, NULL
, &icCmd
))
295 MessageBoxA (hCb
, "Unable to grab size of index", "Nix", MB_OK
) ;
296 pszCmd
= realloc (pszCmd
, icCmd
) ;
297 if (ERROR_SUCCESS
!= RegQueryValueExA (hkey
, szIndex
, NULL
, NULL
, pszCmd
, &icCmd
))
298 MessageBoxA (hCb
, "Unable to grab index", "Nix", MB_OK
) ;
300 if (NULL
!= pszLatest
)
302 if (!strcasecmp (pszCmd
, pszLatest
))
305 sprintf (szDbgMsg, "Found existing (%d).\n", Nix) ;
306 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
308 SendMessageA (hCb
, CB_INSERTSTRING
, 0, (LPARAM
)pszCmd
) ;
309 SetWindowTextA (hCb
, pszCmd
) ;
310 SendMessageA (hCb
, CB_SETEDITSEL
, 0, MAKELPARAM (0, -1)) ;
312 cMatch
= pszList
[Nix
] ;
313 memmove (&pszList
[1], pszList
, Nix
) ;
314 pszList
[0] = cMatch
;
319 if (26 != icList
- 1 || icList
- 2 != Nix
|| cMatch
|| NULL
== pszLatest
)
322 sprintf (szDbgMsg, "Happily appending (%d).\n", Nix) ;
323 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
325 SendMessageA (hCb
, CB_ADDSTRING
, 0, (LPARAM
)pszCmd
) ;
328 SetWindowTextA (hCb
, pszCmd
) ;
329 SendMessageA (hCb
, CB_SETEDITSEL
, 0, MAKELPARAM (0, -1)) ;
336 sprintf (szDbgMsg, "Doing loop thing.\n") ;
337 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
339 SendMessageA (hCb
, CB_INSERTSTRING
, 0, (LPARAM
)pszLatest
) ;
340 SetWindowTextA (hCb
, pszLatest
) ;
341 SendMessageA (hCb
, CB_SETEDITSEL
, 0, MAKELPARAM (0, -1)) ;
343 cMatch
= pszList
[Nix
] ;
344 memmove (&pszList
[1], pszList
, Nix
) ;
345 pszList
[0] = cMatch
;
346 szIndex
[0] = cMatch
;
347 RegSetValueExA (hkey
, szIndex
, 0, REG_SZ
, pszLatest
, strlen (pszLatest
) + 1) ;
351 if (!cMatch
&& NULL
!= pszLatest
)
354 sprintf (szDbgMsg, "Simply inserting (increasing list).\n") ;
355 MessageBoxA (hCb, szDbgMsg, "Nix", MB_OK) ;
357 SendMessageA (hCb
, CB_INSERTSTRING
, 0, (LPARAM
)pszLatest
) ;
358 SetWindowTextA (hCb
, pszLatest
) ;
359 SendMessageA (hCb
, CB_SETEDITSEL
, 0, MAKELPARAM (0, -1)) ;
362 pszList
= realloc (pszList
, ++icList
) ;
363 memmove (&pszList
[1], pszList
, icList
- 1) ;
364 pszList
[0] = cMatch
;
365 szIndex
[0] = cMatch
;
366 RegSetValueExA (hkey
, szIndex
, 0, REG_SZ
, pszLatest
, strlen (pszLatest
) + 1) ;
369 RegSetValueExA (hkey
, "MRUList", 0, REG_SZ
, pszList
, strlen (pszList
) + 1) ;
375 /*************************************************************************
376 * ExitWindowsDialog [SHELL32.60]
379 * exported by ordinal
381 void WINAPI
ExitWindowsDialog (HWND hWndOwner
)
383 TRACE("(%p)\n", hWndOwner
);
384 if (MessageBoxA( hWndOwner
, "Do you want to exit WINE?", "Shutdown", MB_YESNO
|MB_ICONQUESTION
) == IDYES
)
386 SendMessageA ( hWndOwner
, WM_QUIT
, 0, 0);