ReactOS 0.4.17-dev-966-gf06eace
filedlg.c
Go to the documentation of this file.
1/*
2 * COMMDLG - File Open Dialogs Win95 look and feel
3 *
4 * Copyright 1999 Francois Boisvert
5 * Copyright 1999, 2000 Juergen Schmied
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 * FIXME: The whole concept of handling unicode is badly broken.
22 * many hook-messages expect a pointer to a
23 * OPENFILENAMEA or W structure. With the current architecture
24 * we would have to convert the beast at every call to a hook.
25 * we have to find a better solution but it would likely cause
26 * a complete rewrite after which we should handle the
27 * OPENFILENAME structure without any converting (jsch).
28 *
29 * FIXME: any hook gets a OPENFILENAMEA structure
30 *
31 * FIXME: CDN_FILEOK is wrong implemented, other CDN_ messages likely too
32 *
33 * FIXME: old style hook messages are not implemented (except FILEOKSTRING)
34 *
35 * FIXME: algorithm for selecting the initial directory is too simple
36 *
37 * FIXME: add to recent docs
38 *
39 * FIXME: flags not implemented: OFN_DONTADDTORECENT,
40 * OFN_NODEREFERENCELINKS, OFN_NOREADONLYRETURN,
41 * OFN_NOTESTFILECREATE, OFN_USEMONIKERS
42 *
43 * FIXME: lCustData for lpfnHook (WM_INITDIALOG)
44 *
45 *
46 */
47
48#include <ctype.h>
49#include <stdlib.h>
50#include <stdarg.h>
51#include <stdio.h>
52#include <string.h>
53
54#define COBJMACROS
55#include "windef.h"
56#include "winbase.h"
57#include "winternl.h"
58#include "winnls.h"
59#include "wingdi.h"
60#ifdef __REACTOS__
61/* RegGetValueW is supported by Win2k3 SP1 but headers need Win Vista */
62#undef _WIN32_WINNT
63#define _WIN32_WINNT 0x0600
64#endif
65#include "winreg.h"
66#include "winuser.h"
67#include "commdlg.h"
68#include "dlgs.h"
69#include "cdlg.h"
70#include "cderr.h"
71#include "shellapi.h"
72#include "shlobj.h"
73#include "filedlgbrowser.h"
74#include "shlwapi.h"
75
76#include "wine/debug.h"
77#include "wine/heap.h"
78#ifdef __REACTOS__
79#include "wine/unicode.h"
82#endif
83
85
86#define UNIMPLEMENTED_FLAGS \
87(OFN_DONTADDTORECENT |\
88OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
89OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/)
90
91/***********************************************************************
92 * Data structure and global variables
93 */
94typedef struct SFolder
95{
96 int m_iImageIndex; /* Index of picture in image list */
98 int m_iIndent; /* Indentation index */
99 LPITEMIDLIST pidlItem; /* absolute pidl of the item */
100
102
103typedef struct tagLookInInfo
104{
108
109#ifdef __REACTOS__
110/* We have to call IShellView::TranslateAccelerator to handle the standard
111 key bindings of File Open Dialog. We use hook to realize them. */
112static HHOOK s_hFileDialogHook = NULL;
113static LONG s_nFileDialogHookCount = 0;
114
115#define MAX_TRANSLATE 8
116static HWND s_ahwndTranslate[MAX_TRANSLATE] = { NULL };
117
118static void FILEDLG95_AddRemoveTranslate(HWND hwndOld, HWND hwndNew)
119{
120 LONG i;
121 for (i = 0; i < MAX_TRANSLATE; ++i)
122 {
123 if (s_ahwndTranslate[i] == hwndOld)
124 {
125 s_ahwndTranslate[i] = hwndNew;
126 break;
127 }
128 }
129}
130
131static __inline BOOL
132FILEDLG95_DoTranslate(LONG i, HWND hwndFocus, LPMSG pMsg)
133{
134 FileOpenDlgInfos *fodInfos;
135 HWND hwndView;
136
137 if (s_ahwndTranslate[i] == NULL)
138 return FALSE;
139
140 fodInfos = get_filedlg_infoptr(s_ahwndTranslate[i]);
141 if (fodInfos == NULL)
142 return FALSE;
143
144 hwndView = fodInfos->ShellInfos.hwndView;
145 if (hwndView == hwndFocus || IsChild(hwndView, hwndFocus))
146 {
147 IShellView_TranslateAccelerator(fodInfos->Shell.FOIShellView, pMsg);
148 return TRUE;
149 }
150 return FALSE;
151}
152
153/* WH_MSGFILTER hook procedure */
154static LRESULT CALLBACK
155FILEDLG95_TranslateMsgProc(INT nCode, WPARAM wParam, LPARAM lParam)
156{
157 LPMSG pMsg;
158
159 if (nCode < 0)
160 return CallNextHookEx(s_hFileDialogHook, nCode, wParam, lParam);
161 if (nCode != MSGF_DIALOGBOX)
162 return 0;
163
164 pMsg = (LPMSG)lParam;
165 if (WM_KEYFIRST <= pMsg->message && pMsg->message <= WM_KEYLAST)
166 {
167 LONG i;
168 HWND hwndFocus = GetFocus();
169 EnterCriticalSection(&COMDLG32_OpenFileLock);
170 for (i = 0; i < MAX_TRANSLATE; ++i)
171 {
172 if (FILEDLG95_DoTranslate(i, hwndFocus, pMsg))
173 break;
174 }
175 LeaveCriticalSection(&COMDLG32_OpenFileLock);
176 }
177
178 return 0;
179}
180#endif
181
182/***********************************************************************
183 * Defines and global variables
184 */
185
186/* Draw item constant */
187#define XTEXTOFFSET 3
188
189/* AddItem flags*/
190#define LISTEND -1
191
192/* SearchItem methods */
193#define SEARCH_PIDL 1
194#define SEARCH_EXP 2
195#define ITEM_NOTFOUND -1
196
197/* Undefined windows message sent by CreateViewObject*/
198#define WM_GETISHELLBROWSER WM_USER+7
199
200#define TBPLACES_CMDID_PLACE0 0xa064
201#define TBPLACES_CMDID_PLACE1 0xa065
202#define TBPLACES_CMDID_PLACE2 0xa066
203#define TBPLACES_CMDID_PLACE3 0xa067
204#define TBPLACES_CMDID_PLACE4 0xa068
205
206/* NOTE
207 * Those macros exist in windowsx.h. However, you can't really use them since
208 * they rely on the UNICODE defines and can't be used inside Wine itself.
209 */
210
211/* Combo box macros */
212#define CBGetItemDataPtr(hwnd,iItemId) \
213 SendMessageW(hwnd, CB_GETITEMDATA, (WPARAM)(iItemId), 0)
214
215static const char LookInInfosStr[] = "LookInInfos"; /* LOOKIN combo box property */
216static SIZE MemDialogSize = { 0, 0}; /* keep size of the (resizable) dialog */
217
219{
220 return GetPropW(hwnd, L"FileOpenDlgInfos");
221}
222
224{
225 return (info->ofnInfos->Flags & OFN_ENABLEHOOK) && info->ofnInfos->lpfnHook;
226}
227
229{
230 return (info->ofnInfos->Flags & OFN_HIDEREADONLY) || (info->DlgInfos.dwDlgProp & FODPROP_SAVEDLG);
231}
232
233/***********************************************************************
234 * Prototypes
235 */
236
237/* Internal functions used by the dialog */
244static void FILEDLG95_Clean(HWND hwnd);
245
246/* Functions used by the shell navigation */
250static void FILEDLG95_SHELL_Clean(HWND hwnd);
251
252/* Functions used by the EDIT box */
253static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed);
254
255/* Functions used by the filetype combo box */
257static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode);
258static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd,LPCWSTR lpstrExt);
260
261/* Functions used by the Look In combo box */
262static void FILEDLG95_LOOKIN_Init(HWND hwndCombo);
264static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode);
265static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId);
266static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod);
270static void FILEDLG95_LOOKIN_Clean(HWND hwnd);
271
272/* Functions for dealing with the most-recently-used registry keys */
273static void FILEDLG95_MRU_load_filename(LPWSTR stored_path);
274static WCHAR FILEDLG95_MRU_get_slot(LPCWSTR module_name, LPWSTR stored_path, PHKEY hkey_ret);
276#ifdef __REACTOS__
277static void FILEDLG95_MRU_load_ext(LPWSTR stored_path, size_t cchMax, LPCWSTR defext);
278static void FILEDLG95_MRU_save_ext(LPCWSTR filename);
279#endif
280
281/* Miscellaneous tool functions */
282static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPWSTR lpstrFileName);
285static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
286static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
287static UINT GetNumSelected( IDataObject *doSelected );
288static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium);
289
292static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
294
296{
298
299 size = sizeof(data);
300 if (hkey && !RegQueryValueExW(hkey, name, 0, &type, (BYTE *)&data, &size))
301 {
302 *value = data;
303 return TRUE;
304 }
305
306 return FALSE;
307}
308
310{
312
313 size = sizeof(data);
314 if (hkey && !RegQueryValueExW(hkey, name, 0, &type, (BYTE *)&data, &size) && type == REG_DWORD)
315 {
316 *value = data;
317 return TRUE;
318 }
319
320 return FALSE;
321}
322
324{
325 DWORD type, size;
326 WCHAR *str;
327
328 if (RegQueryValueExW(hkey, name, 0, &type, NULL, &size))
329 return FALSE;
330 if (type != REG_SZ && type != REG_EXPAND_SZ)
331 return FALSE;
332
334 if (RegQueryValueExW(hkey, name, 0, &type, (BYTE *)str, &size))
335 {
336 heap_free(str);
337 return FALSE;
338 }
339
340 *value = str;
341 return TRUE;
342}
343
345{
346 DWORD value;
347 HKEY hkey;
348
349 if (fodInfos->ofnInfos->lStructSize != sizeof(*fodInfos->ofnInfos) ||
350 (fodInfos->ofnInfos->FlagsEx & OFN_EX_NOPLACESBAR) ||
351 !(fodInfos->ofnInfos->Flags & OFN_EXPLORER))
352 {
353 return FALSE;
354 }
355
356 if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Comdlg32", &hkey))
357 return TRUE;
358
359 value = 0;
360 get_config_key_as_dword(hkey, L"NoPlacesBar", &value);
361 RegCloseKey(hkey);
362 return value == 0;
363}
364
366{
367 static const int default_places[] =
368 {
369#ifdef __REACTOS__
375#else
379#endif
380 };
381 unsigned int i;
382 HKEY hkey;
383
384 if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Comdlg32\\Placesbar",
385 &hkey))
386 {
387 for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
388 {
389 WCHAR nameW[8];
390 DWORD value;
391 HRESULT hr;
392 WCHAR *str;
393
394 swprintf(nameW, ARRAY_SIZE(nameW), L"Place%d", i);
395 if (get_config_key_dword(hkey, nameW, &value))
396 {
398 if (FAILED(hr))
399 WARN("Unrecognized special folder %lu.\n", value);
400 }
401 else if (get_config_key_string(hkey, nameW, &str))
402 {
403 hr = SHParseDisplayName(str, NULL, &fodInfos->places[i], 0, NULL);
404 if (FAILED(hr))
405 WARN("Failed to parse custom places location, %s.\n", debugstr_w(str));
406 heap_free(str);
407 }
408 }
409
410 /* FIXME: eliminate duplicates. */
411
412 RegCloseKey(hkey);
413 return;
414 }
415
416 for (i = 0; i < ARRAY_SIZE(default_places); i++)
417 SHGetSpecialFolderLocation(NULL, default_places[i], &fodInfos->places[i]);
418}
419
420/***********************************************************************
421 * GetFileName95
422 *
423 * Creates an Open common dialog box that lets the user select
424 * the drive, directory, and the name of a file or set of files to open.
425 *
426 * IN : The FileOpenDlgInfos structure associated with the dialog
427 * OUT : TRUE on success
428 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
429 */
431{
432 LRESULT lRes;
433 void *template;
434 HRSRC hRes;
435 HANDLE hDlgTmpl = 0;
436 WORD templateid;
437
438 /* test for missing functionality */
439 if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
440 {
441 FIXME("Flags 0x%08lx not yet implemented\n",
442 fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS);
443 }
444
445 /* Create the dialog from a template */
446
447 if (is_places_bar_enabled(fodInfos))
448 templateid = NEWFILEOPENV2ORD;
449 else
450 templateid = NEWFILEOPENORD;
451
453 {
455 return FALSE;
456 }
457 if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
458 !(template = LockResource( hDlgTmpl )))
459 {
461 return FALSE;
462 }
463
464 /* msdn: explorer style dialogs permit sizing by default.
465 * The OFN_ENABLESIZING flag is only needed when a hook or
466 * custom template is provided */
467 if( (fodInfos->ofnInfos->Flags & OFN_EXPLORER) &&
469 fodInfos->ofnInfos->Flags |= OFN_ENABLESIZING;
470
471 if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
472 {
473 fodInfos->sizedlg.cx = fodInfos->sizedlg.cy = 0;
474 fodInfos->initial_size.x = fodInfos->initial_size.y = 0;
475 }
476
477 /* old style hook messages */
478 if (is_dialog_hooked(fodInfos))
479 {
480 fodInfos->HookMsg.fileokstring = RegisterWindowMessageW(FILEOKSTRINGW);
481 fodInfos->HookMsg.lbselchstring = RegisterWindowMessageW(LBSELCHSTRINGW);
482 fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageW(HELPMSGSTRINGW);
483 fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW);
484 }
485
486 if (fodInfos->unicode)
488 template,
489 fodInfos->ofnInfos->hwndOwner,
491 (LPARAM) fodInfos);
492 else
494 template,
495 fodInfos->ofnInfos->hwndOwner,
497 (LPARAM) fodInfos);
498 if (fodInfos->ole_initialized)
500
501 /* Unable to create the dialog */
502 if( lRes == -1)
503 return FALSE;
504
505 return lRes;
506}
507
508static WCHAR *heap_strdupAtoW(const char *str)
509{
510 WCHAR *ret;
511 INT len;
512
513 if (!str)
514 return NULL;
515
516 len = MultiByteToWideChar(CP_ACP, 0, str, -1, 0, 0);
517 ret = heap_alloc(len * sizeof(WCHAR));
519
520 return ret;
521}
522
524{
526
527 /* Initialize ComboBoxEx32 */
528 icc.dwSize = sizeof(icc);
531
532 /* Initialize CommDlgExtendedError() */
534
535 memset(info, 0, sizeof(*info));
536
537 /* Pass in the original ofn */
538 info->ofnInfos = ofn;
539
540 info->title = ofn->lpstrTitle;
541#ifdef __REACTOS__
542 if (ofn->lpstrDefExt)
543 {
544 INT cchExt = lstrlenW(ofn->lpstrDefExt);
545 LPWSTR pszExt = heap_alloc((cchExt + 1) * sizeof(WCHAR));
546 lstrcpyW(pszExt, ofn->lpstrDefExt);
547 info->defext = pszExt;
548 }
549#else
550 info->defext = ofn->lpstrDefExt;
551#endif
552 info->filter = ofn->lpstrFilter;
553 info->customfilter = ofn->lpstrCustomFilter;
554
555 if (ofn->lpstrFile)
556 {
557 info->filename = heap_alloc(ofn->nMaxFile * sizeof(WCHAR));
558 lstrcpynW(info->filename, ofn->lpstrFile, ofn->nMaxFile);
559 }
560
561 if (ofn->lpstrInitialDir)
562 {
564 if (len)
565 {
566 info->initdir = heap_alloc(len * sizeof(WCHAR));
568 }
569 }
570
571 info->unicode = TRUE;
572}
573
575{
576 OPENFILENAMEW ofnW;
577 int len;
578
579 ofnW = *(OPENFILENAMEW *)ofn;
580
584
585 if (ofn->lpstrFile)
586 {
588 ofnW.lpstrFile = heap_alloc(len * sizeof(WCHAR));
590 ofnW.nMaxFile = len;
591 }
592
593 if (ofn->lpstrFilter)
594 {
595 LPCSTR s;
596 int n;
597
598 /* filter is a list... title\0ext\0......\0\0 */
599 s = ofn->lpstrFilter;
600 while (*s) s = s+strlen(s)+1;
601 s++;
602 n = s - ofn->lpstrFilter;
604 ofnW.lpstrFilter = heap_alloc(len * sizeof(WCHAR));
606 }
607
608 /* convert lpstrCustomFilter */
610 {
611 int n, len;
612 LPCSTR s;
613
614 /* customfilter contains a pair of strings... title\0ext\0 */
616 if (*s) s = s+strlen(s)+1;
617 if (*s) s = s+strlen(s)+1;
620 ofnW.lpstrCustomFilter = heap_alloc(len * sizeof(WCHAR));
622 }
623
624 init_filedlg_infoW(&ofnW, info);
625
626 /* fixup A-specific fields */
627 info->ofnInfos = (OPENFILENAMEW *)ofn;
628 info->unicode = FALSE;
629
630 /* free what was duplicated */
631 heap_free((void *)ofnW.lpstrInitialDir);
632 heap_free(ofnW.lpstrFile);
633}
634
635/***********************************************************************
636 * GetFileDialog95
637 *
638 * Call GetFileName95 with this structure and clean the memory.
639 */
641{
642 WCHAR *current_dir = NULL;
643 unsigned int i;
644 BOOL ret;
645
646 /* save current directory */
647 if (info->ofnInfos->Flags & OFN_NOCHANGEDIR)
648 {
649 current_dir = heap_alloc(MAX_PATH * sizeof(WCHAR));
650 GetCurrentDirectoryW(MAX_PATH, current_dir);
651 }
652
653 switch (dlg_type)
654 {
655 case OPEN_DIALOG:
657 break;
658 case SAVE_DIALOG:
659 info->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
661 break;
662 default:
663 ret = FALSE;
664 }
665
666#ifdef __REACTOS__
667 /* set the lpstrFileTitle */
668 if (ret && info->ofnInfos->lpstrFile && info->ofnInfos->lpstrFileTitle)
669 {
670 if (info->unicode)
671 {
672 LPOPENFILENAMEW ofn = info->ofnInfos;
673 WCHAR *file_title = PathFindFileNameW(ofn->lpstrFile);
675 }
676 else
677 {
679 char *file_title = PathFindFileNameA(ofn->lpstrFile);
681 }
682 }
683#endif
684
685 if (current_dir)
686 {
687 SetCurrentDirectoryW(current_dir);
688 heap_free(current_dir);
689 }
690
691 if (!info->unicode)
692 {
693 heap_free((void *)info->defext);
694 heap_free((void *)info->title);
695 heap_free((void *)info->filter);
696 heap_free((void *)info->customfilter);
697 }
698#ifdef __REACTOS__
699 else
700 {
701 heap_free((void *)info->defext);
702 }
703#endif
704
705 heap_free(info->filename);
706 heap_free(info->initdir);
707
708 for (i = 0; i < ARRAY_SIZE(info->places); i++)
709 ILFree(info->places[i]);
710
711 return ret;
712}
713
714/******************************************************************************
715 * COMDLG32_GetDisplayNameOf [internal]
716 *
717 * Helper function to get the display name for a pidl.
718 */
720 LPSHELLFOLDER psfDesktop;
721 STRRET strret;
722
723 if (FAILED(SHGetDesktopFolder(&psfDesktop)))
724 return FALSE;
725
726 if (FAILED(IShellFolder_GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret))) {
727 IShellFolder_Release(psfDesktop);
728 return FALSE;
729 }
730
731 IShellFolder_Release(psfDesktop);
732 return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH));
733}
734
735/******************************************************************************
736 * COMDLG32_GetCanonicalPath [internal]
737 *
738 * Helper function to get the canonical path.
739 */
741 LPWSTR lpstrFile, LPWSTR lpstrPathAndFile)
742{
743 WCHAR lpstrTemp[MAX_PATH];
744
745 /* Get the current directory name */
746 if (!COMDLG32_GetDisplayNameOf(pidlAbsCurrent, lpstrPathAndFile))
747 {
748 /* last fallback */
749 GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
750 }
751 PathAddBackslashW(lpstrPathAndFile);
752
753 TRACE("current directory=%s, file=%s\n", debugstr_w(lpstrPathAndFile), debugstr_w(lpstrFile));
754
755 /* if the user specified a fully qualified path use it */
756 if(PathIsRelativeW(lpstrFile))
757 {
758 lstrcatW(lpstrPathAndFile, lpstrFile);
759 }
760 else
761 {
762 /* does the path have a drive letter? */
763 if (PathGetDriveNumberW(lpstrFile) == -1)
764 lstrcpyW(lpstrPathAndFile+2, lpstrFile);
765 else
766 lstrcpyW(lpstrPathAndFile, lpstrFile);
767 }
768
769 /* resolve "." and ".." */
770 PathCanonicalizeW(lpstrTemp, lpstrPathAndFile );
771 lstrcpyW(lpstrPathAndFile, lpstrTemp);
772 TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile));
773}
774
775/***********************************************************************
776 * COMDLG32_SplitFileNames [internal]
777 *
778 * Creates a delimited list of filenames.
779 */
780int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed)
781{
782 UINT nStrCharCount = 0; /* index in src buffer */
783 UINT nFileIndex = 0; /* index in dest buffer */
784 UINT nFileCount = 0; /* number of files */
785
786 /* we might get single filename without any '"',
787 * so we need nStrLen + terminating \0 + end-of-list \0 */
788 *lpstrFileList = heap_alloc((nStrLen + 2) * sizeof(WCHAR));
789 *sizeUsed = 0;
790
791 /* build delimited file list from filenames */
792 while ( nStrCharCount <= nStrLen )
793 {
794 if ( lpstrEdit[nStrCharCount]=='"' )
795 {
796 nStrCharCount++;
797 while ((nStrCharCount <= nStrLen) && (lpstrEdit[nStrCharCount]!='"'))
798 {
799 (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
800 nStrCharCount++;
801 }
802 (*lpstrFileList)[nFileIndex++] = 0;
803 nFileCount++;
804 }
805 nStrCharCount++;
806 }
807
808 /* single, unquoted string */
809 if ((nStrLen > 0) && (nFileIndex == 0) )
810 {
811 lstrcpyW(*lpstrFileList, lpstrEdit);
812 nFileIndex = lstrlenW(lpstrEdit) + 1;
813 nFileCount = 1;
814 }
815
816 /* trailing \0 */
817 (*lpstrFileList)[nFileIndex++] = '\0';
818
819 *sizeUsed = nFileIndex;
820 return nFileCount;
821}
822
823/***********************************************************************
824 * ArrangeCtrlPositions [internal]
825 *
826 * NOTE: Make sure to add testcases for any changes made here.
827 */
828static void ArrangeCtrlPositions(HWND hwndChildDlg, HWND hwndParentDlg, BOOL hide_help)
829{
830 HWND hwndChild, hwndStc32;
831 RECT rectParent, rectChild, rectStc32;
832 INT help_fixup = 0;
833 int chgx, chgy;
834
835 /* Take into account if open as read only checkbox and help button
836 * are hidden
837 */
838 if (hide_help)
839 {
840 RECT rectHelp, rectCancel;
841 GetWindowRect(GetDlgItem(hwndParentDlg, pshHelp), &rectHelp);
842 GetWindowRect(GetDlgItem(hwndParentDlg, IDCANCEL), &rectCancel);
843 /* subtract the height of the help button plus the space between
844 * the help button and the cancel button to the height of the dialog
845 */
846 help_fixup = rectHelp.bottom - rectCancel.bottom;
847 }
848
849 /*
850 There are two possibilities to add components to the default file dialog box.
851
852 By default, all the new components are added below the standard dialog box (the else case).
853
854 However, if there is a static text component with the stc32 id, a special case happens.
855 The x and y coordinates of stc32 indicate the top left corner where to place the standard file dialog box
856 in the window and the cx and cy indicate how to size the window.
857 Moreover, if the new component's coordinates are on the left of the stc32 , it is placed on the left
858 of the standard file dialog box. If they are above the stc32 component, it is placed above and so on....
859
860 */
861
862 GetClientRect(hwndParentDlg, &rectParent);
863
864 /* when arranging controls we have to use fixed parent size */
865 rectParent.bottom -= help_fixup;
866
867 hwndStc32 = GetDlgItem(hwndChildDlg, stc32);
868 if (hwndStc32)
869 {
870 GetWindowRect(hwndStc32, &rectStc32);
871 MapWindowPoints(0, hwndChildDlg, (LPPOINT)&rectStc32, 2);
872
873 /* set the size of the stc32 control according to the size of
874 * client area of the parent dialog
875 */
876 SetWindowPos(hwndStc32, 0,
877 0, 0,
878 rectParent.right, rectParent.bottom,
880 }
881 else
882 SetRectEmpty(&rectStc32);
883
884 /* this part moves controls of the child dialog */
885 hwndChild = GetWindow(hwndChildDlg, GW_CHILD);
886 while (hwndChild)
887 {
888 if (hwndChild != hwndStc32)
889 {
890 GetWindowRect(hwndChild, &rectChild);
891 MapWindowPoints(0, hwndChildDlg, (LPPOINT)&rectChild, 2);
892
893 /* move only if stc32 exist */
894 if (hwndStc32 && rectChild.left > rectStc32.right)
895 {
896 /* move to the right of visible controls of the parent dialog */
897 rectChild.left += rectParent.right;
898 rectChild.left -= rectStc32.right;
899 }
900 /* move even if stc32 doesn't exist */
901 if (rectChild.top >= rectStc32.bottom)
902 {
903 /* move below visible controls of the parent dialog */
904 rectChild.top += rectParent.bottom;
905 rectChild.top -= rectStc32.bottom - rectStc32.top;
906 }
907
908 SetWindowPos(hwndChild, 0, rectChild.left, rectChild.top,
909 0, 0, SWP_NOSIZE | SWP_NOZORDER);
910 }
911 hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
912 }
913
914 /* this part moves controls of the parent dialog */
915 hwndChild = GetWindow(hwndParentDlg, GW_CHILD);
916 while (hwndChild)
917 {
918 if (hwndChild != hwndChildDlg)
919 {
920 GetWindowRect(hwndChild, &rectChild);
921 MapWindowPoints(0, hwndParentDlg, (LPPOINT)&rectChild, 2);
922
923 /* left,top of stc32 marks the position of controls
924 * from the parent dialog
925 */
926 rectChild.left += rectStc32.left;
927 rectChild.top += rectStc32.top;
928
929 SetWindowPos(hwndChild, 0, rectChild.left, rectChild.top,
930 0, 0, SWP_NOSIZE | SWP_NOZORDER);
931 }
932 hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
933 }
934
935 /* calculate the size of the resulting dialog */
936
937 /* here we have to use original parent size */
938 GetClientRect(hwndParentDlg, &rectParent);
939 GetClientRect(hwndChildDlg, &rectChild);
940 TRACE( "parent %s child %s stc32 %s\n", wine_dbgstr_rect( &rectParent),
941 wine_dbgstr_rect( &rectChild), wine_dbgstr_rect( &rectStc32));
942
943 if (hwndStc32)
944 {
945 /* width */
946 if (rectParent.right > rectStc32.right - rectStc32.left)
947 chgx = rectChild.right - ( rectStc32.right - rectStc32.left);
948 else
949 chgx = rectChild.right - rectParent.right;
950 /* height */
951 if (rectParent.bottom > rectStc32.bottom - rectStc32.top)
952 chgy = rectChild.bottom - ( rectStc32.bottom - rectStc32.top) - help_fixup;
953 else
954 /* Unconditionally set new dialog
955 * height to that of the child
956 */
957 chgy = rectChild.bottom - rectParent.bottom;
958 }
959 else
960 {
961 chgx = 0;
962 chgy = rectChild.bottom - help_fixup;
963 }
964 /* set the size of the parent dialog */
965 GetWindowRect(hwndParentDlg, &rectParent);
966 SetWindowPos(hwndParentDlg, 0,
967 0, 0,
968 rectParent.right - rectParent.left + chgx,
969 rectParent.bottom - rectParent.top + chgy,
971}
972
974{
975 switch(uMsg) {
976 case WM_INITDIALOG:
977 return TRUE;
978 }
979 return FALSE;
980}
981
983{
984 LPCVOID template;
985 HRSRC hRes;
986 HANDLE hDlgTmpl = 0;
987 HWND hChildDlg = 0;
988
989 TRACE("%p, %p\n", fodInfos, hwnd);
990
991 /*
992 * If OFN_ENABLETEMPLATEHANDLE is specified, the OPENFILENAME
993 * structure's hInstance parameter is not a HINSTANCE, but
994 * instead a pointer to a template resource to use.
995 */
997 {
999 if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
1000 {
1002 if( !(template = LockResource( fodInfos->ofnInfos->hInstance)))
1003 {
1005 return NULL;
1006 }
1007 }
1008 else
1009 {
1010 hinst = fodInfos->ofnInfos->hInstance;
1011 if(fodInfos->unicode)
1012 {
1013 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
1015 }
1016 else
1017 {
1020 }
1021 if (!hRes)
1022 {
1024 return NULL;
1025 }
1026 if (!(hDlgTmpl = LoadResource( hinst, hRes )) ||
1027 !(template = LockResource( hDlgTmpl )))
1028 {
1030 return NULL;
1031 }
1032 }
1033 if (fodInfos->unicode)
1034 hChildDlg = CreateDialogIndirectParamW(hinst, template, hwnd,
1036 (LPARAM)fodInfos->ofnInfos);
1037 else
1038 hChildDlg = CreateDialogIndirectParamA(hinst, template, hwnd,
1040 (LPARAM)fodInfos->ofnInfos);
1041 return hChildDlg;
1042 }
1043 else if (is_dialog_hooked(fodInfos))
1044 {
1045 RECT rectHwnd;
1046 struct {
1047 DLGTEMPLATE tmplate;
1048 WORD menu,class,title;
1049 } temp;
1050 GetClientRect(hwnd,&rectHwnd);
1052 temp.tmplate.dwExtendedStyle = 0;
1053 temp.tmplate.cdit = 0;
1054 temp.tmplate.x = 0;
1055 temp.tmplate.y = 0;
1056 temp.tmplate.cx = 0;
1057 temp.tmplate.cy = 0;
1058 temp.menu = temp.class = temp.title = 0;
1059
1061 hwnd, (DLGPROC)fodInfos->ofnInfos->lpfnHook, (LPARAM)fodInfos->ofnInfos);
1062
1063 return hChildDlg;
1064 }
1065 return NULL;
1066}
1067
1068/***********************************************************************
1069* SendCustomDlgNotificationMessage
1070*
1071* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
1072*/
1073
1075{
1076 FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwndParentDlg);
1077 LRESULT hook_result;
1078 OFNOTIFYW ofnNotify;
1079
1080 TRACE("%p %d\n", hwndParentDlg, uCode);
1081
1082 if (!fodInfos || !fodInfos->DlgInfos.hwndCustomDlg)
1083 return 0;
1084
1085 TRACE("CALL NOTIFY for %d\n", uCode);
1086
1087 ofnNotify.hdr.hwndFrom = hwndParentDlg;
1088 ofnNotify.hdr.idFrom = 0;
1089 ofnNotify.hdr.code = uCode;
1090 ofnNotify.lpOFN = fodInfos->ofnInfos;
1091 ofnNotify.pszFile = NULL;
1092
1093 if (fodInfos->unicode)
1094 hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
1095 else
1096 hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg, WM_NOTIFY, 0, (LPARAM)&ofnNotify);
1097
1098 TRACE("RET NOTIFY retval %#Ix\n", hook_result);
1099
1100 return hook_result;
1101}
1102
1104{
1105 UINT len, total;
1106 WCHAR *p, *buffer;
1108
1109 TRACE("CDM_GETFILEPATH:\n");
1110
1111 if ( ! (fodInfos->ofnInfos->Flags & OFN_EXPLORER ) )
1112 return -1;
1113
1114 /* get path and filenames */
1115 len = SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0 );
1116 buffer = heap_alloc( (len + 2 + MAX_PATH) * sizeof(WCHAR) );
1117 COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, buffer );
1118 if (len)
1119 {
1120 p = buffer + lstrlenW(buffer);
1121 *p++ = '\\';
1122 SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, len + 1, (LPARAM)p );
1123 }
1124 if (fodInfos->unicode)
1125 {
1126 total = lstrlenW( buffer) + 1;
1127 if (result) lstrcpynW( result, buffer, size );
1128 TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_w(result));
1129 }
1130 else
1131 {
1132 total = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
1134 TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_a(result));
1135 }
1136 heap_free( buffer );
1137 return total;
1138}
1139
1140/***********************************************************************
1141* FILEDLG95_HandleCustomDialogMessages
1142*
1143* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages
1144*/
1146{
1148 WCHAR lpstrPath[MAX_PATH];
1150
1151 if(!fodInfos) return FALSE;
1152
1153 switch(uMsg)
1154 {
1155 case CDM_GETFILEPATH:
1157 break;
1158
1159 case CDM_GETFOLDERPATH:
1160 TRACE("CDM_GETFOLDERPATH:\n");
1161 COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);
1162 if (lParam)
1163 {
1164 if (fodInfos->unicode)
1165 lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
1166 else
1167 WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
1168 (LPSTR)lParam, (int)wParam, NULL, NULL);
1169 }
1170 retval = lstrlenW(lpstrPath) + 1;
1171 break;
1172
1174 retval = ILGetSize(fodInfos->ShellInfos.pidlAbsCurrent);
1175 if (retval <= wParam)
1176 memcpy((void*)lParam, fodInfos->ShellInfos.pidlAbsCurrent, retval);
1177 break;
1178
1179 case CDM_GETSPEC:
1180 TRACE("CDM_GETSPEC:\n");
1181 retval = SendMessageW(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0) + 1;
1182 if (lParam)
1183 {
1184 if (fodInfos->unicode)
1185 SendMessageW(fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, wParam, lParam);
1186 else
1187 SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, wParam, lParam);
1188 }
1189 break;
1190
1191 case CDM_SETCONTROLTEXT:
1192 TRACE("CDM_SETCONTROLTEXT:\n");
1193 if ( lParam )
1194 {
1195 if( fodInfos->unicode )
1197 else
1199 }
1200 retval = TRUE;
1201 break;
1202
1203 case CDM_HIDECONTROL:
1204 /* MSDN states that it should fail for not OFN_EXPLORER case */
1205 if (fodInfos->ofnInfos->Flags & OFN_EXPLORER)
1206 {
1209 retval = TRUE;
1210 }
1211 else retval = FALSE;
1212 break;
1213
1214#ifdef __REACTOS__
1215 case CDM_SETDEFEXT:
1216 {
1217 LPWSTR olddefext = (LPWSTR)fodInfos->defext;
1218 fodInfos->defext = NULL;
1219
1220 if (fodInfos->unicode)
1221 {
1222 LPCWSTR pszExt = (LPCWSTR)lParam;
1223 if (pszExt)
1224 {
1225 INT cchExt = lstrlenW(pszExt);
1226 fodInfos->defext = heap_alloc((cchExt + 1) * sizeof(WCHAR));
1227 lstrcpyW((LPWSTR)fodInfos->defext, pszExt);
1228 }
1229 }
1230 else
1231 {
1232 LPCSTR pszExt = (LPCSTR)lParam;
1233 if (pszExt)
1234 fodInfos->defext = heap_strdupAtoW(pszExt);
1235 }
1236
1237 heap_free(olddefext);
1238 break;
1239 }
1240#endif
1241
1242 default:
1243 if (uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
1244 FIXME("message CDM_FIRST+%04x not implemented\n", uMsg - CDM_FIRST);
1245 return FALSE;
1246 }
1248 return TRUE;
1249}
1250
1251/***********************************************************************
1252 * FILEDLG95_OnWMGetMMI
1253 *
1254 * WM_GETMINMAXINFO message handler for resizable dialogs
1255 */
1257{
1259 if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
1260 if( fodInfos->initial_size.x || fodInfos->initial_size.y)
1261 {
1262 mmiptr->ptMinTrackSize = fodInfos->initial_size;
1263 }
1264 return TRUE;
1265}
1266
1267/***********************************************************************
1268 * FILEDLG95_OnWMSize
1269 *
1270 * WM_SIZE message handler, resize the dialog. Re-arrange controls.
1271 *
1272 * FIXME: this could be made more elaborate. Now use a simple scheme
1273 * where the file view is enlarged and the controls are either moved
1274 * vertically or horizontally to get out of the way. Only the "grip"
1275 * is moved in both directions to stay in the corner.
1276 */
1278{
1279 RECT rc, rcview;
1280 int chgx, chgy;
1281 HWND ctrl;
1282 HDWP hdwp;
1283 FileOpenDlgInfos *fodInfos;
1284
1285 if( wParam != SIZE_RESTORED) return FALSE;
1286 fodInfos = get_filedlg_infoptr(hwnd);
1287 if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
1288 /* get the new dialog rectangle */
1289 GetWindowRect( hwnd, &rc);
1290 TRACE("%p, size from %ld,%ld to %ld,%ld\n", hwnd, fodInfos->sizedlg.cx, fodInfos->sizedlg.cy,
1291 rc.right -rc.left, rc.bottom -rc.top);
1292 /* not initialized yet */
1293 if( (fodInfos->sizedlg.cx == 0 && fodInfos->sizedlg.cy == 0) ||
1294 ((fodInfos->sizedlg.cx == rc.right -rc.left) && /* no change */
1295 (fodInfos->sizedlg.cy == rc.bottom -rc.top)))
1296 return FALSE;
1297 chgx = rc.right - rc.left - fodInfos->sizedlg.cx;
1298 chgy = rc.bottom - rc.top - fodInfos->sizedlg.cy;
1299 fodInfos->sizedlg.cx = rc.right - rc.left;
1300 fodInfos->sizedlg.cy = rc.bottom - rc.top;
1301 /* change the size of the view window */
1302 GetWindowRect( fodInfos->ShellInfos.hwndView, &rcview);
1303 MapWindowPoints( NULL, hwnd, (LPPOINT) &rcview, 2);
1304 hdwp = BeginDeferWindowPos( 10);
1305 DeferWindowPos( hdwp, fodInfos->ShellInfos.hwndView, NULL, 0, 0,
1306 rcview.right - rcview.left + chgx,
1307 rcview.bottom - rcview.top + chgy,
1309 /* change position and sizes of the controls */
1311 {
1312 int ctrlid = GetDlgCtrlID( ctrl);
1313 GetWindowRect( ctrl, &rc);
1314 MapWindowPoints( NULL, hwnd, (LPPOINT) &rc, 2);
1315 if( ctrl == fodInfos->DlgInfos.hwndGrip)
1316 {
1317 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top + chgy,
1318 0, 0,
1320 }
1321 else if( rc.top > rcview.bottom)
1322 {
1323 /* if it was below the shell view
1324 * move to bottom */
1325 switch( ctrlid)
1326 {
1327 /* file name (edit or comboboxex) and file types combo change also width */
1328 case edt1:
1329 case cmb13:
1330 case cmb1:
1331 DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
1332 rc.right - rc.left + chgx, rc.bottom - rc.top,
1334 break;
1335 /* then these buttons must move out of the way */
1336 case IDOK:
1337 case IDCANCEL:
1338 case pshHelp:
1339 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top + chgy,
1340 0, 0,
1342 break;
1343 default:
1344 DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
1345 0, 0,
1347 }
1348 }
1349 else if( rc.left > rcview.right)
1350 {
1351 /* if it was to the right of the shell view
1352 * move to right */
1353 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
1354 0, 0,
1356 }
1357 else
1358 /* special cases */
1359 {
1360 switch( ctrlid)
1361 {
1362#if 0 /* this is Win2k, Win XP. Vista and Higher don't move/size these controls */
1363 case IDC_LOOKIN:
1364 DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
1365 rc.right - rc.left + chgx, rc.bottom - rc.top,
1367 break;
1368 case IDC_TOOLBARSTATIC:
1369 case IDC_TOOLBAR:
1370 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
1371 0, 0,
1373 break;
1374#endif
1375 /* not resized in windows. Since wine uses this invisible control
1376 * to size the browser view it needs to be resized */
1377 case IDC_SHELLSTATIC:
1378 DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
1379 rc.right - rc.left + chgx,
1380 rc.bottom - rc.top + chgy,
1382 break;
1383 case IDC_TOOLBARPLACES:
1384 DeferWindowPos( hdwp, ctrl, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top + chgy,
1386 break;
1387 }
1388 }
1389 }
1390 if(fodInfos->DlgInfos.hwndCustomDlg &&
1392 {
1393 for( ctrl = GetWindow( fodInfos->DlgInfos.hwndCustomDlg, GW_CHILD);
1395 {
1396 GetWindowRect( ctrl, &rc);
1397 MapWindowPoints( NULL, hwnd, (LPPOINT) &rc, 2);
1398 if( rc.top > rcview.bottom)
1399 {
1400 /* if it was below the shell view
1401 * move to bottom */
1402 DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
1403 rc.right - rc.left, rc.bottom - rc.top,
1405 }
1406 else if( rc.left > rcview.right)
1407 {
1408 /* if it was to the right of the shell view
1409 * move to right */
1410 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
1411 rc.right - rc.left, rc.bottom - rc.top,
1413 }
1414 }
1415 /* size the custom dialog at the end: some applications do some
1416 * control re-arranging at this point */
1417 GetClientRect(hwnd, &rc);
1418 DeferWindowPos( hdwp,fodInfos->DlgInfos.hwndCustomDlg, NULL,
1420 }
1421 EndDeferWindowPos( hdwp);
1422 /* should not be needed */
1424 return TRUE;
1425}
1426
1427/***********************************************************************
1428 * FileOpenDlgProc95
1429 *
1430 * File open dialog procedure
1431 */
1433{
1434#if 0
1435 TRACE("%p 0x%04x\n", hwnd, uMsg);
1436#endif
1437
1438 switch(uMsg)
1439 {
1440 case WM_INITDIALOG:
1441 {
1443 RECT rc, rcstc;
1444 int gripx = GetSystemMetrics( SM_CYHSCROLL);
1445 int gripy = GetSystemMetrics( SM_CYVSCROLL);
1446
1447 /* Some shell namespace extensions depend on COM being initialized. */
1449 fodInfos->ole_initialized = TRUE;
1450
1451 SetPropW(hwnd, L"FileOpenDlgInfos", fodInfos);
1452
1454
1455 if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
1456 {
1458 DWORD ex_style = GetWindowLongW(hwnd, GWL_EXSTYLE);
1459 RECT client, client_adjusted;
1460
1461 if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
1462 {
1463 style |= WS_SIZEBOX;
1464 ex_style |= WS_EX_WINDOWEDGE;
1465 }
1466 else
1467 style &= ~WS_SIZEBOX;
1469 SetWindowLongW(hwnd, GWL_EXSTYLE, ex_style);
1470
1472 GetClientRect( hwnd, &client_adjusted );
1473 AdjustWindowRectEx( &client_adjusted, style, FALSE, ex_style );
1474
1475 GetWindowRect( hwnd, &rc );
1476 rc.right += client_adjusted.right - client.right;
1477 rc.bottom += client_adjusted.bottom - client.bottom;
1478 SetWindowPos(hwnd, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED | SWP_NOACTIVATE |
1480
1481 GetWindowRect( hwnd, &rc );
1482 fodInfos->DlgInfos.hwndGrip =
1483 CreateWindowExA( 0, "SCROLLBAR", NULL,
1486 rc.right - gripx, rc.bottom - gripy,
1487 gripx, gripy, hwnd, (HMENU) -1, COMDLG32_hInstance, NULL);
1488 }
1489
1490 fodInfos->DlgInfos.hwndCustomDlg =
1492
1495
1496 if( fodInfos->DlgInfos.hwndCustomDlg)
1497 ShowWindow( fodInfos->DlgInfos.hwndCustomDlg, SW_SHOW);
1498
1499 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER) {
1502 }
1503
1504 /* if the app has changed the position of the invisible listbox,
1505 * change that of the listview (browser) as well */
1506 GetWindowRect( fodInfos->ShellInfos.hwndView, &rc);
1508 if( !EqualRect( &rc, &rcstc))
1509 {
1510 MapWindowPoints( NULL, hwnd, (LPPOINT) &rcstc, 2);
1511 SetWindowPos( fodInfos->ShellInfos.hwndView, NULL,
1512 rcstc.left, rcstc.top, rcstc.right - rcstc.left, rcstc.bottom - rcstc.top,
1514 }
1515
1516 if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
1517 {
1518 GetWindowRect( hwnd, &rc);
1519 fodInfos->sizedlg.cx = rc.right - rc.left;
1520 fodInfos->sizedlg.cy = rc.bottom - rc.top;
1521 fodInfos->initial_size.x = fodInfos->sizedlg.cx;
1522 fodInfos->initial_size.y = fodInfos->sizedlg.cy;
1523 GetClientRect( hwnd, &rc);
1524 SetWindowPos( fodInfos->DlgInfos.hwndGrip, NULL,
1525 rc.right - gripx, rc.bottom - gripy,
1527 /* resize the dialog to the previous invocation */
1532 }
1533
1534 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
1536
1537#ifdef __REACTOS__
1538 /* Enable hook and translate */
1539 EnterCriticalSection(&COMDLG32_OpenFileLock);
1540 if (++s_nFileDialogHookCount == 1)
1541 {
1542 s_hFileDialogHook = SetWindowsHookEx(WH_MSGFILTER, FILEDLG95_TranslateMsgProc,
1543 0, GetCurrentThreadId());
1544 }
1545 FILEDLG95_AddRemoveTranslate(NULL, hwnd);
1546 LeaveCriticalSection(&COMDLG32_OpenFileLock);
1547#endif
1548 return 0;
1549 }
1550 case WM_SIZE:
1552 case WM_GETMINMAXINFO:
1554 case WM_COMMAND:
1556 case WM_DRAWITEM:
1557 {
1558 switch(((LPDRAWITEMSTRUCT)lParam)->CtlID)
1559 {
1560 case IDC_LOOKIN:
1562 return TRUE;
1563 }
1564 }
1565 return FALSE;
1566
1569
1570 case WM_DESTROY:
1571 {
1573 HWND places_bar = GetDlgItem(hwnd, IDC_TOOLBARPLACES);
1575
1576 if (fodInfos && fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
1577 MemDialogSize = fodInfos->sizedlg;
1578
1579 if (places_bar)
1580 {
1584 }
1585#ifdef __REACTOS__
1586 /* Disable hook and translate */
1587 EnterCriticalSection(&COMDLG32_OpenFileLock);
1588 FILEDLG95_AddRemoveTranslate(hwnd, NULL);
1589 if (--s_nFileDialogHookCount == 0)
1590 {
1591 UnhookWindowsHookEx(s_hFileDialogHook);
1592 s_hFileDialogHook = NULL;
1593 }
1594 LeaveCriticalSection(&COMDLG32_OpenFileLock);
1596#endif
1597 return FALSE;
1598 }
1599
1600 case WM_NCDESTROY:
1601 RemovePropW(hwnd, L"FileOpenDlgInfos");
1602 return 0;
1603
1604 case WM_NOTIFY:
1605 {
1606 LPNMHDR lpnmh = (LPNMHDR)lParam;
1607 UINT stringId = -1;
1608
1609 /* set up the button tooltips strings */
1610 if(TTN_GETDISPINFOA == lpnmh->code )
1611 {
1613 switch(lpnmh->idFrom )
1614 {
1615 /* Up folder button */
1616 case FCIDM_TB_UPFOLDER:
1617 stringId = IDS_UPFOLDER;
1618 break;
1619 /* New folder button */
1620 case FCIDM_TB_NEWFOLDER:
1621 stringId = IDS_NEWFOLDER;
1622 break;
1623 /* List option button */
1624 case FCIDM_TB_SMALLICON:
1625 stringId = IDS_LISTVIEW;
1626 break;
1627 /* Details option button */
1629 stringId = IDS_REPORTVIEW;
1630 break;
1631 /* Desktop button */
1632 case FCIDM_TB_DESKTOP:
1633 stringId = IDS_TODESKTOP;
1634 break;
1635 default:
1636 stringId = 0;
1637 }
1638 lpdi->hinst = COMDLG32_hInstance;
1639 lpdi->lpszText = MAKEINTRESOURCEA(stringId);
1640 }
1641 return FALSE;
1642 }
1643 default :
1644 if(uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
1646 return FALSE;
1647 }
1648}
1649
1651{
1652 return (info->ofnInfos->lStructSize == OPENFILENAME_SIZE_VERSION_400W) &&
1654}
1655
1656/***********************************************************************
1657 * FILEDLG95_InitControls
1658 *
1659 * WM_INITDIALOG message handler (before hook notification)
1660 */
1662{
1663 BOOL win2000plus = FALSE;
1664 BOOL win98plus = FALSE;
1665 BOOL handledPath = FALSE;
1666 OSVERSIONINFOW osVi;
1667
1668 static const TBBUTTON tbb[] =
1669 {
1670 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1672 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1674 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1676 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1679 };
1680 static const TBADDBITMAP tba = {HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR};
1681
1682 RECT rectTB;
1683 RECT rectlook;
1684
1685 HIMAGELIST toolbarImageList;
1686 ITEMIDLIST *desktopPidl;
1688
1690
1691 TRACE("%p\n", fodInfos);
1692
1693 /* Get windows version emulating */
1694 osVi.dwOSVersionInfoSize = sizeof(osVi);
1695 GetVersionExW(&osVi);
1697 win98plus = ((osVi.dwMajorVersion > 4) || ((osVi.dwMajorVersion == 4) && (osVi.dwMinorVersion > 0)));
1698 } else if (osVi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
1699 win2000plus = (osVi.dwMajorVersion > 4);
1700 if (win2000plus) win98plus = TRUE;
1701 }
1702 TRACE("Running on 2000+ %d, 98+ %d\n", win2000plus, win98plus);
1703
1704
1705 /* Use either the edit or the comboboxex for the filename control */
1706 if (filename_is_edit( fodInfos ))
1707 {
1709 fodInfos->DlgInfos.hwndFileName = GetDlgItem( hwnd, edt1 );
1710 }
1711 else
1712 {
1714 fodInfos->DlgInfos.hwndFileName = GetDlgItem( hwnd, cmb13 );
1715 }
1716
1717 /* Get the hwnd of the controls */
1718 fodInfos->DlgInfos.hwndFileTypeCB = GetDlgItem(hwnd,IDC_FILETYPE);
1719 fodInfos->DlgInfos.hwndLookInCB = GetDlgItem(hwnd,IDC_LOOKIN);
1720
1721 GetWindowRect( fodInfos->DlgInfos.hwndLookInCB,&rectlook);
1722 MapWindowPoints( 0, hwnd,(LPPOINT)&rectlook,2);
1723
1724 /* construct the toolbar */
1726 MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
1727
1728 rectTB.right = rectlook.right + rectTB.right - rectTB.left;
1729 rectTB.bottom = rectlook.top - 1 + rectTB.bottom - rectTB.top;
1730 rectTB.left = rectlook.right;
1731 rectTB.top = rectlook.top-1;
1732
1733 if (fodInfos->unicode)
1734 fodInfos->DlgInfos.hwndTB = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
1736 rectTB.left, rectTB.top,
1737 rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
1739 else
1740 fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL,
1742 rectTB.left, rectTB.top,
1743 rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
1745
1746 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
1747
1748/* FIXME: use TB_LOADIMAGES when implemented */
1749/* SendMessageW(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
1750 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_SETMAXTEXTROWS, 0, 0);
1751 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, 12, (LPARAM) &tba);
1752
1753 /* Retrieve and add desktop icon to the toolbar */
1754 toolbarImageList = (HIMAGELIST)SendMessageW(fodInfos->DlgInfos.hwndTB, TB_GETIMAGELIST, 0, 0L);
1756 SHGetFileInfoW((const WCHAR *)desktopPidl, 0, &fileinfo, sizeof(fileinfo),
1758 ImageList_AddIcon(toolbarImageList, fileinfo.hIcon);
1759
1760 DestroyIcon(fileinfo.hIcon);
1761 CoTaskMemFree(desktopPidl);
1762
1763 /* Finish Toolbar Construction */
1764 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSW, 9, (LPARAM) tbb);
1765 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
1766
1767 if (is_places_bar_enabled(fodInfos))
1768 {
1769 TBBUTTON tb = { 0 };
1771 RECT rect;
1772 int i, cx;
1773
1776 cx = rect.right - rect.left;
1777
1780
1782 for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
1783 {
1784 int index;
1785
1786 if (!fodInfos->places[i])
1787 continue;
1788
1789 memset(&fileinfo, 0, sizeof(fileinfo));
1790 SHGetFileInfoW((const WCHAR *)fodInfos->places[i], 0, &fileinfo, sizeof(fileinfo),
1793
1794 tb.iBitmap = index;
1795 tb.iString = (INT_PTR)fileinfo.szDisplayName;
1796 tb.fsState = TBSTATE_ENABLED | TBSTATE_WRAP;
1797 tb.idCommand = TBPLACES_CMDID_PLACE0 + i;
1799
1800 DestroyIcon(fileinfo.hIcon);
1801 }
1802
1805 }
1806
1807 /* Set the window text with the text specified in the OPENFILENAME structure */
1808 if(fodInfos->title)
1809 {
1810 SetWindowTextW(hwnd,fodInfos->title);
1811 }
1812 else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
1813 {
1814 WCHAR buf[64];
1817 }
1818
1819 /* Initialise the file name edit control */
1820 handledPath = FALSE;
1821 TRACE("Before manipulation, file = %s, dir = %s\n", debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
1822
1823 if(fodInfos->filename)
1824 {
1825 /* 1. If win2000 or higher and filename contains a path, use it
1826 in preference over the lpstrInitialDir */
1827 if (win2000plus && *fodInfos->filename && wcspbrk(fodInfos->filename, L"\\")) {
1828 WCHAR tmpBuf[MAX_PATH];
1829 WCHAR *nameBit;
1830 DWORD result;
1831
1832 result = GetFullPathNameW(fodInfos->filename, MAX_PATH, tmpBuf, &nameBit);
1833 if (result) {
1834
1835 /* nameBit is always shorter than the original filename. It may be NULL
1836 * when the filename contains only a drive name instead of file name */
1837 if (nameBit)
1838 {
1839 lstrcpyW(fodInfos->filename,nameBit);
1840 *nameBit = 0x00;
1841 }
1842 else
1843 *fodInfos->filename = '\0';
1844
1845 heap_free(fodInfos->initdir);
1846 fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
1847 lstrcpyW(fodInfos->initdir, tmpBuf);
1848 handledPath = TRUE;
1849 TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n",
1850 debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
1851 }
1852 SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
1853
1854 } else {
1855 SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
1856 }
1857 }
1858
1859 /* 2. (All platforms) If initdir is not null, then use it */
1860 if (!handledPath && fodInfos->initdir && *fodInfos->initdir)
1861 {
1862 /* Work out the proper path as supplied one might be relative */
1863 /* (Here because supplying '.' as dir browses to My Computer) */
1864 WCHAR tmpBuf[MAX_PATH];
1865 WCHAR tmpBuf2[MAX_PATH];
1866 WCHAR *nameBit;
1867 DWORD result;
1868
1869 lstrcpyW(tmpBuf, fodInfos->initdir);
1870 if (PathFileExistsW(tmpBuf)) {
1871 /* initdir does not have to be a directory. If a file is
1872 * specified, the dir part is taken */
1873 if (PathIsDirectoryW(tmpBuf)) {
1874 PathAddBackslashW(tmpBuf);
1875 lstrcatW(tmpBuf, L"*");
1876 }
1877 result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
1878 if (result) {
1879 *nameBit = 0x00;
1880 heap_free(fodInfos->initdir);
1881 fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR));
1882 lstrcpyW(fodInfos->initdir, tmpBuf2);
1883 handledPath = TRUE;
1884 TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
1885 }
1886 }
1887 else if (fodInfos->initdir)
1888 {
1889 heap_free(fodInfos->initdir);
1890 fodInfos->initdir = NULL;
1891 TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
1892 }
1893 }
1894
1895#ifdef __REACTOS__
1896 if (!handledPath && (!fodInfos->initdir || !*fodInfos->initdir))
1897 {
1898 /* 2.5. Win2000+: Recently used defext */
1899 if (win2000plus) {
1900 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1901 fodInfos->initdir[0] = '\0';
1902
1903 FILEDLG95_MRU_load_ext(fodInfos->initdir, MAX_PATH, fodInfos->defext);
1904
1905 if (fodInfos->initdir[0] && PathIsDirectoryW(fodInfos->initdir)) {
1906 handledPath = TRUE;
1907 } else {
1908 heap_free(fodInfos->initdir);
1909 fodInfos->initdir = NULL;
1910 }
1911 }
1912 }
1913#endif
1914
1915 if (!handledPath && (!fodInfos->initdir || !*fodInfos->initdir))
1916 {
1917 /* 3. All except w2k+: if filename contains a path use it */
1918 if (!win2000plus && fodInfos->filename && *fodInfos->filename &&
1919 wcspbrk(fodInfos->filename, L"\\")) {
1920 WCHAR tmpBuf[MAX_PATH];
1921 WCHAR *nameBit;
1922 DWORD result;
1923
1925 tmpBuf, &nameBit);
1926 if (result) {
1927 int len;
1928
1929 /* nameBit is always shorter than the original filename */
1930 lstrcpyW(fodInfos->filename, nameBit);
1931 *nameBit = 0x00;
1932
1933 len = lstrlenW(tmpBuf);
1934 heap_free(fodInfos->initdir);
1935 fodInfos->initdir = heap_alloc((len+1)*sizeof(WCHAR));
1936 lstrcpyW(fodInfos->initdir, tmpBuf);
1937
1938 handledPath = TRUE;
1939 TRACE("Value in Filename includes path, overriding initdir: %s, %s\n",
1940 debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
1941 }
1942 SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
1943 }
1944
1945 /* 4. Win2000+: Recently used */
1946 if (!handledPath && win2000plus) {
1947 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1948 fodInfos->initdir[0] = '\0';
1949
1951
1952 if (fodInfos->initdir[0] && PathFileExistsW(fodInfos->initdir)){
1953 handledPath = TRUE;
1954 }else{
1955 heap_free(fodInfos->initdir);
1956 fodInfos->initdir = NULL;
1957 }
1958 }
1959
1960 /* 5. win98+ and win2000+ if any files of specified filter types in
1961 current directory, use it */
1962 if (win98plus && !handledPath && fodInfos->filter && *fodInfos->filter) {
1963
1964 LPCWSTR lpstrPos = fodInfos->filter;
1965 WIN32_FIND_DATAW FindFileData;
1966 HANDLE hFind;
1967
1968 while (1)
1969 {
1970 /* filter is a list... title\0ext\0......\0\0 */
1971
1972 /* Skip the title */
1973 if(! *lpstrPos) break; /* end */
1974 lpstrPos += lstrlenW(lpstrPos) + 1;
1975
1976 /* See if any files exist in the current dir with this extension */
1977 if(! *lpstrPos) break; /* end */
1978
1979 hFind = FindFirstFileW(lpstrPos, &FindFileData);
1980
1981 if (hFind == INVALID_HANDLE_VALUE) {
1982 /* None found - continue search */
1983 lpstrPos += lstrlenW(lpstrPos) + 1;
1984
1985 } else {
1986
1987 heap_free(fodInfos->initdir);
1988 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1990
1991 handledPath = TRUE;
1992 TRACE("No initial dir specified, but files of type %s found in current, so using it\n",
1993 debugstr_w(lpstrPos));
1994 FindClose(hFind);
1995 break;
1996 }
1997 }
1998 }
1999
2000 /* 6. Win98+ and 2000+: Use personal files dir, others use current dir */
2001 if (!handledPath && (win2000plus || win98plus)) {
2002 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
2003
2004 if (SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir) == S_OK)
2005 {
2007 {
2008 /* last fallback */
2010 TRACE("No personal or desktop dir, using cwd as failsafe: %s\n", debugstr_w(fodInfos->initdir));
2011 }
2012 else
2013 TRACE("No personal dir, using desktop instead: %s\n", debugstr_w(fodInfos->initdir));
2014 }
2015 else
2016 TRACE("No initial dir specified, using personal files dir of %s\n", debugstr_w(fodInfos->initdir));
2017
2018 handledPath = TRUE;
2019 } else if (!handledPath) {
2020 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
2022 handledPath = TRUE;
2023 TRACE("No initial dir specified, using current dir of %s\n", debugstr_w(fodInfos->initdir));
2024 }
2025 }
2026 SetFocus( fodInfos->DlgInfos.hwndFileName );
2027 TRACE("After manipulation, file = %s, dir = %s\n", debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
2028
2029 /* Must the open as read only check box be checked ?*/
2030 if(fodInfos->ofnInfos->Flags & OFN_READONLY)
2031 {
2033 }
2034
2035 /* Must the open as read only check box be hidden? */
2036 if (filedialog_is_readonly_hidden(fodInfos))
2037 {
2040 }
2041
2042 /* Must the help button be hidden? */
2043 if (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP))
2044 {
2047 }
2048
2049 /* change Open to Save */
2050 if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
2051 {
2052#ifdef __REACTOS__
2053 WCHAR buf[24];
2054#else
2055 WCHAR buf[16];
2056#endif
2061 }
2062
2063 /* Initialize the filter combo box */
2065#ifdef __REACTOS__
2066 DoInitAutoCompleteWithCWD(fodInfos, fodInfos->DlgInfos.hwndFileName);
2067#endif
2068
2069 return 0;
2070}
2071
2072/***********************************************************************
2073 * FILEDLG95_ResizeControls
2074 *
2075 * WM_INITDIALOG message handler (after hook notification)
2076 */
2078{
2080
2081 if (fodInfos->DlgInfos.hwndCustomDlg)
2082 {
2083 RECT rc;
2085
2086 ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
2087 filedialog_is_readonly_hidden(fodInfos) && !(fodInfos->ofnInfos->Flags & OFN_SHOWHELP));
2088
2089 /* resize the custom dialog to the parent size */
2091 GetClientRect(hwnd, &rc);
2092 else
2093 {
2094 /* our own fake template is zero sized and doesn't have children, so
2095 * there is no need to resize it. Picasa depends on it.
2096 */
2097 flags |= SWP_NOSIZE;
2098 SetRectEmpty(&rc);
2099 }
2100 SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
2101 0, 0, rc.right, rc.bottom, flags);
2102 }
2103 else
2104 {
2105 /* Resize the height; if opened as read-only, checkbox and help button are
2106 * hidden and we are not using a custom template nor a customDialog
2107 */
2108 if (filedialog_is_readonly_hidden(fodInfos) &&
2109 (!(fodInfos->ofnInfos->Flags &
2111 {
2112 RECT rectDlg, rectHelp, rectCancel;
2113 GetWindowRect(hwnd, &rectDlg);
2114 GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
2115 GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
2116 /* subtract the height of the help button plus the space between the help
2117 * button and the cancel button to the height of the dialog
2118 */
2119 SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
2120 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
2122 }
2123 }
2124 return TRUE;
2125}
2126
2127/***********************************************************************
2128 * FILEDLG95_FillControls
2129 *
2130 * WM_INITDIALOG message handler (after hook notification)
2131 */
2133{
2134 LPITEMIDLIST pidlItemId = NULL;
2135
2137
2138 TRACE("dir=%s file=%s\n",
2139 debugstr_w(fodInfos->initdir), debugstr_w(fodInfos->filename));
2140
2141 /* Get the initial directory pidl */
2142
2143 if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->initdir)))
2144 {
2146
2148 pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder, path);
2149 }
2150
2151 /* Initialise shell objects */
2153
2154 /* Initialize the Look In combo box */
2155 FILEDLG95_LOOKIN_Init(fodInfos->DlgInfos.hwndLookInCB);
2156
2157 /* Browse to the initial directory */
2158 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,pidlItemId, SBSP_ABSOLUTE);
2159
2160 ILFree(pidlItemId);
2161
2162 return TRUE;
2163}
2164/***********************************************************************
2165 * FILEDLG95_Clean
2166 *
2167 * Regroups all the cleaning functions of the filedlg
2168 */
2170{
2174}
2175
2176
2177/***********************************************************************
2178 * Browse to arbitrary pidl
2179 */
2181{
2182 TRACE("%p, %p\n", info->ShellInfos.hwndOwner, pidl);
2183
2184 IShellBrowser_BrowseObject(info->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
2185 if (info->ofnInfos->Flags & OFN_EXPLORER)
2187}
2188
2189/***********************************************************************
2190 * FILEDLG95_OnWMCommand
2191 *
2192 * WM_COMMAND message handler
2193 */
2195{
2197 WORD wNotifyCode = HIWORD(wParam); /* notification code */
2198 WORD id = LOWORD(wParam); /* item, control, or accelerator identifier */
2199
2200 switch (id)
2201 {
2202 /* OK button */
2203 case IDOK:
2205 break;
2206 /* Cancel button */
2207 case IDCANCEL:
2210 break;
2211 /* Filetype combo box */
2212 case IDC_FILETYPE:
2214 break;
2215 /* LookIn combo box */
2216 case IDC_LOOKIN:
2217 FILEDLG95_LOOKIN_OnCommand(hwnd,wNotifyCode);
2218 break;
2219
2220 /* --- toolbar --- */
2221 /* Up folder button */
2222 case FCIDM_TB_UPFOLDER:
2224 break;
2225 /* New folder button */
2226 case FCIDM_TB_NEWFOLDER:
2227 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_NEWFOLDERA);
2228 break;
2229 /* List option button */
2230 case FCIDM_TB_SMALLICON:
2231 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWLISTA);
2232 break;
2233 /* Details option button */
2235 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWDETAILSA);
2236 break;
2237
2238 case FCIDM_TB_DESKTOP:
2239 {
2240 LPITEMIDLIST pidl;
2241
2243 filedlg_browse_to_pidl(fodInfos, pidl);
2244 ILFree(pidl);
2245 break;
2246 }
2247
2248 /* Places bar */
2254 filedlg_browse_to_pidl(fodInfos, fodInfos->places[id - TBPLACES_CMDID_PLACE0]);
2255 break;
2256
2257 case edt1:
2258 case cmb13:
2259 break;
2260
2261 }
2262 /* Do not use the listview selection anymore */
2263 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
2264 return 0;
2265}
2266
2267/***********************************************************************
2268 * FILEDLG95_OnWMGetIShellBrowser
2269 *
2270 * WM_GETISHELLBROWSER message handler
2271 */
2273{
2275
2276 TRACE("\n");
2277
2278 SetWindowLongPtrW(hwnd,DWLP_MSGRESULT,(LONG_PTR)fodInfos->Shell.FOIShellBrowser);
2279
2280 return TRUE;
2281}
2282
2283
2284/***********************************************************************
2285 * FILEDLG95_SendFileOK
2286 *
2287 * Sends the CDN_FILEOK notification if required
2288 *
2289 * RETURNS
2290 * TRUE if the dialog should close
2291 * FALSE if the dialog should not be closed
2292 */
2294{
2295 /* ask the hook if we can close */
2296 if (is_dialog_hooked(fodInfos))
2297 {
2298 LRESULT retval = 0;
2299
2300 TRACE("---\n");
2301 /* First send CDN_FILEOK as MSDN doc says */
2302 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
2304 if( retval)
2305 {
2306 TRACE("canceled\n");
2307 return FALSE;
2308 }
2309
2310 /* fodInfos->ofnInfos points to an ASCII or UNICODE structure as appropriate */
2311 retval = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,
2312 fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
2313 if( retval)
2314 {
2315 TRACE("canceled\n");
2316 return FALSE;
2317 }
2318 }
2319 return TRUE;
2320}
2321
2322/***********************************************************************
2323 * FILEDLG95_OnOpenMultipleFiles
2324 *
2325 * Handles the opening of multiple files.
2326 *
2327 * FIXME
2328 * check destination buffer size
2329 */
2330BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
2331{
2333 WCHAR lpstrPathSpec[MAX_PATH] = {0};
2334 UINT nCount, nSizePath;
2335
2336 TRACE("\n");
2337
2338 if(fodInfos->unicode)
2339 {
2340 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
2341 ofn->lpstrFile[0] = '\0';
2342 }
2343 else
2344 {
2346 ofn->lpstrFile[0] = '\0';
2347 }
2348
2349 COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
2350
2351 if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
2352 ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
2353 ! ( fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG ) )
2354 {
2355 LPWSTR lpstrTemp = lpstrFileList;
2356
2357 for ( nCount = 0; nCount < nFileCount; nCount++ )
2358 {
2359 LPITEMIDLIST pidl;
2360
2361 pidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, lpstrTemp);
2362 if (!pidl)
2363 {
2364 WCHAR lpstrNotFound[100];
2365 WCHAR lpstrMsg[100];
2366 WCHAR tmp[400];
2367
2368 LoadStringW(COMDLG32_hInstance, IDS_FILENOTFOUND, lpstrNotFound, 100);
2370
2371 lstrcpyW(tmp, lpstrTemp);
2372 lstrcatW(tmp, L"\n");
2373 lstrcatW(tmp, lpstrNotFound);
2374 lstrcatW(tmp, L"\n");
2375 lstrcatW(tmp, lpstrMsg);
2376
2377 MessageBoxW(hwnd, tmp, fodInfos->title, MB_OK | MB_ICONEXCLAMATION);
2378 return FALSE;
2379 }
2380
2381 /* move to the next file in the list of files */
2382 lpstrTemp += lstrlenW(lpstrTemp) + 1;
2383 ILFree(pidl);
2384 }
2385 }
2386
2387 nSizePath = lstrlenW(lpstrPathSpec) + 1;
2388 if ( !(fodInfos->ofnInfos->Flags & OFN_EXPLORER) )
2389 {
2390 /* For "oldstyle" dialog the components have to
2391 be separated by blanks (not '\0'!) and short
2392 filenames have to be used! */
2393 FIXME("Components have to be separated by blanks\n");
2394 }
2395 if(fodInfos->unicode)
2396 {
2397 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
2398 lstrcpyW( ofn->lpstrFile, lpstrPathSpec);
2399 memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) );
2400 }
2401 else
2402 {
2404
2405 if (ofn->lpstrFile != NULL)
2406 {
2407 nSizePath = WideCharToMultiByte(CP_ACP, 0, lpstrPathSpec, -1,
2409 if (ofn->nMaxFile > nSizePath)
2410 {
2411 WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
2412 ofn->lpstrFile + nSizePath,
2413 ofn->nMaxFile - nSizePath, NULL, NULL);
2414 }
2415 }
2416 }
2417
2418 fodInfos->ofnInfos->nFileOffset = nSizePath;
2419 fodInfos->ofnInfos->nFileExtension = 0;
2420
2421 if ( !FILEDLG95_SendFileOK(hwnd, fodInfos) )
2422 return FALSE;
2423
2424 /* clean and exit */
2426 return EndDialog(hwnd,TRUE);
2427}
2428
2429/* Returns the 'slot name' of the given module_name in the registry's
2430 * most-recently-used list. This will be an ASCII value in the
2431 * range ['a','z'). Returns zero on error.
2432 *
2433 * The slot's value in the registry has the form:
2434 * module_name\0mru_path\0
2435 *
2436 * If stored_path is given, then stored_path will contain the path name
2437 * stored in the registry's MRU list for the given module_name.
2438 *
2439 * If hkey_ret is given, then hkey_ret will be a handle to the registry's
2440 * MRU list key for the given module_name.
2441 */
2443{
2444 WCHAR mru_list[32], *cur_mru_slot;
2445 BOOL taken[25] = {0};
2446 DWORD mru_list_size = sizeof(mru_list), key_type = -1, i;
2447 HKEY hkey_tmp, *hkey;
2448 LONG ret;
2449
2450 if(hkey_ret)
2451 hkey = hkey_ret;
2452 else
2453 hkey = &hkey_tmp;
2454
2455 if(stored_path)
2456 *stored_path = '\0';
2457
2459 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", hkey);
2460 if(ret){
2461 WARN("Unable to create MRU key: %ld\n", ret);
2462 return 0;
2463 }
2464
2465 ret = RegGetValueW(*hkey, NULL, L"MRUList", RRF_RT_REG_SZ, &key_type,
2466 (LPBYTE)mru_list, &mru_list_size);
2467 if(ret || key_type != REG_SZ){
2469 return 'a';
2470
2471 WARN("Error getting MRUList data: type: %ld, ret: %ld\n", key_type, ret);
2472 RegCloseKey(*hkey);
2473 return 0;
2474 }
2475
2476 for(cur_mru_slot = mru_list; *cur_mru_slot; ++cur_mru_slot){
2477 WCHAR value_data[MAX_PATH], value_name[2] = {0};
2478 DWORD value_data_size = sizeof(value_data);
2479
2480 *value_name = *cur_mru_slot;
2481
2482 ret = RegGetValueW(*hkey, NULL, value_name, RRF_RT_REG_BINARY,
2483 &key_type, (LPBYTE)value_data, &value_data_size);
2484 if(ret || key_type != REG_BINARY){
2485 WARN("Error getting MRU slot data: type: %ld, ret: %ld\n", key_type, ret);
2486 continue;
2487 }
2488
2489 if(!wcsicmp(module_name, value_data)){
2490 if(!hkey_ret)
2491 RegCloseKey(*hkey);
2492 if(stored_path)
2493 lstrcpyW(stored_path, value_data + lstrlenW(value_data) + 1);
2494 return *value_name;
2495 }
2496 }
2497
2498 if(!hkey_ret)
2499 RegCloseKey(*hkey);
2500
2501 /* the module name isn't in the registry, so find the next open slot */
2502 for(cur_mru_slot = mru_list; *cur_mru_slot; ++cur_mru_slot)
2503 taken[*cur_mru_slot - 'a'] = TRUE;
2504 for(i = 0; i < 25; ++i){
2505 if(!taken[i])
2506 return i + 'a';
2507 }
2508
2509 /* all slots are taken, so return the last one in MRUList */
2510 --cur_mru_slot;
2511 return *cur_mru_slot;
2512}
2513
2514/* save the given filename as most-recently-used path for this module */
2516{
2517 WCHAR module_path[MAX_PATH], *module_name, slot, slot_name[2] = {0};
2518 LONG ret;
2519 HKEY hkey;
2520
2521 /* get the current executable's name */
2522 if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
2523 {
2524 WARN("GotModuleFileName failed: %ld\n", GetLastError());
2525 return;
2526 }
2527 module_name = wcsrchr(module_path, '\\');
2528 if(!module_name)
2529 module_name = module_path;
2530 else
2531 module_name += 1;
2532
2534 if(!slot)
2535 return;
2536 *slot_name = slot;
2537
2538 { /* update the slot's info */
2539 WCHAR *path_ends, *final;
2540 DWORD path_len, final_len;
2541
2542 /* use only the path segment of `filename' */
2543 path_ends = wcsrchr(filename, '\\');
2544 path_len = path_ends - filename;
2545
2546 final_len = path_len + lstrlenW(module_name) + 2;
2547
2548 final = heap_alloc(final_len * sizeof(WCHAR));
2549 if(!final)
2550 return;
2551 lstrcpyW(final, module_name);
2552 memcpy(final + lstrlenW(final) + 1, filename, path_len * sizeof(WCHAR));
2553 final[final_len-1] = '\0';
2554
2555 ret = RegSetValueExW(hkey, slot_name, 0, REG_BINARY, (LPBYTE)final,
2556 final_len * sizeof(WCHAR));
2557 if(ret){
2558 WARN("Error saving MRU data to slot %s: %ld\n", wine_dbgstr_w(slot_name), ret);
2559 heap_free(final);
2560 RegCloseKey(hkey);
2561 return;
2562 }
2563
2564 heap_free(final);
2565 }
2566
2567 { /* update MRUList value */
2568 WCHAR old_mru_list[32], new_mru_list[32];
2569 WCHAR *old_mru_slot, *new_mru_slot = new_mru_list;
2570 DWORD mru_list_size = sizeof(old_mru_list), key_type;
2571
2572 ret = RegGetValueW(hkey, NULL, L"MRUList", RRF_RT_ANY, &key_type,
2573 (LPBYTE)old_mru_list, &mru_list_size);
2574 if(ret || key_type != REG_SZ){
2576 new_mru_list[0] = slot;
2577 new_mru_list[1] = '\0';
2578 }else{
2579 WARN("Error getting MRUList data: type: %ld, ret: %ld\n", key_type, ret);
2580 RegCloseKey(hkey);
2581 return;
2582 }
2583 }else{
2584 /* copy old list data over so that the new slot is at the start
2585 * of the list */
2586 *new_mru_slot++ = slot;
2587 for(old_mru_slot = old_mru_list; *old_mru_slot; ++old_mru_slot){
2588 if(*old_mru_slot != slot)
2589 *new_mru_slot++ = *old_mru_slot;
2590 }
2591 *new_mru_slot = '\0';
2592 }
2593
2594 ret = RegSetValueExW(hkey, L"MRUList", 0, REG_SZ, (LPBYTE)new_mru_list,
2595 (lstrlenW(new_mru_list) + 1) * sizeof(WCHAR));
2596 if(ret){
2597 WARN("Error saving MRUList data: %ld\n", ret);
2598 RegCloseKey(hkey);
2599 return;
2600 }
2601 }
2602}
2603
2604/* load the most-recently-used path for this module */
2605static void FILEDLG95_MRU_load_filename(LPWSTR stored_path)
2606{
2607 WCHAR module_path[MAX_PATH], *module_name;
2608
2609 /* get the current executable's name */
2610 if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
2611 {
2612 WARN("GotModuleFileName failed: %ld\n", GetLastError());
2613 return;
2614 }
2615 module_name = wcsrchr(module_path, '\\');
2616 if(!module_name)
2617 module_name = module_path;
2618 else
2619 module_name += 1;
2620
2622 TRACE("got MRU path: %s\n", wine_dbgstr_w(stored_path));
2623}
2624#ifdef __REACTOS__
2625
2626static const WCHAR s_subkey[] =
2627{
2628 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
2629 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s',
2630 'i','o','n','\\','E','x','p','l','o','r','e','r','\\','C','o','m','D','l','g',
2631 '3','2','\\','O','p','e','n','S','a','v','e','M','R','U',0
2632};
2633static const WCHAR s_szAst[] = { '*', 0 };
2634
2635typedef INT (CALLBACK *MRUStringCmpFnW)(LPCWSTR lhs, LPCWSTR rhs);
2636typedef INT (CALLBACK *MRUBinaryCmpFn)(LPCVOID lhs, LPCVOID rhs, DWORD length);
2637
2638/* https://docs.microsoft.com/en-us/windows/desktop/shell/mruinfo */
2639typedef struct tagMRUINFOW
2640{
2641 DWORD cbSize;
2642 UINT uMax;
2643 UINT fFlags;
2644 HKEY hKey;
2646 union
2647 {
2650 } u;
2652
2653/* flags for MRUINFOW.fFlags */
2654#define MRU_STRING 0x0000
2655#define MRU_BINARY 0x0001
2656#define MRU_CACHEWRITE 0x0002
2657
2658static HINSTANCE s_hComCtl32 = NULL;
2659
2660/* comctl32.400: CreateMRUListW */
2661typedef HANDLE (WINAPI *CREATEMRULISTW)(const MRUINFOW *);
2662static CREATEMRULISTW s_pCreateMRUListW = NULL;
2663
2664/* comctl32.401: AddMRUStringW */
2665typedef INT (WINAPI *ADDMRUSTRINGW)(HANDLE, LPCWSTR);
2666static ADDMRUSTRINGW s_pAddMRUStringW = NULL;
2667
2668/* comctl32.402: FindMRUStringW */
2669typedef INT (WINAPI *FINDMRUSTRINGW)(HANDLE, LPCWSTR, LPINT);
2670static FINDMRUSTRINGW s_pFindMRUStringW = NULL;
2671
2672/* comctl32.403: EnumMRUListW */
2673typedef INT (WINAPI *ENUMMRULISTW)(HANDLE, INT, LPVOID, DWORD);
2674static ENUMMRULISTW s_pEnumMRUListW = NULL;
2675
2676/* comctl32.152: FreeMRUList */
2677typedef void (WINAPI *FREEMRULIST)(HANDLE);
2678static FREEMRULIST s_pFreeMRUList = NULL;
2679
2680static BOOL FILEDLG_InitMRUList(void)
2681{
2682 if (s_hComCtl32)
2683 return TRUE;
2684
2685 s_hComCtl32 = GetModuleHandleA("comctl32");
2686 if (!s_hComCtl32)
2687 return FALSE;
2688
2689 s_pCreateMRUListW = (CREATEMRULISTW)GetProcAddress(s_hComCtl32, (LPCSTR)400);
2690 s_pAddMRUStringW = (ADDMRUSTRINGW)GetProcAddress(s_hComCtl32, (LPCSTR)401);
2691 s_pFindMRUStringW = (FINDMRUSTRINGW)GetProcAddress(s_hComCtl32, (LPCSTR)402);
2692 s_pEnumMRUListW = (ENUMMRULISTW)GetProcAddress(s_hComCtl32, (LPCSTR)403);
2693 s_pFreeMRUList = (FREEMRULIST)GetProcAddress(s_hComCtl32, (LPCSTR)152);
2694 if (!s_pCreateMRUListW ||
2695 !s_pAddMRUStringW ||
2696 !s_pFindMRUStringW ||
2697 !s_pEnumMRUListW ||
2698 !s_pFreeMRUList)
2699 {
2700 s_hComCtl32 = NULL;
2701 return FALSE;
2702 }
2703
2704 return TRUE;
2705}
2706
2707static BOOL ExtIsPicture(LPCWSTR ext)
2708{
2709 static const WCHAR s_image_exts[][6] =
2710 {
2711 { 'b','m','p',0 },
2712 { 'd','i','b',0 },
2713 { 'j','p','g',0 },
2714 { 'j','p','e','g',0 },
2715 { 'j','p','e',0 },
2716 { 'j','f','i','f',0 },
2717 { 'p','n','g',0 },
2718 { 'g','i','f',0 },
2719 { 't','i','f',0 },
2720 { 't','i','f','f',0 }
2721 };
2722 size_t i;
2723
2724 for (i = 0; i < ARRAY_SIZE(s_image_exts); ++i)
2725 {
2726 if (lstrcmpiW(ext, s_image_exts[i]) == 0)
2727 {
2728 return TRUE;
2729 }
2730 }
2731 return FALSE;
2732}
2733
2734static void FILEDLG95_MRU_load_ext(LPWSTR stored_path, size_t cchMax, LPCWSTR defext)
2735{
2736 HKEY hOpenSaveMRT = NULL;
2737 LONG result;
2738 MRUINFOW mi;
2739 HANDLE hList;
2740 WCHAR szText[MAX_PATH];
2741 INT ret = 0;
2742
2743 stored_path[0] = 0;
2744
2745 if (!defext || !*defext || !FILEDLG_InitMRUList())
2746 {
2747 return;
2748 }
2749
2750 if (*defext == '.')
2751 ++defext;
2752
2753 result = RegOpenKeyW(HKEY_CURRENT_USER, s_subkey, &hOpenSaveMRT);
2754 if (!result && hOpenSaveMRT)
2755 {
2756 ZeroMemory(&mi, sizeof(mi));
2757 mi.cbSize = sizeof(mi);
2758 mi.uMax = 26;
2759 mi.fFlags = MRU_STRING;
2760 mi.hKey = hOpenSaveMRT;
2761 mi.lpszSubKey = defext;
2762 mi.u.string_cmpfn = lstrcmpiW;
2763 hList = (*s_pCreateMRUListW)(&mi);
2764 if (hList)
2765 {
2766 ret = (*s_pEnumMRUListW)(hList, 0, szText, sizeof(szText));
2767 if (ret > 0)
2768 {
2769 lstrcpynW(stored_path, szText, cchMax);
2770 PathRemoveFileSpecW(stored_path);
2771 }
2772 (*s_pFreeMRUList)(hList);
2773 }
2774
2775 RegCloseKey(hOpenSaveMRT);
2776 }
2777
2778 if (stored_path[0] == 0)
2779 {
2780 LPITEMIDLIST pidl;
2781 if (ExtIsPicture(defext))
2782 {
2784 }
2785 else
2786 {
2788 }
2789 SHGetPathFromIDListW(pidl, stored_path);
2790 ILFree(pidl);
2791 }
2792}
2793
2794static void FILEDLG95_MRU_save_ext(LPCWSTR filename)
2795{
2796 HKEY hOpenSaveMRT = NULL;
2797 LONG result;
2798 MRUINFOW mi;
2799 HANDLE hList;
2801
2802 if (!defext || !*defext || !FILEDLG_InitMRUList())
2803 {
2804 return;
2805 }
2806
2807 if (*defext == '.')
2808 ++defext;
2809
2810 result = RegOpenKeyW(HKEY_CURRENT_USER, s_subkey, &hOpenSaveMRT);
2811 if (!result && hOpenSaveMRT)
2812 {
2813 ZeroMemory(&mi, sizeof(mi));
2814 mi.cbSize = sizeof(mi);
2815 mi.uMax = 26;
2816 mi.fFlags = MRU_STRING;
2817 mi.hKey = hOpenSaveMRT;
2818 mi.lpszSubKey = defext;
2819 mi.u.string_cmpfn = lstrcmpiW;
2820 hList = (*s_pCreateMRUListW)(&mi);
2821 if (hList)
2822 {
2823 (*s_pAddMRUStringW)(hList, filename);
2824 (*s_pFreeMRUList)(hList);
2825 }
2826
2827 mi.cbSize = sizeof(mi);
2828 mi.uMax = 26;
2829 mi.fFlags = MRU_STRING;
2830 mi.hKey = hOpenSaveMRT;
2831 mi.lpszSubKey = s_szAst;
2832 mi.u.string_cmpfn = lstrcmpiW;
2833 hList = (*s_pCreateMRUListW)(&mi);
2834 if (hList)
2835 {
2836 (*s_pAddMRUStringW)(hList, filename);
2837 (*s_pFreeMRUList)(hList);
2838 }
2839
2840 RegCloseKey(hOpenSaveMRT);
2841 }
2842}
2843
2844#endif /* __REACTOS__ */
2845
2846void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
2847{
2848 WCHAR strMsgTitle[MAX_PATH];
2849 WCHAR strMsgText [MAX_PATH];
2850 if (idCaption)
2851 LoadStringW(COMDLG32_hInstance, idCaption, strMsgTitle, ARRAY_SIZE(strMsgTitle));
2852 else
2853 strMsgTitle[0] = '\0';
2854 LoadStringW(COMDLG32_hInstance, idText, strMsgText, ARRAY_SIZE(strMsgText));
2855 MessageBoxW(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND);
2856}
2857
2858#ifdef __REACTOS__
2859/* The return value needs LocalFree */
2860static LPWSTR FILEDLG95_GetFallbackExtension(FileOpenDlgInfos *fodInfos, LPWSTR lpstrPathAndFile)
2861{
2862 LPWSTR lpstrFilter, the_ext = NULL, pchDot = NULL;
2863
2864 /* Without lpstrDefExt, append no extension */
2865 if (!fodInfos->defext)
2866 return NULL;
2867
2868 /* Get filter extensions */
2869 lpstrFilter = (LPWSTR)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
2870 fodInfos->ofnInfos->nFilterIndex - 1);
2871 if (lpstrFilter != (LPWSTR)CB_ERR && lpstrFilter && *lpstrFilter)
2872 {
2873 LPWSTR pchSemicolon = wcschr(lpstrFilter, L';');
2874
2875 if (pchSemicolon)
2876 *pchSemicolon = UNICODE_NULL;
2877
2878 pchDot = wcschr(lpstrFilter, L'.');
2879
2880 if (pchDot && pchDot[1] && !wcschr(pchDot, L'*') && !wcschr(pchDot, L'?'))
2881 the_ext = StrDupW(pchDot + 1);
2882
2883 if (pchSemicolon)
2884 *pchSemicolon = L';';
2885 }
2886
2887 if (!the_ext && (!pchDot || pchDot[1]))
2888 {
2889 /* use default extension if no extension in filter */
2890 the_ext = StrDupW(fodInfos->defext);
2891 }
2892
2893 return the_ext;
2894}
2895
2896static BOOL
2897FILEDLG95_AddDotExtIfNeeded(FileOpenDlgInfos *fodInfos, LPWSTR lpstrPathAndFile)
2898{
2899 BOOL ret = FALSE;
2900 LPWSTR ext = PathFindExtensionW(lpstrPathAndFile);
2901 int PathLength = lstrlenW(lpstrPathAndFile);
2902 LPWSTR the_ext = FILEDLG95_GetFallbackExtension(fodInfos, lpstrPathAndFile);
2903
2904 if (the_ext && *the_ext &&
2905 (*ext == UNICODE_NULL || lstrcmpiW(ext + 1, the_ext) != 0))
2906 {
2907 if (strlenW(lpstrPathAndFile) + 1 + strlenW(the_ext) + 1 <=
2908 fodInfos->ofnInfos->nMaxFile)
2909 {
2910 /* Make the extension lowercase */
2911 CharLowerW(the_ext);
2912 /* Append it (with dot) to the file */
2913 lstrcatW(lpstrPathAndFile, L".");
2914 lstrcatW(lpstrPathAndFile, the_ext);
2915 /* update ext */
2916 ext = PathFindExtensionW(lpstrPathAndFile);
2917 ret = TRUE;
2918 }
2919 }
2920
2921 LocalFree(the_ext);
2922
2923 /* In Open dialog: if file does not exist try without extension */
2924 if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
2925 {
2926 lpstrPathAndFile[PathLength] = UNICODE_NULL;
2927 ret = FALSE;
2928 }
2929
2930 /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */
2931 if (*ext)
2932 ext++;
2933 if (!lstrcmpiW(fodInfos->defext, ext))
2934 fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT;
2935 else
2937
2938 return ret;
2939}
2940#endif
2941
2942#ifdef __REACTOS__
2943int FILEDLG95_ValidatePathAction(struct FileOpenDlgInfos *fodInfos, LPWSTR lpstrPathAndFile,
2944 IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg,
2945 int defAction)
2946#else
2948 HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction)
2949#endif
2950{
2951 int nOpenAction = defAction;
2952 LPWSTR lpszTemp, lpszTemp1;
2953 LPITEMIDLIST pidl = NULL;
2954
2955 /* check for invalid chars */
2956 if((wcspbrk(lpstrPathAndFile+3, L"/:<>|") != NULL) && !(flags & OFN_NOVALIDATE))
2957 {
2959 return FALSE;
2960 }
2961
2962 if (FAILED (SHGetDesktopFolder(ppsf))) return FALSE;
2963
2964 lpszTemp1 = lpszTemp = lpstrPathAndFile;
2965 while (lpszTemp1)
2966 {
2967 LPSHELLFOLDER lpsfChild;
2968 WCHAR lpwstrTemp[MAX_PATH];
2969 DWORD dwEaten, dwAttributes;
2970 LPWSTR p;
2971
2972 lstrcpyW(lpwstrTemp, lpszTemp);
2973 if (lpszTemp == lpstrPathAndFile && (p = PathSkipRootW(lpwstrTemp)))
2974 {
2975 *p = 0;
2976 }
2977 else
2978 {
2979 p = PathFindNextComponentW(lpwstrTemp);
2980 if (!p) break; /* end of path */
2981 *p = 0;
2982 }
2983 lpszTemp = lpszTemp + lstrlenW(lpwstrTemp);
2984
2985 /* There are no wildcards when OFN_NOVALIDATE is set */
2986 if(*lpszTemp==0 && !(flags & OFN_NOVALIDATE))
2987 {
2988 /* if the last element is a wildcard do a search */
2989 if(wcspbrk(lpszTemp1, L"*?") != NULL)
2990 {
2991 nOpenAction = ONOPEN_SEARCH;
2992 break;
2993 }
2994 }
2995 lpszTemp1 = lpszTemp;
2996
2997 TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_w(lpszTemp), *ppsf);
2998
2999 /* append a backslash to drive letters */
3000 if(lstrlenW(lpwstrTemp)==2 && lpwstrTemp[1] == ':' &&
3001 ((lpwstrTemp[0] >= 'a' && lpwstrTemp[0] <= 'z') ||
3002 (lpwstrTemp[0] >= 'A' && lpwstrTemp[0] <= 'Z')))
3003 {
3004 PathAddBackslashW(lpwstrTemp);
3005 }
3006
3007#ifdef __REACTOS__
3008 dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSANCESTOR;
3009#else
3010 dwAttributes = SFGAO_FOLDER;
3011#endif
3012 if(SUCCEEDED(IShellFolder_ParseDisplayName(*ppsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes)))
3013 {
3014 /* the path component is valid, we have a pidl of the next path component */
3015 TRACE("parse OK attr=0x%08lx pidl=%p\n", dwAttributes, pidl);
3016#ifdef __REACTOS__
3017 if((dwAttributes & (SFGAO_FOLDER | SFGAO_FILESYSANCESTOR)) == (SFGAO_FOLDER | SFGAO_FILESYSANCESTOR))
3018#else
3019 if(dwAttributes & SFGAO_FOLDER)
3020#endif
3021 {
3022 if(FAILED(IShellFolder_BindToObject(*ppsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild)))
3023 {
3024 ERR("bind to failed\n"); /* should not fail */
3025 break;
3026 }
3027 IShellFolder_Release(*ppsf);
3028 *ppsf = lpsfChild;
3029 lpsfChild = NULL;
3030 }
3031 else
3032 {
3033 TRACE("value\n");
3034
3035 /* end dialog, return value */
3036 nOpenAction = ONOPEN_OPEN;
3037 break;
3038 }
3039 ILFree(pidl);
3040 pidl = NULL;
3041 }
3042 else if (!(flags & OFN_NOVALIDATE))
3043 {
3044 if(*lpszTemp || /* points to trailing null for last path element */
3045 (lpwstrTemp[lstrlenW(lpwstrTemp)-1] == '\\')) /* or if last element ends in '\' */
3046 {
3048 {
3050 break;
3051 }
3052 }
3053 else
3054 {
3055 if( (flags & OFN_FILEMUSTEXIST) && !isSaveDlg )
3056 {
3057#ifdef __REACTOS__
3058 FILEDLG95_AddDotExtIfNeeded(fodInfos, lpstrPathAndFile);
3059 if (!PathFileExistsW(lpstrPathAndFile))
3060 {
3062 break;
3063 }
3064#else
3066 break;
3067#endif
3068 }
3069 }
3070 /* change to the current folder */
3071 nOpenAction = ONOPEN_OPEN;
3072 break;
3073 }
3074 else
3075 {
3076 nOpenAction = ONOPEN_OPEN;
3077 break;
3078 }
3079 }
3080 ILFree(pidl);
3081
3082 return nOpenAction;
3083}
3084
3085/***********************************************************************
3086 * FILEDLG95_OnOpen
3087 *
3088 * Ok button WM_COMMAND message handler
3089 *
3090 * If the function succeeds, the return value is nonzero.
3091 */
3093{
3095 LPWSTR lpstrFileList;
3096 UINT nFileCount = 0;
3097 UINT sizeUsed = 0;
3098 BOOL ret = TRUE;
3099 WCHAR lpstrPathAndFile[MAX_PATH];
3100 LPSHELLFOLDER lpsf = NULL;
3101 int nOpenAction;
3102
3103 TRACE("hwnd=%p\n", hwnd);
3104
3105 /* try to browse the selected item */
3107 return FALSE;
3108
3109 /* get the files from the edit control */
3110 nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
3111
3112 if(nFileCount == 0)
3113 return FALSE;
3114
3115 if(nFileCount > 1)
3116 {
3117 ret = FILEDLG95_OnOpenMultipleFiles(hwnd, lpstrFileList, nFileCount, sizeUsed);
3118 goto ret;
3119 }
3120
3121 TRACE("count=%u len=%u file=%s\n", nFileCount, sizeUsed, debugstr_w(lpstrFileList));
3122
3123/*
3124 Step 1: Build a complete path name from the current folder and
3125 the filename or path in the edit box.
3126 Special cases:
3127 - the path in the edit box is a root path
3128 (with or without drive letter)
3129 - the edit box contains ".." (or a path with ".." in it)
3130*/
3131
3132 COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile);
3133 heap_free(lpstrFileList);
3134
3135/*
3136 Step 2: here we have a cleaned up path
3137
3138 We have to parse the path step by step to see if we have to browse
3139 to a folder if the path points to a directory or the last
3140 valid element is a directory.
3141
3142 valid variables:
3143 lpstrPathAndFile: cleaned up path
3144 */
3145
3146 if (nFileCount &&
3147 (fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
3148 !(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
3149 nOpenAction = ONOPEN_OPEN;
3150 else
3151 nOpenAction = ONOPEN_BROWSE;
3152
3153#ifdef __REACTOS__
3154 nOpenAction = FILEDLG95_ValidatePathAction(fodInfos, lpstrPathAndFile, &lpsf, hwnd,
3155#else
3156 nOpenAction = FILEDLG95_ValidatePathAction(lpstrPathAndFile, &lpsf, hwnd,
3157#endif
3158 fodInfos->ofnInfos->Flags,
3159 fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG,
3160 nOpenAction);
3161 if(!nOpenAction)
3162 goto ret;
3163
3164/*
3165 Step 3: here we have a cleaned up and validated path
3166
3167 valid variables:
3168 lpsf: ShellFolder bound to the rightmost valid path component
3169 lpstrPathAndFile: cleaned up path
3170 nOpenAction: action to do
3171*/
3172 TRACE("end validate sf=%p\n", lpsf);
3173
3174 switch(nOpenAction)
3175 {
3176 case ONOPEN_SEARCH: /* set the current filter to the file mask and refresh */
3177 TRACE("ONOPEN_SEARCH %s\n", debugstr_w(lpstrPathAndFile));
3178 {
3179 int iPos;
3180 LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);
3181 DWORD len;
3182
3183 /* replace the current filter */
3184 heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
3185 len = lstrlenW(lpszTemp)+1;
3186 fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc(len * sizeof(WCHAR));
3187 lstrcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
3188
3189 /* set the filter cb to the extension when possible */
3190 if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
3191 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, iPos, 0);
3192 }
3193 /* fall through */
3194 case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */
3195 TRACE("ONOPEN_BROWSE\n");
3196 {
3197 IPersistFolder2 * ppf2;
3198 if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
3199 {
3200 LPITEMIDLIST pidlCurrent;
3201 IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent);
3202 IPersistFolder2_Release(ppf2);
3203 if (!ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
3204 {
3205 if (SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE))
3206 && fodInfos->ofnInfos->Flags & OFN_EXPLORER)
3207 {
3209 SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_SETTEXT, 0, (LPARAM)"");
3210 }
3211 }
3212 else if( nOpenAction == ONOPEN_SEARCH )
3213 {
3214 if (fodInfos->Shell.FOIShellView)
3215 IShellView_Refresh(fodInfos->Shell.FOIShellView);
3216 }
3217 ILFree(pidlCurrent);
3218 if (filename_is_edit( fodInfos ))
3219 SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
3220 else
3221 {
3222 HWND hwnd;
3223
3224 hwnd = (HWND)SendMessageA(fodInfos->DlgInfos.hwndFileName, CBEM_GETEDITCONTROL, 0, 0);
3225 SendMessageW(hwnd, EM_SETSEL, 0, -1);
3226 }
3227 }
3228 }
3229 ret = FALSE;
3230 break;
3231 case ONOPEN_OPEN: /* fill in the return struct and close the dialog */
3232 TRACE("ONOPEN_OPEN %s\n", debugstr_w(lpstrPathAndFile));
3233 {
3234#ifndef __REACTOS__
3235 WCHAR *ext = NULL;
3236#endif
3237
3238 /* update READONLY check box flag */
3240 fodInfos->ofnInfos->Flags |= OFN_READONLY;
3241 else
3242 fodInfos->ofnInfos->Flags &= ~OFN_READONLY;
3243
3244 /* Attach the file extension with file name*/
3245#ifdef __REACTOS__
3246 /* Add extension if necessary */
3247 FILEDLG95_AddDotExtIfNeeded(fodInfos, lpstrPathAndFile);
3248 /* update dialog data */
3249 SetWindowTextW(fodInfos->DlgInfos.hwndFileName, PathFindFileNameW(lpstrPathAndFile));
3250#else /* __REACTOS__ */
3251 ext = PathFindExtensionW(lpstrPathAndFile);
3252 if (! *ext && fodInfos->defext)
3253 {
3254 /* if no extension is specified with file name, then */
3255 /* attach the extension from file filter or default one */
3256
3257 WCHAR *filterExt = NULL;
3258 LPWSTR lpstrFilter = NULL;
3259 int PathLength = lstrlenW(lpstrPathAndFile);
3260
3261 /*Get the file extension from file type filter*/
3262 lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
3263 fodInfos->ofnInfos->nFilterIndex-1);
3264
3265 if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
3266 {
3267 WCHAR* filterSearchIndex;
3268 filterExt = heap_alloc((lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR));
3269 lstrcpyW(filterExt, lpstrFilter);
3270
3271 /* if a semicolon-separated list of file extensions was given, do not include the
3272 semicolon or anything after it in the extension.
3273 example: if filterExt was "*.abc;*.def", it will become "*.abc" */
3274 filterSearchIndex = wcschr(filterExt, ';');
3275 if (filterSearchIndex)
3276 {
3277 filterSearchIndex[0] = '\0';
3278 }
3279
3280 /* find the file extension by searching for the first dot in filterExt */
3281 /* strip the * or anything else from the extension, "*.abc" becomes "abc" */
3282 /* if the extension is invalid or contains a glob, ignore it */
3283 filterSearchIndex = wcschr(filterExt, '.');
3284 if (filterSearchIndex++ && !wcschr(filterSearchIndex, '*') && !wcschr(filterSearchIndex, '?'))
3285 {
3286 lstrcpyW(filterExt, filterSearchIndex);
3287 }
3288 else
3289 {
3290 heap_free(filterExt);
3291 filterExt = NULL;
3292 }
3293 }
3294
3295 if (!filterExt)
3296 {
3297 /* use the default file extension */
3298 filterExt = heap_alloc((lstrlenW(fodInfos->defext) + 1) * sizeof(WCHAR));
3299 lstrcpyW(filterExt, fodInfos->defext);
3300 }
3301
3302 if (*filterExt) /* ignore filterExt="" */
3303 {
3304 /* Attach the dot*/
3305 lstrcatW(lpstrPathAndFile, L".");
3306 /* Attach the extension */
3307 lstrcatW(lpstrPathAndFile, filterExt);
3308 }
3309
3310 heap_free(filterExt);
3311
3312 /* In Open dialog: if file does not exist try without extension */
3313 if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
3314 lpstrPathAndFile[PathLength] = '\0';
3315
3316 /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */
3317 if (*ext)
3318 ext++;
3319 if (!lstrcmpiW(fodInfos->defext, ext))
3320 fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT;
3321 else
3323 }
3324#endif /* __REACTOS__ */
3325
3326 /* In Save dialog: check if the file already exists */
3327 if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG
3328 && fodInfos->ofnInfos->Flags & OFN_OVERWRITEPROMPT
3329 && PathFileExistsW(lpstrPathAndFile))
3330 {
3331 WCHAR lpstrOverwrite[100];
3332 int answer;
3333
3334 LoadStringW(COMDLG32_hInstance, IDS_OVERWRITEFILE, lpstrOverwrite, 100);
3335 answer = MessageBoxW(hwnd, lpstrOverwrite, fodInfos->title,
3337 if (answer == IDNO || answer == IDCANCEL)
3338 {
3339 ret = FALSE;
3340 goto ret;
3341 }
3342 }
3343
3344 /* In Open dialog: check if it should be created if it doesn't exist */
3345 if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
3346 && fodInfos->ofnInfos->Flags & OFN_CREATEPROMPT
3347 && !PathFileExistsW(lpstrPathAndFile))
3348 {
3349 WCHAR lpstrCreate[100];
3350 int answer;
3351
3352 LoadStringW(COMDLG32_hInstance, IDS_CREATEFILE, lpstrCreate, 100);
3353 answer = MessageBoxW(hwnd, lpstrCreate, fodInfos->title,
3355 if (answer == IDNO || answer == IDCANCEL)
3356 {
3357 ret = FALSE;
3358 goto ret;
3359 }
3360 }
3361
3362 /* Check that the size of the file does not exceed buffer size.
3363 (Allow for extra \0 if OFN_MULTISELECT is set.) */
3364 if(lstrlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
3365 ((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
3366 {
3367
3368 /* fill destination buffer */
3369 if (fodInfos->ofnInfos->lpstrFile)
3370 {
3371 if(fodInfos->unicode)
3372 {
3373 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
3374
3375 lstrcpynW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
3377 ofn->lpstrFile[lstrlenW(ofn->lpstrFile) + 1] = '\0';
3378 }
3379 else
3380 {
3382
3383 WideCharToMultiByte(CP_ACP, 0, lpstrPathAndFile, -1,
3386 ofn->lpstrFile[lstrlenA(ofn->lpstrFile) + 1] = '\0';
3387 }
3388 }
3389
3390 if(fodInfos->unicode)
3391 {
3392 LPWSTR lpszTemp;
3393
3394 /* set filename offset */
3395 lpszTemp = PathFindFileNameW(lpstrPathAndFile);
3396 fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
3397
3398 /* set extension offset */
3399 lpszTemp = PathFindExtensionW(lpstrPathAndFile);
3400 fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
3401 }
3402 else
3403 {
3404 LPSTR lpszTemp;
3405 CHAR tempFileA[MAX_PATH];
3406
3407 /* avoid using fodInfos->ofnInfos->lpstrFile since it can be NULL */
3408 WideCharToMultiByte(CP_ACP, 0, lpstrPathAndFile, -1,
3409 tempFileA, sizeof(tempFileA), NULL, NULL);
3410
3411 /* set filename offset */
3412 lpszTemp = PathFindFileNameA(tempFileA);
3413 fodInfos->ofnInfos->nFileOffset = (lpszTemp - tempFileA);
3414
3415 /* set extension offset */
3416 lpszTemp = PathFindExtensionA(tempFileA);
3417 fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - tempFileA) + 1 : 0;
3418 }
3419
3420#ifdef __REACTOS__
3421 /* set the lpstrFileTitle */
3422 if(fodInfos->ofnInfos->lpstrFileTitle)
3423 {
3424 LPWSTR lpstrFileTitle = PathFindFileNameW(lpstrPathAndFile);
3425 if(fodInfos->unicode)
3426 {
3427 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
3428 lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
3429 }
3430 else
3431 {
3433 WideCharToMultiByte(CP_ACP, 0, lpstrFileTitle, -1,
3435 }
3436 }
3437#endif
3438
3439 /* copy currently selected filter to lpstrCustomFilter */
3440 if (fodInfos->ofnInfos->lpstrCustomFilter)
3441 {
3443 int len = WideCharToMultiByte(CP_ACP, 0, fodInfos->ShellInfos.lpstrCurrentFilter, -1,
3444 NULL, 0, NULL, NULL);
3446 {
3449 WideCharToMultiByte(CP_ACP, 0, fodInfos->ShellInfos.lpstrCurrentFilter, -1,
3450 s, len, NULL, NULL);
3451 }
3452 }
3453
3454
3455 if ( !FILEDLG95_SendFileOK(hwnd, fodInfos) )
3456 goto ret;
3457
3458 FILEDLG95_MRU_save_filename(lpstrPathAndFile);
3459#ifdef __REACTOS__
3460 FILEDLG95_MRU_save_ext(lpstrPathAndFile);
3461#endif
3462
3463 TRACE("close\n");
3465 ret = EndDialog(hwnd, TRUE);
3466 }
3467 else
3468 {
3469 WORD size;
3470
3471 size = lstrlenW(lpstrPathAndFile) + 1;
3472 if (fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)
3473 size += 1;
3474 /* return needed size in first two bytes of lpstrFile */
3475 if(fodInfos->ofnInfos->lpstrFile)
3476 *(WORD *)fodInfos->ofnInfos->lpstrFile = size;
3478 ret = EndDialog(hwnd, FALSE);
3480 }
3481 }
3482 break;
3483 }
3484
3485ret:
3486 if(lpsf) IShellFolder_Release(lpsf);
3487 return ret;
3488}
3489
3490/***********************************************************************
3491 * FILEDLG95_SHELL_Init
3492 *
3493 * Initialisation of the shell objects
3494 */
3496{
3498
3499 TRACE("%p\n", hwnd);
3500
3501 /*
3502 * Initialisation of the FileOpenDialogInfos structure
3503 */
3504
3505 /* Shell */
3506
3507 /*ShellInfos */
3508 fodInfos->ShellInfos.hwndOwner = hwnd;
3509
3510 /* Disable multi-select if flag not set */
3511 if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT))
3512 {
3513 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
3514 }
3515 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT;
3516 fodInfos->ShellInfos.folderSettings.ViewMode = FVM_LIST;
3517
3518 /* Construct the IShellBrowser interface */
3519 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
3520
3521 return NOERROR;
3522}
3523
3524/***********************************************************************
3525 * FILEDLG95_SHELL_ExecuteCommand
3526 *
3527 * Change the folder option and refresh the view
3528 * If the function succeeds, the return value is nonzero.
3529 */
3531{
3533 IContextMenu * pcm;
3534
3535 TRACE("(%p,%p)\n", hwnd, lpVerb);
3536
3537 if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView,
3538 SVGIO_BACKGROUND,
3539 &IID_IContextMenu,
3540 (LPVOID*)&pcm)))
3541 {
3542 CMINVOKECOMMANDINFO ci;
3543 ZeroMemory(&ci, sizeof(CMINVOKECOMMANDINFO));
3544 ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
3545 ci.lpVerb = lpVerb;
3546 ci.hwnd = hwnd;
3547
3548 IContextMenu_InvokeCommand(pcm, &ci);
3549 IContextMenu_Release(pcm);
3550 }
3551
3552 return FALSE;
3553}
3554
3555/***********************************************************************
3556 * FILEDLG95_SHELL_UpFolder
3557 *
3558 * Browse to the specified object
3559 * If the function succeeds, the return value is nonzero.
3560 */
3562{
3564
3565 TRACE("\n");
3566
3567 if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
3568 NULL,
3569 SBSP_PARENT)))
3570 {
3571 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
3573 return TRUE;
3574 }
3575 return FALSE;
3576}
3577/***********************************************************************
3578 * FILEDLG95_SHELL_Clean
3579 *
3580 * Cleans the memory used by shell objects
3581 */
3583{
3585
3586 TRACE("\n");
3587
3588 ILFree(fodInfos->ShellInfos.pidlAbsCurrent);
3589
3590 /* clean Shell interfaces */
3591 if (fodInfos->Shell.FOIShellView)
3592 {
3593 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
3594 IShellView_Release(fodInfos->Shell.FOIShellView);
3595 }
3596 if (fodInfos->Shell.FOIShellFolder)
3597 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
3598 IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
3599 if (fodInfos->Shell.FOIDataObject)
3600 IDataObject_Release(fodInfos->Shell.FOIDataObject);
3601}
3602
3603/***********************************************************************
3604 * FILEDLG95_FILETYPE_Init
3605 *
3606 * Initialisation of the file type combo box
3607 */
3609{
3611 int nFilters = 0; /* number of filters */
3612 int nFilterIndexCB;
3613
3614 TRACE("%p\n", hwnd);
3615
3616 if(fodInfos->customfilter)
3617 {
3618 /* customfilter has one entry... title\0ext\0
3619 * Set first entry of combo box item with customfilter
3620 */
3621 LPWSTR lpstrExt;
3622 LPCWSTR lpstrPos = fodInfos->customfilter;
3623
3624 /* Get the title */
3625 lpstrPos += lstrlenW(fodInfos->customfilter) + 1;
3626
3627 /* Copy the extensions */
3628 if (! *lpstrPos) return E_FAIL; /* malformed filter */
3629 if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
3630 lstrcpyW(lpstrExt,lpstrPos);
3631
3632 /* Add the item at the end of the combo */
3633 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)fodInfos->customfilter);
3634 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters, (LPARAM)lpstrExt);
3635
3636 nFilters++;
3637 }
3638 if(fodInfos->filter)
3639 {
3640 LPCWSTR lpstrPos = fodInfos->filter;
3641
3642 for(;;)
3643 {
3644 /* filter is a list... title\0ext\0......\0\0
3645 * Set the combo item text to the title and the item data
3646 * to the ext
3647 */
3648 LPCWSTR lpstrDisplay;
3649 LPWSTR lpstrExt;
3650
3651 /* Get the title */
3652 if(! *lpstrPos) break; /* end */
3653 lpstrDisplay = lpstrPos;
3654 lpstrPos += lstrlenW(lpstrPos) + 1;
3655
3656 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)lpstrDisplay);
3657
3658 nFilters++;
3659
3660 /* Copy the extensions */
3661 if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
3662 lstrcpyW(lpstrExt,lpstrPos);
3663 lpstrPos += lstrlenW(lpstrPos) + 1;
3664
3665 /* Add the item at the end of the combo */
3666 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters - 1, (LPARAM)lpstrExt);
3667
3668 /* malformed filters are added anyway... */
3669 if (!*lpstrExt) break;
3670 }
3671 }
3672
3673 /*
3674 * Set the current filter to the one specified
3675 * in the initialisation structure
3676 */
3677 if (fodInfos->filter || fodInfos->customfilter)
3678 {
3679 LPWSTR lpstrFilter;
3680
3681 /* Check to make sure our index isn't out of bounds. */
3682 if ( fodInfos->ofnInfos->nFilterIndex >
3683 nFilters - (fodInfos->customfilter == NULL ? 0 : 1) )
3684 fodInfos->ofnInfos->nFilterIndex = (fodInfos->customfilter == NULL ? 1 : 0);
3685
3686 /* set default filter index */
3687 if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->customfilter == NULL)
3688 fodInfos->ofnInfos->nFilterIndex = 1;
3689
3690 /* calculate index of Combo Box item */
3691 nFilterIndexCB = fodInfos->ofnInfos->nFilterIndex;
3692 if (fodInfos->customfilter == NULL)
3693 nFilterIndexCB--;
3694
3695 /* Set the current index selection. */
3696 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, nFilterIndexCB, 0);
3697
3698 /* Get the corresponding text string from the combo box. */
3699 lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
3700 nFilterIndexCB);
3701
3702 if ((INT_PTR)lpstrFilter == CB_ERR) /* control is empty */
3703 lpstrFilter = NULL;
3704
3705 if(lpstrFilter)
3706 {
3707 DWORD len;
3708 CharLowerW(lpstrFilter); /* lowercase */
3709 len = lstrlenW(lpstrFilter)+1;
3710 fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
3711 lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
3712 }
3713 } else
3714 fodInfos->ofnInfos->nFilterIndex = 0;
3715 return S_OK;
3716}
3717
3718/***********************************************************************
3719 * FILEDLG95_FILETYPE_OnCommand
3720 *
3721 * WM_COMMAND of the file type combo box
3722 * If the function succeeds, the return value is nonzero.
3723 */
3725{
3727
3728 switch(wNotifyCode)
3729 {
3730 case CBN_SELENDOK:
3731 {
3732 LPWSTR lpstrFilter;
3733
3734 /* Get the current item of the filetype combo box */
3735 int iItem = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCURSEL, 0, 0);
3736
3737 /* set the current filter index */
3738 fodInfos->ofnInfos->nFilterIndex = iItem +
3739 (fodInfos->customfilter == NULL ? 1 : 0);
3740
3741 /* Set the current filter with the current selection */
3742 heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
3743
3744 lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
3745 iItem);
3746 if((INT_PTR)lpstrFilter != CB_ERR)
3747 {
3748 DWORD len;
3749 CharLowerW(lpstrFilter); /* lowercase */
3750 len = lstrlenW(lpstrFilter)+1;
3751 fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
3752 lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
3753 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
3755 }
3756
3757 /* Refresh the actual view to display the included items*/
3758 if (fodInfos->Shell.FOIShellView)
3759 IShellView_Refresh(fodInfos->Shell.FOIShellView);
3760 }
3761 }
3762 return FALSE;
3763}
3764/***********************************************************************
3765 * FILEDLG95_FILETYPE_SearchExt
3766 *
3767 * searches for an extension in the filetype box
3768 */
3770{
3771 int i, iCount;
3772
3773 iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
3774
3775 TRACE("%s\n", debugstr_w(lpstrExt));
3776
3777 if(iCount != CB_ERR)
3778 {
3779 for(i=0;i<iCount;i++)
3780 {
3781 if(!lstrcmpiW(lpstrExt,(LPWSTR)CBGetItemDataPtr(hwnd,i)))
3782 return i;
3783 }
3784 }
3785 return -1;
3786}
3787
3788/***********************************************************************
3789 * FILEDLG95_FILETYPE_Clean
3790 *
3791 * Clean the memory used by the filetype combo box
3792 */
3794{
3796 int iPos;
3797 int iCount;
3798
3799 iCount = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCOUNT, 0, 0);
3800
3801 TRACE("\n");
3802
3803 /* Delete each string of the combo and their associated data */
3804 if(iCount != CB_ERR)
3805 {
3806 for(iPos = iCount-1;iPos>=0;iPos--)
3807 {
3808 heap_free((void *)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
3809 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_DELETESTRING, iPos, 0);
3810 }
3811 }
3812 /* Current filter */
3813 heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
3814}
3815
3816/***********************************************************************
3817 * FILEDLG95_LOOKIN_Init
3818 *
3819 * Initialisation of the look in combo box
3820 */
3821
3822/* Small helper function, to determine if the unixfs shell extension is rooted
3823 * at the desktop. Copied from dlls/shell32/shfldr_unixfs.c.
3824 */
3826 HKEY hKey;
3827
3829 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\"
3830 "{9D20AAE8-0625-44B0-9CA7-71889C2254D9}", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
3831 return FALSE;
3832
3834 return TRUE;
3835}
3836
3837static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
3838{
3839 IShellFolder *psfRoot, *psfDrives;
3840 IEnumIDList *lpeRoot, *lpeDrives;
3841 LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
3842 HDC hdc;
3844 LookInInfos *liInfos = heap_alloc_zero(sizeof(*liInfos));
3845
3846 TRACE("%p\n", hwndCombo);
3847
3848 liInfos->iMaxIndentation = 0;
3849
3850 SetPropA(hwndCombo, LookInInfosStr, liInfos);
3851
3852 hdc = GetDC( hwndCombo );
3853 SelectObject( hdc, (HFONT)SendMessageW( hwndCombo, WM_GETFONT, 0, 0 ));
3854 GetTextMetricsW( hdc, &tm );
3855 ReleaseDC( hwndCombo, hdc );
3856
3857 /* set item height for both text field and listbox */
3858 SendMessageW(hwndCombo, CB_SETITEMHEIGHT, -1, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
3859 SendMessageW(hwndCombo, CB_SETITEMHEIGHT, 0, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
3860
3861 /* Turn on the extended UI for the combo box like Windows does */
3862 SendMessageW(hwndCombo, CB_SETEXTENDEDUI, TRUE, 0);
3863
3864 /* Initialise data of Desktop folder */
3866 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
3867 ILFree(pidlTmp);
3868
3870
3871 SHGetDesktopFolder(&psfRoot);
3872
3873 if (psfRoot)
3874 {
3875 /* enumerate the contents of the desktop */
3876 if(SUCCEEDED(IShellFolder_EnumObjects(psfRoot, hwndCombo, SHCONTF_FOLDERS, &lpeRoot)))
3877 {
3878 while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL))
3879 {
3880 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
3881
3882 /* If the unixfs extension is rooted, we don't expand the drives by default */
3884 {
3885 /* special handling for CSIDL_DRIVES */
3886 if (ILIsEqual(pidlTmp, pidlDrives))
3887 {
3888 if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
3889 {
3890 /* enumerate the drives */
3891 if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
3892 {
3893 while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
3894 {
3895 pidlAbsTmp = ILCombine(pidlTmp, pidlTmp1);
3896 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
3897 ILFree(pidlAbsTmp);
3898 ILFree(pidlTmp1);
3899 }
3900 IEnumIDList_Release(lpeDrives);
3901 }
3902 IShellFolder_Release(psfDrives);
3903 }
3904 }
3905 }
3906
3907 ILFree(pidlTmp);
3908 }
3909 IEnumIDList_Release(lpeRoot);
3910 }
3911 IShellFolder_Release(psfRoot);
3912 }
3913
3914 ILFree(pidlDrives);
3915}
3916
3917/***********************************************************************
3918 * FILEDLG95_LOOKIN_DrawItem
3919 *
3920 * WM_DRAWITEM message handler
3921 */
3923{
3925 COLORREF crHighLight = GetSysColor(COLOR_HIGHLIGHT);
3927 RECT rectText, rectIcon, lookin_rect;
3928 SHFILEINFOW sfi;
3929 HIMAGELIST ilItemImage;
3930 int iIndentation;
3932 LPSFOLDER tmpFolder;
3934 UINT icon_width, icon_height;
3936 int height;
3937
3938 TRACE("\n");
3939
3940 if(pDIStruct->itemID == -1)
3941 return 0;
3942
3943 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(pDIStruct->hwndItem,
3944 pDIStruct->itemID)))
3945 return 0;
3946
3947
3948 icon_width = GetSystemMetrics(SM_CXICON);
3949 icon_height = GetSystemMetrics(SM_CYICON);
3950 if (pDIStruct->rcItem.bottom - pDIStruct->rcItem.top < icon_height)
3951 {
3952 icon_width = GetSystemMetrics(SM_CXSMICON);
3953 icon_height = GetSystemMetrics(SM_CYSMICON);
3954 shgfi_flags |= SHGFI_SMALLICON;
3955 }
3956
3957 ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
3958 0, &sfi, sizeof (sfi), shgfi_flags );
3959
3960 /* Is this item selected ? */
3961 if(pDIStruct->itemState & ODS_SELECTED)
3962 {
3963 SetTextColor(pDIStruct->hDC,(0x00FFFFFF & ~(crText)));
3964 SetBkColor(pDIStruct->hDC,crHighLight);
3965 FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_HIGHLIGHT));
3966 }
3967 else
3968 {
3969 SetTextColor(pDIStruct->hDC,crText);
3970 SetBkColor(pDIStruct->hDC,crWin);
3971 FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_WINDOW));
3972 }
3973
3974 /* Do not indent item if drawing in the edit of the combo */
3975 if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
3976 iIndentation = 0;
3977 else
3978 iIndentation = tmpFolder->m_iIndent;
3979
3980 /* Draw text and icon */
3981
3982 /* Initialise the icon display area */
3983 rectIcon.left = pDIStruct->rcItem.left + 1 + icon_width/2 * iIndentation;
3984 rectIcon.top = (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - icon_height) / 2;
3985 rectIcon.right = rectIcon.left + icon_width + XTEXTOFFSET;
3986 rectIcon.bottom = (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + icon_height) / 2;
3987
3988 /* Initialise the text display area */
3989 GetTextMetricsW(pDIStruct->hDC, &tm);
3990 rectText.left = rectIcon.right;
3991 rectText.top =
3992 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
3993 rectText.right = pDIStruct->rcItem.right;
3994 rectText.bottom =
3995 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
3996
3997 /* Draw the icon from the image list */
3998 ImageList_Draw(ilItemImage,
3999 sfi.iIcon,
4000 pDIStruct->hDC,
4001 rectIcon.left,
4002 rectIcon.top,
4004
4005 /* Draw the associated text */
4006 TextOutW(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,lstrlenW(sfi.szDisplayName));
4007
4009 GetWindowRect(dialog->DlgInfos.hwndLookInCB, &lookin_rect);
4010 height = lookin_rect.bottom - lookin_rect.top;
4012
4013 return NOERROR;
4014}
4015
4016/***********************************************************************
4017 * FILEDLG95_LOOKIN_OnCommand
4018 *
4019 * LookIn combo box WM_COMMAND message handler
4020 * If the function succeeds, the return value is nonzero.
4021 */
4023{
4025
4026 TRACE("%p\n", fodInfos);
4027
4028 switch(wNotifyCode)
4029 {
4030 case CBN_SELENDOK:
4031 {
4032 LPSFOLDER tmpFolder;
4033 int iItem;
4034
4035 iItem = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCURSEL, 0, 0);
4036
4037 if( iItem == CB_ERR) return FALSE;
4038
4039 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
4040 iItem)))
4041 return FALSE;
4042
4043
4044 if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
4045 tmpFolder->pidlItem,
4046 SBSP_ABSOLUTE)))
4047 {
4048 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
4050 return TRUE;
4051 }
4052 break;
4053 }
4054
4055 }
4056 return FALSE;
4057}
4058
4059/***********************************************************************
4060 * FILEDLG95_LOOKIN_AddItem
4061 *
4062 * Adds an absolute pidl item to the lookin combo box
4063 * returns the index of the inserted item
4064 */
4065static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
4066{
4067 LPITEMIDLIST pidlNext;
4068 SHFILEINFOW sfi;
4069 SFOLDER *tmpFolder;
4070 LookInInfos *liInfos;
4071
4072 TRACE("%p, %p, %d\n", hwnd, pidl, iInsertId);
4073
4074 if(!pidl)
4075 return -1;
4076
4077 if(!(liInfos = GetPropA(hwnd,LookInInfosStr)))
4078 return -1;
4079
4080 tmpFolder = heap_alloc_zero(sizeof(*tmpFolder));
4081 tmpFolder->m_iIndent = 0;
4082
4083 /* Calculate the indentation of the item in the lookin*/
4084 pidlNext = pidl;
4085 while ((pidlNext = ILGetNext(pidlNext)))
4086 {
4087 tmpFolder->m_iIndent++;
4088 }
4089
4090 tmpFolder->pidlItem = ILClone(pidl);
4091
4092 if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
4093 liInfos->iMaxIndentation = tmpFolder->m_iIndent;
4094
4095 sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
4096 SHGetFileInfoW((LPCWSTR)pidl,
4097 0,
4098 &sfi,
4099 sizeof(sfi),
4101
4102 TRACE("-- Add %s attr=0x%08lx\n", debugstr_w(sfi.szDisplayName), sfi.dwAttributes);
4103
4104 if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
4105 {
4106 int iItemID;
4107
4108 TRACE("-- Add %s at %u\n", debugstr_w(sfi.szDisplayName), tmpFolder->m_iIndent);
4109
4110 /* Add the item at the end of the list */
4111 if(iInsertId < 0)
4112 {
4113 iItemID = SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)sfi.szDisplayName);
4114 }
4115 /* Insert the item at the iInsertId position*/
4116 else
4117 {
4118 iItemID = SendMessageW(hwnd, CB_INSERTSTRING, iInsertId, (LPARAM)sfi.szDisplayName);
4119 }
4120
4121 SendMessageW(hwnd, CB_SETITEMDATA, iItemID, (LPARAM)tmpFolder);
4122 return iItemID;
4123 }
4124
4125 ILFree( tmpFolder->pidlItem );
4126 heap_free( tmpFolder );
4127 return -1;
4128
4129}
4130
4131/***********************************************************************
4132 * FILEDLG95_LOOKIN_InsertItemAfterParent
4133 *
4134 * Insert an item below its parent
4135 */
4137{
4138
4139 LPITEMIDLIST pidlParent = GetParentPidl(pidl);
4140 int iParentPos;
4141
4142 TRACE("\n");
4143
4144 if (pidl == pidlParent)
4145 return -1;
4146
4147 iParentPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidlParent,SEARCH_PIDL);
4148
4149 if(iParentPos < 0)
4150 {
4151 iParentPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidlParent);
4152 }
4153
4154 ILFree(pidlParent);
4155
4156 return FILEDLG95_LOOKIN_AddItem(hwnd,pidl,iParentPos + 1);
4157}
4158
4159/***********************************************************************
4160 * FILEDLG95_LOOKIN_SelectItem
4161 *
4162 * Adds an absolute pidl item to the lookin combo box
4163 * returns the index of the inserted item
4164 */
4166{
4167 int iItemPos;
4168 LookInInfos *liInfos;
4169
4170 TRACE("%p, %p\n", hwnd, pidl);
4171
4173
4174 liInfos = GetPropA(hwnd,LookInInfosStr);
4175
4176 if(iItemPos < 0)
4177 {
4180 }
4181
4182 else
4183 {
4184 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
4185 while(liInfos->iMaxIndentation > tmpFolder->m_iIndent)
4186 {
4187 int iRemovedItem;
4188
4189 if(-1 == (iRemovedItem = FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd)))
4190 break;
4191 if(iRemovedItem < iItemPos)
4192 iItemPos--;
4193 }
4194 }
4195
4196 SendMessageW(hwnd, CB_SETCURSEL, iItemPos, 0);
4197 liInfos->uSelectedItem = iItemPos;
4198
4199 return 0;
4200
4201}
4202
4203/***********************************************************************
4204 * FILEDLG95_LOOKIN_RemoveMostExpandedItem
4205 *
4206 * Remove the item with an expansion level over iExpansionLevel
4207 */
4209{
4210 int iItemPos;
4212
4213 TRACE("\n");
4214
4215 if(liInfos->iMaxIndentation <= 2)
4216 return -1;
4217
4218 if((iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,liInfos->iMaxIndentation,SEARCH_EXP)) >=0)
4219 {
4220 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
4221 ILFree(tmpFolder->pidlItem);
4222 heap_free(tmpFolder);
4223 SendMessageW(hwnd, CB_DELETESTRING, iItemPos, 0);
4224 liInfos->iMaxIndentation--;
4225
4226 return iItemPos;
4227 }
4228
4229 return -1;
4230}
4231
4232/***********************************************************************
4233 * FILEDLG95_LOOKIN_SearchItem
4234 *
4235 * Search for pidl in the lookin combo box
4236 * returns the index of the found item
4237 */
4238static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd,WPARAM searchArg,int iSearchMethod)
4239{
4240 int i = 0;
4241 int iCount;
4242
4243 iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
4244
4245 TRACE("0x%08Ix 0x%x\n",searchArg, iSearchMethod);
4246
4247 if (iCount != CB_ERR)
4248 {
4249 for(;i<iCount;i++)
4250 {
4251 LPSFOLDER tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,i);
4252
4253 if (iSearchMethod == SEARCH_PIDL && ILIsEqual((LPITEMIDLIST)searchArg, tmpFolder->pidlItem))
4254 return i;
4255 if(iSearchMethod == SEARCH_EXP && tmpFolder->m_iIndent == (int)searchArg)
4256 return i;
4257 }
4258 }
4259
4260 return -1;
4261}
4262
4263/***********************************************************************
4264 * FILEDLG95_LOOKIN_Clean
4265 *
4266 * Clean the memory used by the lookin combo box
4267 */
4269{
4271 LookInInfos *liInfos = GetPropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
4272 int iPos, iCount;
4273
4274 iCount = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCOUNT, 0, 0);
4275
4276 TRACE("\n");
4277
4278 /* Delete each string of the combo and their associated data */
4279 if (iCount != CB_ERR)
4280 {
4281 for(iPos = iCount-1;iPos>=0;iPos--)
4282 {
4283 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos);
4284 ILFree(tmpFolder->pidlItem);
4285 heap_free(tmpFolder);
4286 SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_DELETESTRING, iPos, 0);
4287 }
4288 }
4289
4290 /* LookInInfos structure */
4291 heap_free(liInfos);
4292 RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
4293}
4294
4295/***********************************************************************
4296 * get_def_format
4297 *
4298 * Fill the FORMATETC used in the shell id list
4299 */
4300static FORMATETC get_def_format(void)
4301{
4302 static CLIPFORMAT cfFormat;
4303 FORMATETC formatetc;
4304
4305 if (!cfFormat) cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLISTA);
4306 formatetc.cfFormat = cfFormat;
4307 formatetc.ptd = 0;
4308 formatetc.dwAspect = DVASPECT_CONTENT;
4309 formatetc.lindex = -1;
4310 formatetc.tymed = TYMED_HGLOBAL;
4311 return formatetc;
4312}
4313
4314/***********************************************************************
4315 * FILEDLG95_FILENAME_FillFromSelection
4316 *
4317 * fills the edit box from the cached DataObject
4318 */
4320{
4322 LPITEMIDLIST pidl;
4323 LPWSTR lpstrAllFiles, lpstrTmp;
4324 UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength;
4325 STGMEDIUM medium;
4326 LPIDA cida;
4327 FORMATETC formatetc = get_def_format();
4328
4329 TRACE("\n");
4330
4331 if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, &medium)))
4332 return;
4333
4334 cida = GlobalLock(medium.hGlobal);
4335 nFileSelected = cida->cidl;
4336
4337 /* Allocate a buffer */
4338 nAllFilesMaxLength = MAX_PATH + 3;
4339 lpstrAllFiles = heap_alloc_zero(nAllFilesMaxLength * sizeof(WCHAR));
4340 if (!lpstrAllFiles)
4341 goto ret;
4342
4343 /* Loop through the selection, handle only files (not folders) */
4344 for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++)
4345 {
4346 pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]);
4347 if (pidl)
4348 {
4349 if (!IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl))
4350 {
4351 if (nAllFilesLength + MAX_PATH + 3 > nAllFilesMaxLength)
4352 {
4353 nAllFilesMaxLength *= 2;
4354 lpstrTmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpstrAllFiles, nAllFilesMaxLength * sizeof(WCHAR));
4355 if (!lpstrTmp)
4356 goto ret;
4357 lpstrAllFiles = lpstrTmp;
4358 }
4359 nFiles += 1;
4360 lpstrAllFiles[nAllFilesLength++] = '"';
4361 GetName(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, lpstrAllFiles + nAllFilesLength);
4362 nThisFileLength = lstrlenW(lpstrAllFiles + nAllFilesLength);
4363 nAllFilesLength += nThisFileLength;
4364 lpstrAllFiles[nAllFilesLength++] = '"';
4365 lpstrAllFiles[nAllFilesLength++] = ' ';
4366 }
4367 }
4368 }
4369
4370 if (nFiles != 0)
4371 {
4372 /* If there's only one file, use the name as-is without quotes */
4373 lpstrTmp = lpstrAllFiles;
4374 if (nFiles == 1)
4375 {
4376 lpstrTmp += 1;
4377 lpstrTmp[nThisFileLength] = 0;
4378 }
4379 SetWindowTextW(fodInfos->DlgInfos.hwndFileName, lpstrTmp);
4380 /* Select the file name like Windows does */
4381 if (filename_is_edit(fodInfos))
4382 SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
4383 }
4384
4385ret:
4386 heap_free(lpstrAllFiles);
4388}
4389
4390
4391/* copied from shell32 to avoid linking to it
4392 * Although shell32 is already linked the behaviour of exported StrRetToStrN
4393 * is dependent on whether emulated OS is unicode or not.
4394 */
4396{
4397 switch (src->uType)
4398 {
4399 case STRRET_WSTR:
4400 lstrcpynW(dest, src->pOleStr, len);
4401 CoTaskMemFree(src->pOleStr);
4402 break;
4403
4404 case STRRET_CSTR:
4405 if (!MultiByteToWideChar( CP_ACP, 0, src->cStr, -1, dest, len ) && len)
4406 dest[len-1] = 0;
4407 break;
4408
4409 case STRRET_OFFSET:
4410 if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->uOffset, -1, dest, len ) && len)
4411 dest[len-1] = 0;
4412 break;
4413
4414 default:
4415 FIXME("unknown type %x!\n", src->uType);
4416 if (len) *dest = '\0';
4417 return E_FAIL;
4418 }
4419 return S_OK;
4420}
4421
4422/***********************************************************************
4423 * FILEDLG95_FILENAME_GetFileNames
4424 *
4425 * Copies the filenames to a delimited string list.
4426 */
4427static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed)
4428{
4430 UINT nFileCount = 0; /* number of files */
4431 UINT nStrLen = 0; /* length of string in edit control */
4432 LPWSTR lpstrEdit; /* buffer for string from edit control */
4433
4434 TRACE("\n");
4435
4436 /* get the filenames from the filename control */
4437 nStrLen = GetWindowTextLengthW( fodInfos->DlgInfos.hwndFileName );
4438 lpstrEdit = heap_alloc( (nStrLen+1)*sizeof(WCHAR) );
4439 GetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrEdit, nStrLen+1);
4440
4441 TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit));
4442
4443 nFileCount = COMDLG32_SplitFileNames(lpstrEdit, nStrLen, lpstrFileList, sizeUsed);
4444 heap_free(lpstrEdit);
4445 return nFileCount;
4446}
4447
4448/*
4449 * DATAOBJECT Helper functions
4450 */
4451
4452/***********************************************************************
4453 * COMCTL32_ReleaseStgMedium
4454 *
4455 * like ReleaseStgMedium from ole32
4456 */
4457static void COMCTL32_ReleaseStgMedium (STGMEDIUM medium)
4458{
4459 if(medium.pUnkForRelease)
4460 {
4461 IUnknown_Release(medium.pUnkForRelease);
4462 }
4463 else
4464 {
4465 GlobalUnlock(medium.hGlobal);
4466 GlobalFree(medium.hGlobal);
4467 }
4468}
4469
4470/***********************************************************************
4471 * GetPidlFromDataObject
4472 *
4473 * Return pidl(s) by number from the cached DataObject
4474 *
4475 * nPidlIndex=0 gets the fully qualified root path
4476 */
4478{
4479
4480 STGMEDIUM medium;
4481 FORMATETC formatetc = get_def_format();
4482 LPITEMIDLIST pidl = NULL;
4483
4484 TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
4485
4486 if (!doSelected)
4487 return NULL;
4488
4489 /* Get the pidls from IDataObject */
4490 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
4491 {
4492 LPIDA cida = GlobalLock(medium.hGlobal);
4493 if(nPidlIndex <= cida->cidl)
4494 {
4495 pidl = ILClone((LPITEMIDLIST)(&((LPBYTE)cida)[cida->aoffset[nPidlIndex]]));
4496 }
4498 }
4499 return pidl;
4500}
4501
4502/***********************************************************************
4503 * GetNumSelected
4504 *
4505 * Return the number of selected items in the DataObject.
4506 *
4507*/
4508static UINT GetNumSelected( IDataObject *doSelected )
4509{
4510 UINT retVal = 0;
4511 STGMEDIUM medium;
4512 FORMATETC formatetc = get_def_format();
4513
4514 TRACE("sv=%p\n", doSelected);
4515
4516 if (!doSelected) return 0;
4517
4518 /* Get the pidls from IDataObject */
4519 if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
4520 {
4521 LPIDA cida = GlobalLock(medium.hGlobal);
4522 retVal = cida->cidl;
4524 return retVal;
4525 }
4526 return 0;
4527}
4528
4529/*
4530 * TOOLS
4531 */
4532
4533/***********************************************************************
4534 * GetName
4535 *
4536 * Get the pidl's display name (relative to folder) and
4537 * put it in lpstrFileName.
4538 *
4539 * Return NOERROR on success,
4540 * E_FAIL otherwise
4541 */
4542
4543static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPWSTR lpstrFileName)
4544{
4545 STRRET str;
4546 HRESULT hRes;
4547
4548 TRACE("sf=%p pidl=%p\n", lpsf, pidl);
4549
4550 if(!lpsf)
4551 {
4552 SHGetDesktopFolder(&lpsf);
4553 hRes = GetName(lpsf,pidl,dwFlags,lpstrFileName);
4554 IShellFolder_Release(lpsf);
4555 return hRes;
4556 }
4557
4558 /* Get the display name of the pidl relative to the folder */
4559 if (SUCCEEDED(hRes = IShellFolder_GetDisplayNameOf(lpsf, pidl, dwFlags, &str)))
4560 {
4561 return COMDLG32_StrRetToStrNW(lpstrFileName, MAX_PATH, &str, pidl);
4562 }
4563 return E_FAIL;
4564}
4565
4566/***********************************************************************
4567 * GetShellFolderFromPidl
4568 *
4569 * pidlRel is the item pidl relative
4570 * Return the IShellFolder of the absolute pidl
4571 */
4573{
4574 IShellFolder *psf = NULL,*psfParent;
4575
4576 TRACE("%p\n", pidlAbs);
4577
4578 if(SUCCEEDED(SHGetDesktopFolder(&psfParent)))
4579 {
4580 psf = psfParent;
4581 if(pidlAbs && pidlAbs->mkid.cb)
4582 {
4583 if(SUCCEEDED(IShellFolder_BindToObject(psfParent, pidlAbs, NULL, &IID_IShellFolder, (LPVOID*)&psf)))
4584 {
4585 IShellFolder_Release(psfParent);
4586 return psf;
4587 }
4588 }
4589 /* return the desktop */
4590 return psfParent;
4591 }
4592 return NULL;
4593}
4594
4595/***********************************************************************
4596 * GetParentPidl
4597 *
4598 * Return the LPITEMIDLIST to the parent of the pidl in the list
4599 */
4601{
4602 LPITEMIDLIST pidlParent;
4603
4604 TRACE("%p\n", pidl);
4605
4606 pidlParent = ILClone(pidl);
4607 ILRemoveLastID(pidlParent);
4608
4609 return pidlParent;
4610}
4611
4612/***********************************************************************
4613 * GetPidlFromName
4614 *
4615 * returns the pidl of the file name relative to folder
4616 * NULL if an error occurred
4617 */
4619{
4620 LPITEMIDLIST pidl = NULL;
4621 ULONG ulEaten;
4622
4623 TRACE("sf=%p file=%s\n", lpsf, debugstr_w(lpcstrFileName));
4624
4625 if(!lpcstrFileName) return NULL;
4626 if(!*lpcstrFileName) return NULL;
4627
4628 if(!lpsf)
4629 {
4630 if (SUCCEEDED(SHGetDesktopFolder(&lpsf))) {
4631 IShellFolder_ParseDisplayName(lpsf, 0, NULL, lpcstrFileName, &ulEaten, &pidl, NULL);
4632 IShellFolder_Release(lpsf);
4633 }
4634 }
4635 else
4636 {
4637 IShellFolder_ParseDisplayName(lpsf, 0, NULL, lpcstrFileName, &ulEaten, &pidl, NULL);
4638 }
4639 return pidl;
4640}
4641
4642/*
4643*/
4644static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl)
4645{
4646#ifdef __REACTOS__
4647 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR;
4648#else
4649 ULONG uAttr = SFGAO_FOLDER | SFGAO_HASSUBFOLDER;
4650#endif
4651 HRESULT ret;
4652
4653 TRACE("%p, %p\n", psf, pidl);
4654
4655 ret = IShellFolder_GetAttributesOf( psf, 1, &pidl, &uAttr );
4656
4657 TRACE("-- 0x%08lx 0x%08lx\n", uAttr, ret);
4658 /* see documentation shell 4.1*/
4659#ifdef __REACTOS__
4660 return (uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER)) && (uAttr & SFGAO_FILESYSANCESTOR);
4661#else
4662 return uAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER);
4663#endif
4664}
4665
4666/***********************************************************************
4667 * BrowseSelectedFolder
4668 */
4670{
4672 BOOL bBrowseSelFolder = FALSE;
4673
4674 TRACE("\n");
4675
4676 if (GetNumSelected(fodInfos->Shell.FOIDataObject) == 1)
4677 {
4678 LPITEMIDLIST pidlSelection;
4679
4680 /* get the file selected */
4681 pidlSelection = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, 1);
4682 if (IsPidlFolder (fodInfos->Shell.FOIShellFolder, pidlSelection))
4683 {
4684 if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser,
4685 pidlSelection, SBSP_RELATIVE ) ) )
4686 {
4687 WCHAR buf[64];
4690 }
4691 bBrowseSelFolder = TRUE;
4692 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
4694 }
4695 ILFree( pidlSelection );
4696 }
4697
4698 return bBrowseSelFolder;
4699}
4700
4702{
4704 (size == sizeof( OPENFILENAMEW ));
4705}
4706
4708{
4710 !(flags & OFN_EXPLORER));
4711}
4712
4713/* ------------------ APIs ---------------------- */
4714
4715/***********************************************************************
4716 * GetOpenFileNameA (COMDLG32.@)
4717 *
4718 * Creates a dialog box for the user to select a file to open.
4719 *
4720 * RETURNS
4721 * TRUE on success: user enters a valid file
4722 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
4723 *
4724 */
4726{
4727 TRACE("flags 0x%08lx\n", ofn->Flags);
4728
4730 {
4732 return FALSE;
4733 }
4734
4735 /* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
4738
4739 if (is_win16_looks(ofn->Flags))
4741 else
4742 {
4744
4747 }
4748}
4749
4750/***********************************************************************
4751 * GetOpenFileNameW (COMDLG32.@)
4752 *
4753 * Creates a dialog box for the user to select a file to open.
4754 *
4755 * RETURNS
4756 * TRUE on success: user enters a valid file
4757 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
4758 *
4759 */
4761{
4762 TRACE("flags 0x%08lx\n", ofn->Flags);
4763
4765 {
4767 return FALSE;
4768 }
4769
4770 /* OFN_FILEMUSTEXIST implies OFN_PATHMUSTEXIST */
4773
4774 if (is_win16_looks(ofn->Flags))
4776 else
4777 {
4779
4782 }
4783}
4784
4785
4786/***********************************************************************
4787 * GetSaveFileNameA (COMDLG32.@)
4788 *
4789 * Creates a dialog box for the user to select a file to save.
4790 *
4791 * RETURNS
4792 * TRUE on success: user enters a valid file
4793 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
4794 *
4795 */
4797{
4799 {
4801 return FALSE;
4802 }
4803
4804 if (is_win16_looks(ofn->Flags))
4806 else
4807 {
4809
4812 }
4813}
4814
4815/***********************************************************************
4816 * GetSaveFileNameW (COMDLG32.@)
4817 *
4818 * Creates a dialog box for the user to select a file to save.
4819 *
4820 * RETURNS
4821 * TRUE on success: user enters a valid file
4822 * FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
4823 *
4824 */
4826 LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
4827{
4829 {
4831 return FALSE;
4832 }
4833
4834 if (is_win16_looks(ofn->Flags))
4836 else
4837 {
4839
4842 }
4843}
4844
4845/***********************************************************************
4846 * GetFileTitleA (COMDLG32.@)
4847 *
4848 * See GetFileTitleW.
4849 */
4851{
4852 int ret;
4853 UNICODE_STRING strWFile;
4854 LPWSTR lpWTitle;
4855
4856 RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile);
4857 lpWTitle = heap_alloc(cbBuf * sizeof(WCHAR));
4858 ret = GetFileTitleW(strWFile.Buffer, lpWTitle, cbBuf);
4859 if (!ret) WideCharToMultiByte( CP_ACP, 0, lpWTitle, -1, lpTitle, cbBuf, NULL, NULL );
4860 RtlFreeUnicodeString( &strWFile );
4861 heap_free( lpWTitle );
4862 return ret;
4863}
4864
4865
4866/***********************************************************************
4867 * GetFileTitleW (COMDLG32.@)
4868 *
4869 * Get the name of a file.
4870 *
4871 * PARAMS
4872 * lpFile [I] name and location of file
4873 * lpTitle [O] returned file name
4874 * cbBuf [I] buffer size of lpTitle
4875 *
4876 * RETURNS
4877 * Success: zero
4878 * Failure: negative number.
4879 */
4881{
4882 int i, len;
4883 TRACE("(%p %p %d);\n", lpFile, lpTitle, cbBuf);
4884
4885 if(lpFile == NULL || lpTitle == NULL)
4886 return -1;
4887
4888 len = lstrlenW(lpFile);
4889
4890 if (len == 0)
4891 return -1;
4892
4893 if(wcspbrk(lpFile, L"*[]"))
4894 return -1;
4895
4896 len--;
4897
4898 if(lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
4899 return -1;
4900
4901 for(i = len; i >= 0; i--)
4902 {
4903 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
4904 {
4905 i++;
4906 break;
4907 }
4908 }
4909
4910 if(i == -1)
4911 i++;
4912
4913 TRACE("---> %s\n", debugstr_w(&lpFile[i]));
4914
4915 len = lstrlenW(lpFile+i)+1;
4916 if(cbBuf < len)
4917 return len;
4918
4919 lstrcpyW(lpTitle, &lpFile[i]);
4920 return 0;
4921}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
static USHORT PathLength
UINT cchMax
#define __inline
Definition: _wctype.cpp:15
#define REG_SZ
Definition: layer.c:22
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static const WCHAR nameW[]
Definition: main.c:49
#define index(s, c)
Definition: various.h:29
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define EXTERN_C
Definition: basetyps.h:12
#define RegCloseKey(hKey)
Definition: registry.h:49
HIMAGELIST himl
#define FNERR_BUFFERTOOSMALL
Definition: cderr.h:37
#define CDERR_LOADRESFAILURE
Definition: cderr.h:12
#define CDERR_FINDRESFAILURE
Definition: cderr.h:11
#define CDERR_STRUCTSIZE
Definition: cderr.h:6
BOOL GetFileName31A(OPENFILENAMEA *lpofn, UINT dlgType)
Definition: filedlg31.c:1145
#define ONOPEN_OPEN
Definition: cdlg.h:196
#define ONOPEN_BROWSE
Definition: cdlg.h:195
void COMDLG32_SetCommDlgExtendedError(DWORD err)
Definition: cdlg32.c:124
#define IDS_SAVE_AS
Definition: cdlg.h:159
HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
#define IDS_SAVE_BUTTON
Definition: cdlg.h:156
#define IDS_SAVE_IN
Definition: cdlg.h:157
#define ONOPEN_SEARCH
Definition: cdlg.h:197
BOOL GetFileName31W(OPENFILENAMEW *lpofn, UINT dlgType)
Definition: filedlg31.c:1170
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
HWND hwndEdit
Definition: combotst.c:65
LPARAM lParam
Definition: combotst.c:139
struct tagMRUINFOW MRUINFOW
struct tagMRUINFOW * LPMRUINFOW
INT(CALLBACK * MRUBinaryCmpFn)(LPCVOID lhs, LPCVOID rhs, DWORD length)
INT(CALLBACK * MRUStringCmpFnW)(LPCWSTR lhs, LPCWSTR rhs)
#define MRU_STRING
EXTERN_C HRESULT DoInitAutoCompleteWithCWD(FileOpenDlgInfos *pInfo, HWND hwndEdit)
Definition: autocomp.cpp:12
EXTERN_C HRESULT DoReleaseAutoCompleteWithCWD(FileOpenDlgInfos *pInfo)
Definition: autocomp.cpp:94
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:904
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define OFN_EXTENSIONDIFFERENT
Definition: commdlg.h:105
#define OFN_CREATEPROMPT
Definition: commdlg.h:97
#define CDM_SETCONTROLTEXT
Definition: commdlg.h:47
#define OFN_EXPLORER
Definition: commdlg.h:104
#define CDM_GETSPEC
Definition: commdlg.h:43
#define CDN_INITDONE
Definition: commdlg.h:33
#define OFN_ENABLETEMPLATEHANDLE
Definition: commdlg.h:103
#define HELPMSGSTRINGW
Definition: commdlg.h:27
#define FILEOKSTRINGW
Definition: commdlg.h:24
#define CDN_SELCHANGE
Definition: commdlg.h:34
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
struct tagOFNA * LPOPENFILENAMEA
#define OFN_NOCHANGEDIR
Definition: commdlg.h:109
#define CDM_FIRST
Definition: commdlg.h:41
#define SHAREVISTRINGW
Definition: commdlg.h:23
#define OPENFILENAME_SIZE_VERSION_400W
Definition: commdlg.h:397
#define CDM_GETFOLDERIDLIST
Definition: commdlg.h:46
#define OFN_NOVALIDATE
Definition: commdlg.h:115
#define CDM_LAST
Definition: commdlg.h:42
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_ENABLESIZING
Definition: commdlg.h:101
#define OFN_READONLY
Definition: commdlg.h:118
#define CDN_FILEOK
Definition: commdlg.h:38
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OPEN_DIALOG
Definition: commdlg.h:13
#define CDM_SETDEFEXT
Definition: commdlg.h:49
#define CDM_HIDECONTROL
Definition: commdlg.h:48
#define CDN_FOLDERCHANGE
Definition: commdlg.h:35
#define CDM_GETFILEPATH
Definition: commdlg.h:44
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
#define OFN_EX_NOPLACESBAR
Definition: commdlg.h:121
#define SAVE_DIALOG
Definition: commdlg.h:12
#define CDN_TYPECHANGE
Definition: commdlg.h:39
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define CDM_GETFOLDERPATH
Definition: commdlg.h:45
struct tagOFNW OPENFILENAMEW
#define LBSELCHSTRINGW
Definition: commdlg.h:22
#define OFN_SHOWHELP
Definition: commdlg.h:120
#define OFN_ALLOWMULTISELECT
Definition: commdlg.h:96
TCHAR lpTitle[80]
Definition: ctm.c:69
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:171
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define DLGPROC
Definition: maze.c:62
#define ERROR_SUCCESS
Definition: deptool.c:10
#define cmb1
Definition: dlgs.h:53
#define pshHelp
Definition: dlgs.h:132
#define edt1
Definition: dlgs.h:70
#define cmb13
Definition: dlgs.h:65
#define stc32
Definition: dlgs.h:196
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
BOOL WINAPI ImageList_Draw(HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
Definition: imagelist.c:1246
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:941
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:814
static UINT GetNumSelected(IDataObject *doSelected)
Definition: filedlg.c:4508
int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed)
Definition: filedlg.c:780
struct SFolder SFOLDER
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl)
Definition: filedlg.c:4600
void FILEDLG95_FILENAME_FillFromSelection(HWND hwnd)
Definition: filedlg.c:4319
static void ArrangeCtrlPositions(HWND hwndChildDlg, HWND hwndParentDlg, BOOL hide_help)
Definition: filedlg.c:828
#define SEARCH_PIDL
Definition: filedlg.c:193
#define TBPLACES_CMDID_PLACE0
Definition: filedlg.c:200
static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
Definition: filedlg.c:3793
static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath)
Definition: filedlg.c:719
void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile)
Definition: filedlg.c:740
#define TBPLACES_CMDID_PLACE1
Definition: filedlg.c:201
static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
Definition: filedlg.c:4268
#define UNIMPLEMENTED_FLAGS
Definition: filedlg.c:86
static WCHAR * heap_strdupAtoW(const char *str)
Definition: filedlg.c:508
#define SEARCH_EXP
Definition: filedlg.c:194
static void FILEDLG95_Clean(HWND hwnd)
Definition: filedlg.c:2169
static LRESULT FILEDLG95_SHELL_Init(HWND hwnd)
Definition: filedlg.c:3495
int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction)
Definition: filedlg.c:2947
#define TBPLACES_CMDID_PLACE3
Definition: filedlg.c:203
static SIZE MemDialogSize
Definition: filedlg.c:216
static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl, DWORD dwFlags, LPWSTR lpstrFileName)
Definition: filedlg.c:4543
static int FILEDLG95_FILENAME_GetFileNames(HWND hwnd, LPWSTR *lpstrFileList, UINT *sizeUsed)
Definition: filedlg.c:4427
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb)
Definition: filedlg.c:3530
static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result)
Definition: filedlg.c:1103
static LRESULT FILEDLG95_ResizeControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: filedlg.c:2077
static LRESULT FILEDLG95_LOOKIN_DrawItem(HWND hwnd, LPDRAWITEMSTRUCT pDIStruct)
Definition: filedlg.c:3922
static LRESULT FILEDLG95_OnWMSize(HWND hwnd, WPARAM wParam)
Definition: filedlg.c:1277
static void FILEDLG95_SHELL_Clean(HWND hwnd)
Definition: filedlg.c:3582
static void filedlg_browse_to_pidl(const FileOpenDlgInfos *info, LPITEMIDLIST pidl)
Definition: filedlg.c:2180
void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
Definition: filedlg.c:2846
static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
Definition: filedlg.c:430
#define TBPLACES_CMDID_PLACE4
Definition: filedlg.c:204
static BOOL BrowseSelectedFolder(HWND hwnd)
Definition: filedlg.c:4669
static WCHAR FILEDLG95_MRU_get_slot(LPCWSTR module_name, LPWSTR stored_path, PHKEY hkey_ret)
Definition: filedlg.c:2442
short WINAPI GetFileTitleW(LPCWSTR lpFile, LPWSTR lpTitle, WORD cbBuf)
Definition: filedlg.c:4880
static BOOL FILEDLG95_SendFileOK(HWND hwnd, FileOpenDlgInfos *fodInfos)
Definition: filedlg.c:2293
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
Definition: filedlg.c:3561
#define TBPLACES_CMDID_PLACE2
Definition: filedlg.c:202
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4760
static void FILEDLG95_MRU_load_filename(LPWSTR stored_path)
Definition: filedlg.c:2605
static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
Definition: filedlg.c:4208
#define LISTEND
Definition: filedlg.c:190
static void filedlg_collect_places_pidls(FileOpenDlgInfos *fodInfos)
Definition: filedlg.c:365
#define WM_GETISHELLBROWSER
Definition: filedlg.c:198
static BOOL get_config_key_dword(HKEY hkey, const WCHAR *name, DWORD *value)
Definition: filedlg.c:309
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd)
Definition: filedlg.c:2272
static FORMATETC get_def_format(void)
Definition: filedlg.c:4300
short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf)
Definition: filedlg.c:4850
FileOpenDlgInfos * get_filedlg_infoptr(HWND hwnd)
Definition: filedlg.c:218
static int FILEDLG95_LOOKIN_AddItem(HWND hwnd, LPITEMIDLIST pidl, int iInsertId)
Definition: filedlg.c:4065
static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd, WPARAM searchArg, int iSearchMethod)
Definition: filedlg.c:4238
static BOOL valid_struct_size(DWORD size)
Definition: filedlg.c:4701
static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
Definition: filedlg.c:3837
IShellFolder * GetShellFolderFromPidl(LPITEMIDLIST pidlAbs)
Definition: filedlg.c:4572
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedlg.c:1145
static BOOL FILEDLG95_unixfs_is_rooted_at_desktop(void)
Definition: filedlg.c:3825
static LRESULT FILEDLG95_InitControls(HWND hwnd)
Definition: filedlg.c:1661
static LRESULT FILEDLG95_FillControls(HWND hwnd, WPARAM wParam, LPARAM lParam)
Definition: filedlg.c:2132
static BOOL is_places_bar_enabled(const FileOpenDlgInfos *fodInfos)
Definition: filedlg.c:344
static HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
Definition: filedlg.c:982
static BOOL IsPidlFolder(LPSHELLFOLDER psf, LPCITEMIDLIST pidl)
Definition: filedlg.c:4644
LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
Definition: filedlg.c:1074
static BOOL filename_is_edit(const FileOpenDlgInfos *info)
Definition: filedlg.c:1650
BOOL WINAPI GetSaveFileNameA(OPENFILENAMEA *ofn)
Definition: filedlg.c:4796
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
Definition: filedlg.c:4022
static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
Definition: filedlg.c:574
BOOL WINAPI GetOpenFileNameA(OPENFILENAMEA *ofn)
Definition: filedlg.c:4725
static const char LookInInfosStr[]
Definition: filedlg.c:215
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
Definition: filedlg.c:3608
static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
Definition: filedlg.c:2330
static HRESULT COMDLG32_StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: filedlg.c:4395
static LPITEMIDLIST GetPidlFromName(IShellFolder *psf, LPWSTR lpcstrFileName)
Definition: filedlg.c:4618
static BOOL get_config_key_as_dword(HKEY hkey, const WCHAR *name, DWORD *value)
Definition: filedlg.c:295
static INT_PTR CALLBACK FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedlg.c:973
static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
Definition: filedlg.c:2515
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam)
Definition: filedlg.c:2194
static INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedlg.c:1432
static BOOL filedialog_is_readonly_hidden(const FileOpenDlgInfos *info)
Definition: filedlg.c:228
#define XTEXTOFFSET
Definition: filedlg.c:187
static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
Definition: filedlg.c:640
struct tagLookInInfo LookInInfos
LPITEMIDLIST GetPidlFromDataObject(IDataObject *doSelected, UINT nPidlIndex)
Definition: filedlg.c:4477
static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
Definition: filedlg.c:523
static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd, LPITEMIDLIST pidl)
Definition: filedlg.c:4136
BOOL WINAPI GetSaveFileNameW(LPOPENFILENAMEW ofn)
Definition: filedlg.c:4825
static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd, LPCWSTR lpstrExt)
Definition: filedlg.c:3769
static BOOL is_dialog_hooked(const FileOpenDlgInfos *info)
Definition: filedlg.c:223
int FILEDLG95_LOOKIN_SelectItem(HWND hwnd, LPITEMIDLIST pidl)
Definition: filedlg.c:4165
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
Definition: filedlg.c:3724
static BOOL is_win16_looks(DWORD flags)
Definition: filedlg.c:4707
static LRESULT FILEDLG95_OnWMGetMMI(HWND hwnd, LPMINMAXINFO mmiptr)
Definition: filedlg.c:1256
static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium)
Definition: filedlg.c:4457
static BOOL FILEDLG95_OnOpen(HWND hwnd)
Definition: filedlg.c:3092
struct SFolder * LPSFOLDER
static BOOL get_config_key_string(HKEY hkey, const WCHAR *name, WCHAR **value)
Definition: filedlg.c:323
#define CBGetItemDataPtr(hwnd, iItemId)
Definition: filedlg.c:212
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define wcsrchr
Definition: compat.h:16
#define CP_ACP
Definition: compat.h:109
#define lstrcpynA
Definition: compat.h:751
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapReAlloc
Definition: compat.h:734
HANDLE HWND
Definition: compat.h:19
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define wcsicmp
Definition: compat.h:15
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
static const WCHAR *const ext[]
Definition: module.c:53
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI SetCurrentDirectoryW(IN LPCWSTR lpPathName)
Definition: path.c:2267
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1164
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
LPSTR WINAPI PathFindExtensionA(const char *path)
Definition: path.c:1229
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:1786
WCHAR *WINAPI PathFindFileNameW(const WCHAR *path)
Definition: path.c:1677
BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
Definition: path.c:1121
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1250
BOOL WINAPI PathIsRelativeW(const WCHAR *path)
Definition: path.c:1006
WCHAR *WINAPI PathSkipRootW(const WCHAR *path)
Definition: path.c:2269
BOOL WINAPI PathFileExistsW(const WCHAR *path)
Definition: path.c:2583
char *WINAPI PathFindFileNameA(const char *path)
Definition: path.c:1660
WCHAR *WINAPI PathFindNextComponentW(const WCHAR *path)
Definition: path.c:2224
LPWSTR WINAPI CharLowerW(WCHAR *str)
Definition: string.c:1136
WCHAR *WINAPI StrDupW(const WCHAR *str)
Definition: string.c:317
_ACRTIMP wchar_t *__cdecl wcspbrk(const wchar_t *, const wchar_t *)
Definition: wcs.c:2021
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:162
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:218
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3385
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2717
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:669
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:248
#define IShellFolder_ParseDisplayName
Definition: utils.cpp:14
#define IShellFolder_GetDisplayNameOf
Definition: utils.cpp:13
#define swprintf
Definition: precomp.h:40
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
#define IDS_INVALID_FILENAME_TITLE
#define IDS_PATHNOTEXISTING
#define IDC_TOOLBARPLACES
#define IDS_FILENOTEXISTING
#define IDS_CREATEFILE
#define IDC_LOOKINSTATIC
#define IDS_LISTVIEW
#define IDS_UPFOLDER
#define IDS_TODESKTOP
#define IDS_REPORTVIEW
#define FODPROP_SAVEDLG
#define IDC_TOOLBARSTATIC
#define IDC_SHELLSTATIC
#define IDS_FILENOTFOUND
#define IDS_OVERWRITEFILE
#define IDC_FILETYPE
#define IDS_INVALID_FILENAME
#define IDS_VERIFYFILE
#define IDC_OPENREADONLY
#define IDS_NEWFOLDER
#define IDC_LOOKIN
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
size_t total
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble n
Definition: glext.h:7729
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: sysinfo.c:13
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define wine_dbgstr_w
Definition: kernel32.h:34
if(dx< 0)
Definition: linetemp.h:194
HWND hList
Definition: livecd.c:10
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
int * LPINT
Definition: minwindef.h:151
CONST void * LPCVOID
Definition: minwindef.h:164
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HDC hdc
Definition: main.c:9
static DWORD path_len
Definition: batch.c:31
static HINSTANCE hinst
Definition: edit.c:551
static HDC
Definition: imagelist.c:88
static const WCHAR tb[]
Definition: suminfo.c:431
static char * dest
Definition: rtl.c:149
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define menu
Definition: input.c:3282
#define ctrl
Definition: input.c:3281
static MONITORINFO mi
Definition: win.c:9400
static HWND dialog
Definition: gui.c:33
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:246
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:245
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define REG_BINARY
Definition: nt_native.h:1499
#define KEY_READ
Definition: nt_native.h:1026
#define LPVOID
Definition: nt_native.h:45
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define DWORD
Definition: nt_native.h:44
#define REG_EXPAND_SZ
Definition: nt_native.h:1497
#define UNICODE_NULL
#define PathCanonicalizeW
Definition: pathcch.h:314
#define PathAddBackslashW
Definition: pathcch.h:302
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_SIZEBOX
Definition: pedump.c:642
short WCHAR
Definition: pedump.c:58
#define WS_GROUP
Definition: pedump.c:633
#define WS_VISIBLE
Definition: pedump.c:620
#define RT_DIALOG
Definition: pedump.c:367
long LONG
Definition: pedump.c:60
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
char CHAR
Definition: pedump.c:57
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:238
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1548
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:222
UINT WINAPI ILGetSize(LPCITEMIDLIST pidl)
Definition: pidl.c:941
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:977
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:583
#define INT
Definition: polytest.cpp:20
static char title[]
Definition: ps.c:92
#define TTN_GETDISPINFOA
Definition: commctrl.h:1877
#define BTNS_BUTTON
Definition: commctrl.h:998
#define VIEW_PARENTFOLDER
Definition: commctrl.h:1095
#define TB_AUTOSIZE
Definition: commctrl.h:1137
#define ICC_USEREX_CLASSES
Definition: commctrl.h:68
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define BTNS_SEP
Definition: commctrl.h:999
#define HINST_COMMCTRL
Definition: commctrl.h:1063
#define VIEW_LIST
Definition: commctrl.h:1089
struct _IMAGELIST * HIMAGELIST
Definition: commctrl.h:324
#define IDB_VIEW_SMALL_COLOR
Definition: commctrl.h:1066
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
_Out_opt_ int * cx
Definition: commctrl.h:585
#define ILC_COLOR32
Definition: commctrl.h:358
#define TB_SETIMAGELIST
Definition: commctrl.h:1150
#define VIEW_NEWFOLDER
Definition: commctrl.h:1098
#define ILD_TRANSPARENT
Definition: commctrl.h:418
#define TB_SETBUTTONSIZE
Definition: commctrl.h:1135
#define CCS_NODIVIDER
Definition: commctrl.h:2253
#define TOOLBARCLASSNAMEW
Definition: commctrl.h:943
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TBSTYLE_FLAT
Definition: commctrl.h:992
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define CCS_NORESIZE
Definition: commctrl.h:2250
#define TBSTATE_WRAP
Definition: commctrl.h:977
#define TB_SETBUTTONWIDTH
Definition: commctrl.h:1161
#define TB_ADDBUTTONSW
Definition: commctrl.h:1266
#define VIEW_DETAILS
Definition: commctrl.h:1090
#define TB_SETMAXTEXTROWS
Definition: commctrl.h:1162
#define TOOLBARCLASSNAMEA
Definition: commctrl.h:944
struct tagNMTTDISPINFOA * LPNMTTDISPINFOA
#define TB_ADDBITMAP
Definition: commctrl.h:1056
#define TB_GETIMAGELIST
Definition: commctrl.h:1151
#define CBEM_GETEDITCONTROL
Definition: commctrl.h:3838
HWND WINAPI GetFocus(void)
Definition: window.c:1887
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD WINAPI GetSysColor(_In_ int)
#define CB_SETITEMDATA
Definition: winuser.h:1995
#define ODS_SELECTED
Definition: winuser.h:2581
#define WM_GETTEXTLENGTH
Definition: winuser.h:1647
#define SW_HIDE
Definition: winuser.h:779
#define SWP_NOACTIVATE
Definition: winuser.h:1253
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define SWP_FRAMECHANGED
Definition: winuser.h:1251
#define SBS_SIZEGRIP
Definition: winuser.h:332
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define COLOR_WINDOW
Definition: winuser.h:929
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HANDLE WINAPI GetPropA(_In_ HWND, _In_ LPCSTR)
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
#define IDCANCEL
Definition: winuser.h:842
#define MSGF_DIALOGBOX
Definition: winuser.h:1184
#define SM_CYVSCROLL
Definition: winuser.h:992
BOOL WINAPI SetPropA(_In_ HWND, _In_ LPCSTR, _In_opt_ HANDLE)
#define COLOR_WINDOWTEXT
Definition: winuser.h:932
#define MB_ICONHAND
Definition: winuser.h:799
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_SIZE
Definition: winuser.h:1639
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
HBRUSH WINAPI GetSysColorBrush(_In_ int)
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
#define WH_MSGFILTER
Definition: winuser.h:29
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SWP_NOMOVE
Definition: winuser.h:1255
#define WM_COMMAND
Definition: winuser.h:1768
#define CB_ERR
Definition: winuser.h:2471
#define CB_SETCURSEL
Definition: winuser.h:1990
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define SM_CYSMICON
Definition: winuser.h:1024
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define DS_3DLOOK
Definition: winuser.h:367
#define SWP_NOSIZE
Definition: winuser.h:1256
#define WM_GETTEXT
Definition: winuser.h:1646
#define WM_INITDIALOG
Definition: winuser.h:1767
#define MB_YESNO
Definition: winuser.h:828
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
#define CB_GETCOUNT
Definition: winuser.h:1971
#define SetWindowsHookEx
Definition: winuser.h:6022
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define WM_GETFONT
Definition: winuser.h:1679
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define SM_CYHSCROLL
Definition: winuser.h:973
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:841
#define WM_DRAWITEM
Definition: winuser.h:1673
#define GW_HWNDNEXT
Definition: winuser.h:772
#define BM_SETCHECK
Definition: winuser.h:1950
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define WM_SETTEXT
Definition: winuser.h:1645
#define SM_CXSMICON
Definition: winuser.h:1023
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SM_CYICON
Definition: winuser.h:984
#define WM_GETMINMAXINFO
Definition: winuser.h:1668
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
BOOL WINAPI IsChild(_In_ HWND, _In_ HWND)
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
HWND WINAPI CreateDialogIndirectParamA(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define IDNO
Definition: winuser.h:847
#define CB_ADDSTRING
Definition: winuser.h:1965
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
struct tagNMHDR * LPNMHDR
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
HDC WINAPI GetDC(_In_opt_ HWND)
#define EM_SETSEL
Definition: winuser.h:2047
int WINAPI GetWindowTextLengthW(_In_ HWND)
BOOL WINAPI SetDlgItemTextA(_In_ HWND, _In_ int, _In_ LPCSTR)
#define MB_ICONEXCLAMATION
Definition: winuser.h:796
#define MB_OK
Definition: winuser.h:801
INT_PTR WINAPI DialogBoxIndirectParamA(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
struct tagMSG * LPMSG
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define SBS_SIZEBOXBOTTOMRIGHTALIGN
Definition: winuser.h:330
#define WM_NCDESTROY
Definition: winuser.h:1712
#define SIZE_RESTORED
Definition: winuser.h:2541
#define DWLP_MSGRESULT
Definition: winuser.h:881
int WINAPI GetDlgCtrlID(_In_ HWND)
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define CBN_SELENDOK
Definition: winuser.h:2010
#define SW_SHOW
Definition: winuser.h:786
#define WM_DESTROY
Definition: winuser.h:1637
#define CB_SETEXTENDEDUI
Definition: winuser.h:1993
#define GW_CHILD
Definition: winuser.h:774
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define CB_INSERTSTRING
Definition: winuser.h:1986
#define SWP_NOZORDER
Definition: winuser.h:1258
#define CB_GETCURSEL
Definition: winuser.h:1972
#define SetWindowLongPtrW
Definition: winuser.h:5512
#define CB_DELETESTRING
Definition: winuser.h:1966
#define GWL_STYLE
Definition: winuser.h:863
#define CB_SETITEMHEIGHT
Definition: winuser.h:1996
#define SM_CXICON
Definition: winuser.h:983
#define WM_KEYLAST
Definition: winuser.h:1756
UINT WINAPI RegisterClipboardFormatA(_In_ LPCSTR)
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
int WINAPI GetSystemMetrics(_In_ int)
HWND WINAPI CreateDialogIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define DS_CONTROL
Definition: winuser.h:372
#define RDW_INVALIDATE
Definition: winuser.h:1225
#define HWND_BOTTOM
Definition: winuser.h:1216
HANDLE WINAPI RemovePropA(_In_ HWND, _In_ LPCSTR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1947
HDWP WINAPI BeginDeferWindowPos(_In_ int)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define GWL_EXSTYLE
Definition: winuser.h:862
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2422
#define WM_NOTIFY
Definition: richedit.h:61
const WCHAR * str
static calc_node_t temp
Definition: rpn_ieee.c:38
#define REG_DWORD
Definition: sdbapi.c:615
#define LoadStringW
Definition: utils.h:64
#define memset(x, y, z)
Definition: compat.h:39
static FILE * client
Definition: client.c:37
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:431
#define SHGFI_ATTR_SPECIFIED
Definition: shellapi.h:174
#define SHGFI_OPENICON
Definition: shellapi.h:178
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:171
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:166
#define SHGFI_ICON
Definition: shellapi.h:164
#define SHGFI_ATTRIBUTES
Definition: shellapi.h:168
#define SHGFI_SMALLICON
Definition: shellapi.h:176
#define SHGFI_PIDL
Definition: shellapi.h:180
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2206
#define CSIDL_RECENT
Definition: shlobj.h:2199
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2203
#define CFSTR_SHELLIDLISTA
Definition: shlobj.h:428
#define CSIDL_PERSONAL
Definition: shlobj.h:2196
#define CSIDL_FLAG_CREATE
Definition: shlobj.h:2253
#define CSIDL_MYPICTURES
Definition: shlobj.h:2229
#define CSIDL_DESKTOP
Definition: shlobj.h:2191
#define CSIDL_NETWORK
Definition: shlobj.h:2208
#define CSIDL_DRIVES
Definition: shlobj.h:2207
static IShellBrowser * IShellBrowserImpl_Construct(void)
Definition: shlview.c:278
@ FWF_AUTOARRANGE
Definition: shobjidl.idl:687
@ FWF_ALIGNLEFT
Definition: shobjidl.idl:698
@ FWF_SINGLESEL
Definition: shobjidl.idl:693
@ FVM_LIST
Definition: shobjidl.idl:727
#define FCIDM_TB_DESKTOP
Definition: shresdef.h:901
#define FCIDM_TB_NEWFOLDER
Definition: shresdef.h:898
#define FCIDM_TB_SMALLICON
Definition: shresdef.h:899
#define FCIDM_TB_UPFOLDER
Definition: shresdef.h:897
#define FCIDM_TB_REPORTVIEW
Definition: shresdef.h:900
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
@ STRRET_CSTR
Definition: shtypes.idl:87
@ STRRET_OFFSET
Definition: shtypes.idl:86
@ STRRET_WSTR
Definition: shtypes.idl:85
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
OPENFILENAME ofn
Definition: sndrec32.cpp:56
#define TRACE(s)
Definition: solgame.cpp:4
Definition: shlobj.h:582
UINT aoffset[1]
Definition: shlobj.h:583
UINT cidl
Definition: shlobj.h:582
LPITEMIDLIST places[5]
LPOPENFILENAMEW ofnInfos
struct FileOpenDlgInfos::@432 ShellInfos
struct FileOpenDlgInfos::@433 DlgInfos
struct FileOpenDlgInfos::@431 Shell
struct FileOpenDlgInfos::@434 HookMsg
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
int m_iIndent
Definition: filedlg.c:98
int m_iImageIndex
Definition: filedlg.c:96
HIMAGELIST hImgList
Definition: filedlg.c:97
LPITEMIDLIST pidlItem
Definition: filedlg.c:99
SHITEMID mkid
Definition: shtypes.idl:34
NMHDR hdr
Definition: commdlg.h:411
LPWSTR pszFile
Definition: commdlg.h:413
LPOPENFILENAMEW lpOFN
Definition: commdlg.h:412
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwPlatformId
Definition: rtltypes.h:250
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
ULONG dwMajorVersion
Definition: rtltypes.h:247
DWORD dwAttributes
Definition: shellapi.h:386
WCHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:387
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
Definition: vfat.h:185
Definition: dialog.c:52
Definition: tftpd.h:60
Definition: name.c:39
Definition: style.c:91
UINT uSelectedItem
Definition: filedlg.c:106
int iMaxIndentation
Definition: filedlg.c:105
POINT ptMinTrackSize
Definition: winuser.h:3738
DWORD cbSize
Definition: winuser.h:3892
MRUBinaryCmpFn binary_cmpfn
MRUStringCmpFnW string_cmpfn
LPWSTR lpszSubKey
union tagMRUINFOW::@424 u
UINT message
Definition: winuser.h:3223
UINT_PTR idFrom
Definition: winuser.h:3266
UINT code
Definition: winuser.h:3267
HWND hwndFrom
Definition: winuser.h:3265
HINSTANCE hinst
Definition: commctrl.h:1904
LPCSTR lpstrDefExt
Definition: commdlg.h:345
DWORD nMaxCustFilter
Definition: commdlg.h:334
LPSTR lpstrFileTitle
Definition: commdlg.h:338
LPCSTR lpTemplateName
Definition: commdlg.h:348
LPSTR lpstrCustomFilter
Definition: commdlg.h:333
LPCSTR lpstrTitle
Definition: commdlg.h:341
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
HINSTANCE hInstance
Definition: commdlg.h:362
HWND hwndOwner
Definition: commdlg.h:361
DWORD Flags
Definition: commdlg.h:373
WORD nFileExtension
Definition: commdlg.h:375
LPWSTR lpstrFile
Definition: commdlg.h:367
LPCWSTR lpstrInitialDir
Definition: commdlg.h:371
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:378
WORD nFileOffset
Definition: commdlg.h:374
LPCWSTR lpstrTitle
Definition: commdlg.h:372
LPWSTR lpstrFileTitle
Definition: commdlg.h:369
LPWSTR lpstrCustomFilter
Definition: commdlg.h:364
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
DWORD lStructSize
Definition: commdlg.h:360
DWORD nMaxFile
Definition: commdlg.h:368
LPCWSTR lpstrFilter
Definition: commdlg.h:363
DWORD nFilterIndex
Definition: commdlg.h:366
#define max(a, b)
Definition: svc.c:63
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT_PTR
Definition: typedefs.h:64
const uint16_t * LPCWSTR
Definition: typedefs.h:57
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
PVOID HANDLE
Definition: typedefs.h:73
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
Definition: pdh_main.c:64
DWORD dwAttributes
Definition: vdmdbg.h:34
struct _slot slot
Definition: vfat.h:196
int retval
Definition: wcstombs.cpp:91
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
#define WINAPI
Definition: msvc.h:6
#define strlenW(s)
Definition: unicode.h:28
#define NOERROR
Definition: winerror.h:3448
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RRF_RT_ANY
Definition: winreg.h:66
#define RRF_RT_REG_BINARY
Definition: winreg.h:60
#define RRF_RT_REG_SZ
Definition: winreg.h:58
#define IDC_TOOLBAR
Definition: wordpad.h:157
unsigned char BYTE
Definition: xxhash.c:193