ReactOS 0.4.15-dev-5875-g7c755d9
filedlg.c File Reference
#include <ctype.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "winnls.h"
#include "wingdi.h"
#include "winreg.h"
#include "winuser.h"
#include "commdlg.h"
#include "dlgs.h"
#include "cdlg.h"
#include "cderr.h"
#include "shellapi.h"
#include "shlobj.h"
#include "filedlgbrowser.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for filedlg.c:

Go to the source code of this file.

Classes

struct  SFolder
 
struct  tagLookInInfo
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define UNIMPLEMENTED_FLAGS
 
#define XTEXTOFFSET   3
 
#define LISTEND   -1
 
#define SEARCH_PIDL   1
 
#define SEARCH_EXP   2
 
#define ITEM_NOTFOUND   -1
 
#define WM_GETISHELLBROWSER   WM_USER+7
 
#define TBPLACES_CMDID_PLACE0   0xa064
 
#define TBPLACES_CMDID_PLACE1   0xa065
 
#define TBPLACES_CMDID_PLACE2   0xa066
 
#define TBPLACES_CMDID_PLACE3   0xa067
 
#define TBPLACES_CMDID_PLACE4   0xa068
 
#define CBGetItemDataPtr(hwnd, iItemId)    SendMessageW(hwnd, CB_GETITEMDATA, (WPARAM)(iItemId), 0)
 

Typedefs

typedef struct SFolder SFOLDER
 
typedef struct SFolderLPSFOLDER
 
typedef struct tagLookInInfo LookInInfos
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (commdlg)
 
FileOpenDlgInfosget_filedlg_infoptr (HWND hwnd)
 
static BOOL is_dialog_hooked (const FileOpenDlgInfos *info)
 
static BOOL filedialog_is_readonly_hidden (const FileOpenDlgInfos *info)
 
static LRESULT FILEDLG95_ResizeControls (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT FILEDLG95_FillControls (HWND hwnd, WPARAM wParam, LPARAM lParam)
 
static LRESULT FILEDLG95_OnWMCommand (HWND hwnd, WPARAM wParam)
 
static LRESULT FILEDLG95_OnWMGetIShellBrowser (HWND hwnd)
 
static BOOL FILEDLG95_OnOpen (HWND hwnd)
 
static LRESULT FILEDLG95_InitControls (HWND hwnd)
 
static void FILEDLG95_Clean (HWND hwnd)
 
static LRESULT FILEDLG95_SHELL_Init (HWND hwnd)
 
static BOOL FILEDLG95_SHELL_UpFolder (HWND hwnd)
 
static BOOL FILEDLG95_SHELL_ExecuteCommand (HWND hwnd, LPCSTR lpVerb)
 
static void FILEDLG95_SHELL_Clean (HWND hwnd)
 
static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR *lpstrFileList, UINT *sizeUsed)
 
static HRESULT FILEDLG95_FILETYPE_Init (HWND hwnd)
 
static BOOL FILEDLG95_FILETYPE_OnCommand (HWND hwnd, WORD wNotifyCode)
 
static int FILEDLG95_FILETYPE_SearchExt (HWND hwnd, LPCWSTR lpstrExt)
 
static void FILEDLG95_FILETYPE_Clean (HWND hwnd)
 
static void FILEDLG95_LOOKIN_Init (HWND hwndCombo)
 
static LRESULT FILEDLG95_LOOKIN_DrawItem (LPDRAWITEMSTRUCT pDIStruct)
 
static BOOL FILEDLG95_LOOKIN_OnCommand (HWND hwnd, WORD wNotifyCode)
 
static int FILEDLG95_LOOKIN_AddItem (HWND hwnd, LPITEMIDLIST pidl, int iInsertId)
 
static int FILEDLG95_LOOKIN_SearchItem (HWND hwnd, WPARAM searchArg, int iSearchMethod)
 
static int FILEDLG95_LOOKIN_InsertItemAfterParent (HWND hwnd, LPITEMIDLIST pidl)
 
static int FILEDLG95_LOOKIN_RemoveMostExpandedItem (HWND hwnd)
 
int FILEDLG95_LOOKIN_SelectItem (HWND hwnd, LPITEMIDLIST pidl)
 
static void FILEDLG95_LOOKIN_Clean (HWND hwnd)
 
static void FILEDLG95_MRU_load_filename (LPWSTR stored_path)
 
static WCHAR FILEDLG95_MRU_get_slot (LPCWSTR module_name, LPWSTR stored_path, PHKEY hkey_ret)
 
static void FILEDLG95_MRU_save_filename (LPCWSTR filename)
 
static HRESULT GetName (LPSHELLFOLDER lpsf, LPITEMIDLIST pidl, DWORD dwFlags, LPWSTR lpstrFileName)
 
IShellFolderGetShellFolderFromPidl (LPITEMIDLIST pidlAbs)
 
LPITEMIDLIST GetParentPidl (LPITEMIDLIST pidl)
 
static LPITEMIDLIST GetPidlFromName (IShellFolder *psf, LPWSTR lpcstrFileName)
 
static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl)
 
static UINT GetNumSelected (IDataObject *doSelected)
 
static void COMCTL32_ReleaseStgMedium (STGMEDIUM medium)
 
static INT_PTR CALLBACK FileOpenDlgProc95 (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR FILEDLG95_HandleCustomDialogMessages (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL FILEDLG95_OnOpenMultipleFiles (HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
 
static BOOL BrowseSelectedFolder (HWND hwnd)
 
static BOOL get_config_key_as_dword (HKEY hkey, const WCHAR *name, DWORD *value)
 
static BOOL get_config_key_dword (HKEY hkey, const WCHAR *name, DWORD *value)
 
static BOOL get_config_key_string (HKEY hkey, const WCHAR *name, WCHAR **value)
 
static BOOL is_places_bar_enabled (const FileOpenDlgInfos *fodInfos)
 
static void filedlg_collect_places_pidls (FileOpenDlgInfos *fodInfos)
 
static BOOL GetFileName95 (FileOpenDlgInfos *fodInfos)
 
static WCHARheap_strdupAtoW (const char *str)
 
static void init_filedlg_infoW (OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
 
static void init_filedlg_infoA (OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
 
static BOOL GetFileDialog95 (FileOpenDlgInfos *info, UINT dlg_type)
 
static BOOL COMDLG32_GetDisplayNameOf (LPCITEMIDLIST pidl, LPWSTR pwszPath)
 
void COMDLG32_GetCanonicalPath (PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile)
 
int COMDLG32_SplitFileNames (LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed)
 
static void ArrangeCtrlPositions (HWND hwndChildDlg, HWND hwndParentDlg, BOOL hide_help)
 
static INT_PTR CALLBACK FileOpenDlgProcUserTemplate (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static HWND CreateTemplateDialog (FileOpenDlgInfos *fodInfos, HWND hwnd)
 
LRESULT SendCustomDlgNotificationMessage (HWND hwndParentDlg, UINT uCode)
 
static INT_PTR FILEDLG95_Handle_GetFilePath (HWND hwnd, DWORD size, LPVOID result)
 
static LRESULT FILEDLG95_OnWMGetMMI (HWND hwnd, LPMINMAXINFO mmiptr)
 
static LRESULT FILEDLG95_OnWMSize (HWND hwnd, WPARAM wParam)
 
static BOOL filename_is_edit (const FileOpenDlgInfos *info)
 
static void filedlg_browse_to_pidl (const FileOpenDlgInfos *info, LPITEMIDLIST pidl)
 
static BOOL FILEDLG95_SendFileOK (HWND hwnd, FileOpenDlgInfos *fodInfos)
 
void FILEDLG95_OnOpenMessage (HWND hwnd, int idCaption, int idText)
 
int FILEDLG95_ValidatePathAction (LPWSTR lpstrPathAndFile, IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction)
 
static BOOL FILEDLG95_unixfs_is_rooted_at_desktop (void)
 
static FORMATETC get_def_format (void)
 
void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
 
static HRESULT COMDLG32_StrRetToStrNW (LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
 
LPITEMIDLIST GetPidlFromDataObject (IDataObject *doSelected, UINT nPidlIndex)
 
static BOOL valid_struct_size (DWORD size)
 
static BOOL is_win16_looks (DWORD flags)
 
BOOL WINAPI GetOpenFileNameA (OPENFILENAMEA *ofn)
 
BOOL WINAPI GetOpenFileNameW (OPENFILENAMEW *ofn)
 
BOOL WINAPI GetSaveFileNameA (OPENFILENAMEA *ofn)
 
BOOL WINAPI GetSaveFileNameW (LPOPENFILENAMEW ofn)
 
short WINAPI GetFileTitleA (LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf)
 
short WINAPI GetFileTitleW (LPCWSTR lpFile, LPWSTR lpTitle, WORD cbBuf)
 

Variables

static const char LookInInfosStr [] = "LookInInfos"
 
static SIZE MemDialogSize = { 0, 0}
 
static const WCHAR LastVisitedMRUW []
 
static const WCHAR MRUListW [] = {'M','R','U','L','i','s','t',0}
 
static const WCHAR filedlg_info_propnameW [] = {'F','i','l','e','O','p','e','n','D','l','g','I','n','f','o','s',0}
 

Macro Definition Documentation

◆ CBGetItemDataPtr

#define CBGetItemDataPtr (   hwnd,
  iItemId 
)     SendMessageW(hwnd, CB_GETITEMDATA, (WPARAM)(iItemId), 0)

Definition at line 214 of file filedlg.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 54 of file filedlg.c.

◆ ITEM_NOTFOUND

#define ITEM_NOTFOUND   -1

Definition at line 197 of file filedlg.c.

◆ LISTEND

#define LISTEND   -1

Definition at line 192 of file filedlg.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 55 of file filedlg.c.

◆ SEARCH_EXP

#define SEARCH_EXP   2

Definition at line 196 of file filedlg.c.

◆ SEARCH_PIDL

#define SEARCH_PIDL   1

Definition at line 195 of file filedlg.c.

◆ TBPLACES_CMDID_PLACE0

#define TBPLACES_CMDID_PLACE0   0xa064

Definition at line 202 of file filedlg.c.

◆ TBPLACES_CMDID_PLACE1

#define TBPLACES_CMDID_PLACE1   0xa065

Definition at line 203 of file filedlg.c.

◆ TBPLACES_CMDID_PLACE2

#define TBPLACES_CMDID_PLACE2   0xa066

Definition at line 204 of file filedlg.c.

◆ TBPLACES_CMDID_PLACE3

#define TBPLACES_CMDID_PLACE3   0xa067

Definition at line 205 of file filedlg.c.

◆ TBPLACES_CMDID_PLACE4

#define TBPLACES_CMDID_PLACE4   0xa068

Definition at line 206 of file filedlg.c.

◆ UNIMPLEMENTED_FLAGS

#define UNIMPLEMENTED_FLAGS
Value:
OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/)
#define OFN_DONTADDTORECENT
Definition: commdlg.h:98
#define OFN_NODEREFERENCELINKS
Definition: commdlg.h:125
#define OFN_NOREADONLYRETURN
Definition: commdlg.h:113
#define OFN_NOTESTFILECREATE
Definition: commdlg.h:114

Definition at line 88 of file filedlg.c.

◆ WM_GETISHELLBROWSER

#define WM_GETISHELLBROWSER   WM_USER+7

Definition at line 200 of file filedlg.c.

◆ XTEXTOFFSET

#define XTEXTOFFSET   3

Definition at line 189 of file filedlg.c.

Typedef Documentation

◆ LookInInfos

◆ LPSFOLDER

◆ SFOLDER

Function Documentation

◆ ArrangeCtrlPositions()

static void ArrangeCtrlPositions ( HWND  hwndChildDlg,
HWND  hwndParentDlg,
BOOL  hide_help 
)
static

Definition at line 824 of file filedlg.c.

825{
826 HWND hwndChild, hwndStc32;
827 RECT rectParent, rectChild, rectStc32;
828 INT help_fixup = 0;
829 int chgx, chgy;
830
831 /* Take into account if open as read only checkbox and help button
832 * are hidden
833 */
834 if (hide_help)
835 {
836 RECT rectHelp, rectCancel;
837 GetWindowRect(GetDlgItem(hwndParentDlg, pshHelp), &rectHelp);
838 GetWindowRect(GetDlgItem(hwndParentDlg, IDCANCEL), &rectCancel);
839 /* subtract the height of the help button plus the space between
840 * the help button and the cancel button to the height of the dialog
841 */
842 help_fixup = rectHelp.bottom - rectCancel.bottom;
843 }
844
845 /*
846 There are two possibilities to add components to the default file dialog box.
847
848 By default, all the new components are added below the standard dialog box (the else case).
849
850 However, if there is a static text component with the stc32 id, a special case happens.
851 The x and y coordinates of stc32 indicate the top left corner where to place the standard file dialog box
852 in the window and the cx and cy indicate how to size the window.
853 Moreover, if the new component's coordinates are on the left of the stc32 , it is placed on the left
854 of the standard file dialog box. If they are above the stc32 component, it is placed above and so on....
855
856 */
857
858 GetClientRect(hwndParentDlg, &rectParent);
859
860 /* when arranging controls we have to use fixed parent size */
861 rectParent.bottom -= help_fixup;
862
863 hwndStc32 = GetDlgItem(hwndChildDlg, stc32);
864 if (hwndStc32)
865 {
866 GetWindowRect(hwndStc32, &rectStc32);
867 MapWindowPoints(0, hwndChildDlg, (LPPOINT)&rectStc32, 2);
868
869 /* set the size of the stc32 control according to the size of
870 * client area of the parent dialog
871 */
872 SetWindowPos(hwndStc32, 0,
873 0, 0,
874 rectParent.right, rectParent.bottom,
876 }
877 else
878 SetRectEmpty(&rectStc32);
879
880 /* this part moves controls of the child dialog */
881 hwndChild = GetWindow(hwndChildDlg, GW_CHILD);
882 while (hwndChild)
883 {
884 if (hwndChild != hwndStc32)
885 {
886 GetWindowRect(hwndChild, &rectChild);
887 MapWindowPoints(0, hwndChildDlg, (LPPOINT)&rectChild, 2);
888
889 /* move only if stc32 exist */
890 if (hwndStc32 && rectChild.left > rectStc32.right)
891 {
892 /* move to the right of visible controls of the parent dialog */
893 rectChild.left += rectParent.right;
894 rectChild.left -= rectStc32.right;
895 }
896 /* move even if stc32 doesn't exist */
897 if (rectChild.top >= rectStc32.bottom)
898 {
899 /* move below visible controls of the parent dialog */
900 rectChild.top += rectParent.bottom;
901 rectChild.top -= rectStc32.bottom - rectStc32.top;
902 }
903
904 SetWindowPos(hwndChild, 0, rectChild.left, rectChild.top,
905 0, 0, SWP_NOSIZE | SWP_NOZORDER);
906 }
907 hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
908 }
909
910 /* this part moves controls of the parent dialog */
911 hwndChild = GetWindow(hwndParentDlg, GW_CHILD);
912 while (hwndChild)
913 {
914 if (hwndChild != hwndChildDlg)
915 {
916 GetWindowRect(hwndChild, &rectChild);
917 MapWindowPoints(0, hwndParentDlg, (LPPOINT)&rectChild, 2);
918
919 /* left,top of stc32 marks the position of controls
920 * from the parent dialog
921 */
922 rectChild.left += rectStc32.left;
923 rectChild.top += rectStc32.top;
924
925 SetWindowPos(hwndChild, 0, rectChild.left, rectChild.top,
926 0, 0, SWP_NOSIZE | SWP_NOZORDER);
927 }
928 hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
929 }
930
931 /* calculate the size of the resulting dialog */
932
933 /* here we have to use original parent size */
934 GetClientRect(hwndParentDlg, &rectParent);
935 GetClientRect(hwndChildDlg, &rectChild);
936 TRACE( "parent %s child %s stc32 %s\n", wine_dbgstr_rect( &rectParent),
937 wine_dbgstr_rect( &rectChild), wine_dbgstr_rect( &rectStc32));
938
939 if (hwndStc32)
940 {
941 /* width */
942 if (rectParent.right > rectStc32.right - rectStc32.left)
943 chgx = rectChild.right - ( rectStc32.right - rectStc32.left);
944 else
945 chgx = rectChild.right - rectParent.right;
946 /* height */
947 if (rectParent.bottom > rectStc32.bottom - rectStc32.top)
948 chgy = rectChild.bottom - ( rectStc32.bottom - rectStc32.top) - help_fixup;
949 else
950 /* Unconditionally set new dialog
951 * height to that of the child
952 */
953 chgy = rectChild.bottom - rectParent.bottom;
954 }
955 else
956 {
957 chgx = 0;
958 chgy = rectChild.bottom - help_fixup;
959 }
960 /* set the size of the parent dialog */
961 GetWindowRect(hwndParentDlg, &rectParent);
962 SetWindowPos(hwndParentDlg, 0,
963 0, 0,
964 rectParent.right - rectParent.left + chgx,
965 rectParent.bottom - rectParent.top + chgy,
967}
#define pshHelp
Definition: dlgs.h:127
#define stc32
Definition: dlgs.h:191
static __inline const char * wine_dbgstr_rect(const RECT *rect)
Definition: debug.h:219
#define TRACE(s)
Definition: solgame.cpp:4
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
#define IDCANCEL
Definition: winuser.h:825
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 SWP_NOMOVE
Definition: winuser.h:1234
#define SWP_NOSIZE
Definition: winuser.h:1235
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define GW_HWNDNEXT
Definition: winuser.h:756
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define GW_CHILD
Definition: winuser.h:758
#define SWP_NOZORDER
Definition: winuser.h:1237

Referenced by FILEDLG95_ResizeControls().

◆ BrowseSelectedFolder()

static BOOL BrowseSelectedFolder ( HWND  hwnd)
static

Definition at line 4586 of file filedlg.c.

4587{
4589 BOOL bBrowseSelFolder = FALSE;
4590
4591 TRACE("\n");
4592
4593 if (GetNumSelected(fodInfos->Shell.FOIDataObject) == 1)
4594 {
4595 LPITEMIDLIST pidlSelection;
4596
4597 /* get the file selected */
4598 pidlSelection = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, 1);
4599 if (IsPidlFolder (fodInfos->Shell.FOIShellFolder, pidlSelection))
4600 {
4601 if ( FAILED( IShellBrowser_BrowseObject( fodInfos->Shell.FOIShellBrowser,
4602 pidlSelection, SBSP_RELATIVE ) ) )
4603 {
4604 WCHAR buf[64];
4607 }
4608 bBrowseSelFolder = TRUE;
4609 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
4611 }
4612 ILFree( pidlSelection );
4613 }
4614
4615 return bBrowseSelFolder;
4616}
#define ARRAY_SIZE(A)
Definition: main.h:33
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
#define OFN_EXPLORER
Definition: commdlg.h:104
#define CDN_FOLDERCHANGE
Definition: commdlg.h:35
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static UINT GetNumSelected(IDataObject *doSelected)
Definition: filedlg.c:4433
FileOpenDlgInfos * get_filedlg_infoptr(HWND hwnd)
Definition: filedlg.c:229
static BOOL IsPidlFolder(LPSHELLFOLDER psf, LPCITEMIDLIST pidl)
Definition: filedlg.c:4569
LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
Definition: filedlg.c:1070
LPITEMIDLIST GetPidlFromDataObject(IDataObject *doSelected, UINT nPidlIndex)
Definition: filedlg.c:4402
#define IDS_PATHNOTEXISTING
unsigned int BOOL
Definition: ntddk_ex.h:94
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FAILED(hr)
Definition: intsafe.h:51
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
LPOPENFILENAMEW ofnInfos
struct FileOpenDlgInfos::@332 Shell
DWORD Flags
Definition: commdlg.h:373
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define MB_OK
Definition: winuser.h:784
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by FILEDLG95_OnOpen().

◆ COMCTL32_ReleaseStgMedium()

static void COMCTL32_ReleaseStgMedium ( STGMEDIUM  medium)
static

Definition at line 4382 of file filedlg.c.

4383{
4384 if(medium.pUnkForRelease)
4385 {
4386 IUnknown_Release(medium.pUnkForRelease);
4387 }
4388 else
4389 {
4390 GlobalUnlock(medium.u.hGlobal);
4391 GlobalFree(medium.u.hGlobal);
4392 }
4393}
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

Referenced by FILEDLG95_FILENAME_FillFromSelection(), GetNumSelected(), and GetPidlFromDataObject().

◆ COMDLG32_GetCanonicalPath()

void COMDLG32_GetCanonicalPath ( PCIDLIST_ABSOLUTE  pidlAbsCurrent,
LPWSTR  lpstrFile,
LPWSTR  lpstrPathAndFile 
)

Definition at line 736 of file filedlg.c.

738{
739 WCHAR lpstrTemp[MAX_PATH];
740
741 /* Get the current directory name */
742 if (!COMDLG32_GetDisplayNameOf(pidlAbsCurrent, lpstrPathAndFile))
743 {
744 /* last fallback */
745 GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);
746 }
747 PathAddBackslashW(lpstrPathAndFile);
748
749 TRACE("current directory=%s, file=%s\n", debugstr_w(lpstrPathAndFile), debugstr_w(lpstrFile));
750
751 /* if the user specified a fully qualified path use it */
752 if(PathIsRelativeW(lpstrFile))
753 {
754 lstrcatW(lpstrPathAndFile, lpstrFile);
755 }
756 else
757 {
758 /* does the path have a drive letter? */
759 if (PathGetDriveNumberW(lpstrFile) == -1)
760 lstrcpyW(lpstrPathAndFile+2, lpstrFile);
761 else
762 lstrcpyW(lpstrPathAndFile, lpstrFile);
763 }
764
765 /* resolve "." and ".." */
766 PathCanonicalizeW(lpstrTemp, lpstrPathAndFile );
767 lstrcpyW(lpstrPathAndFile, lpstrTemp);
768 TRACE("canon=%s\n", debugstr_w(lpstrPathAndFile));
769}
static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath)
Definition: filedlg.c:715
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:756
#define MAX_PATH
Definition: compat.h:34
#define lstrcpyW
Definition: compat.h:749
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
int WINAPI PathGetDriveNumberW(const WCHAR *path)
Definition: path.c:553
BOOL WINAPI PathCanonicalizeW(LPWSTR lpszBuf, LPCWSTR lpszPath)
Definition: path.c:2446
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by FILEDLG95_OnOpen(), and on_default_action().

◆ COMDLG32_GetDisplayNameOf()

static BOOL COMDLG32_GetDisplayNameOf ( LPCITEMIDLIST  pidl,
LPWSTR  pwszPath 
)
static

Definition at line 715 of file filedlg.c.

715 {
716 LPSHELLFOLDER psfDesktop;
717 STRRET strret;
718
719 if (FAILED(SHGetDesktopFolder(&psfDesktop)))
720 return FALSE;
721
722 if (FAILED(IShellFolder_GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret))) {
723 IShellFolder_Release(psfDesktop);
724 return FALSE;
725 }
726
727 IShellFolder_Release(psfDesktop);
728 return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH));
729}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by COMDLG32_GetCanonicalPath(), FILEDLG95_Handle_GetFilePath(), FILEDLG95_HandleCustomDialogMessages(), and FILEDLG95_OnOpenMultipleFiles().

◆ COMDLG32_SplitFileNames()

int COMDLG32_SplitFileNames ( LPWSTR  lpstrEdit,
UINT  nStrLen,
LPWSTR lpstrFileList,
UINT sizeUsed 
)

Definition at line 776 of file filedlg.c.

777{
778 UINT nStrCharCount = 0; /* index in src buffer */
779 UINT nFileIndex = 0; /* index in dest buffer */
780 UINT nFileCount = 0; /* number of files */
781
782 /* we might get single filename without any '"',
783 * so we need nStrLen + terminating \0 + end-of-list \0 */
784 *lpstrFileList = heap_alloc((nStrLen + 2) * sizeof(WCHAR));
785 *sizeUsed = 0;
786
787 /* build delimited file list from filenames */
788 while ( nStrCharCount <= nStrLen )
789 {
790 if ( lpstrEdit[nStrCharCount]=='"' )
791 {
792 nStrCharCount++;
793 while ((nStrCharCount <= nStrLen) && (lpstrEdit[nStrCharCount]!='"'))
794 {
795 (*lpstrFileList)[nFileIndex++] = lpstrEdit[nStrCharCount];
796 nStrCharCount++;
797 }
798 (*lpstrFileList)[nFileIndex++] = 0;
799 nFileCount++;
800 }
801 nStrCharCount++;
802 }
803
804 /* single, unquoted string */
805 if ((nStrLen > 0) && (nFileIndex == 0) )
806 {
807 lstrcpyW(*lpstrFileList, lpstrEdit);
808 nFileIndex = lstrlenW(lpstrEdit) + 1;
809 nFileCount = 1;
810 }
811
812 /* trailing \0 */
813 (*lpstrFileList)[nFileIndex++] = '\0';
814
815 *sizeUsed = nFileIndex;
816 return nFileCount;
817}
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define lstrlenW
Definition: compat.h:750
unsigned int UINT
Definition: ndis.h:50

Referenced by FILEDLG95_FILENAME_GetFileNames(), and on_default_action().

◆ COMDLG32_StrRetToStrNW()

static HRESULT COMDLG32_StrRetToStrNW ( LPWSTR  dest,
DWORD  len,
LPSTRRET  src,
const ITEMIDLIST pidl 
)
static

Definition at line 4320 of file filedlg.c.

4321{
4322 switch (src->uType)
4323 {
4324 case STRRET_WSTR:
4325 lstrcpynW(dest, src->u.pOleStr, len);
4326 CoTaskMemFree(src->u.pOleStr);
4327 break;
4328
4329 case STRRET_CSTR:
4330 if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ) && len)
4331 dest[len-1] = 0;
4332 break;
4333
4334 case STRRET_OFFSET:
4335 if (!MultiByteToWideChar( CP_ACP, 0, ((LPCSTR)&pidl->mkid)+src->u.uOffset, -1, dest, len ) && len)
4336 dest[len-1] = 0;
4337 break;
4338
4339 default:
4340 FIXME("unknown type %x!\n", src->uType);
4341 if (len) *dest = '\0';
4342 return E_FAIL;
4343 }
4344 return S_OK;
4345}
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_FAIL
Definition: ddrawi.h:102
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrcpynW
Definition: compat.h:738
GLenum src
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define S_OK
Definition: intsafe.h:52
static char * dest
Definition: rtl.c:135
@ STRRET_CSTR
Definition: shtypes.idl:87
@ STRRET_OFFSET
Definition: shtypes.idl:86
@ STRRET_WSTR
Definition: shtypes.idl:85
SHITEMID mkid
Definition: shtypes.idl:34
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by GetName().

◆ CreateTemplateDialog()

static HWND CreateTemplateDialog ( FileOpenDlgInfos fodInfos,
HWND  hwnd 
)
static

Definition at line 978 of file filedlg.c.

979{
980 LPCVOID template;
981 HRSRC hRes;
982 HANDLE hDlgTmpl = 0;
983 HWND hChildDlg = 0;
984
985 TRACE("%p, %p\n", fodInfos, hwnd);
986
987 /*
988 * If OFN_ENABLETEMPLATEHANDLE is specified, the OPENFILENAME
989 * structure's hInstance parameter is not a HINSTANCE, but
990 * instead a pointer to a template resource to use.
991 */
993 {
995 if (fodInfos->ofnInfos->Flags & OFN_ENABLETEMPLATEHANDLE)
996 {
998 if( !(template = LockResource( fodInfos->ofnInfos->hInstance)))
999 {
1001 return NULL;
1002 }
1003 }
1004 else
1005 {
1006 hinst = fodInfos->ofnInfos->hInstance;
1007 if(fodInfos->unicode)
1008 {
1009 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
1011 }
1012 else
1013 {
1016 }
1017 if (!hRes)
1018 {
1020 return NULL;
1021 }
1022 if (!(hDlgTmpl = LoadResource( hinst, hRes )) ||
1023 !(template = LockResource( hDlgTmpl )))
1024 {
1026 return NULL;
1027 }
1028 }
1029 if (fodInfos->unicode)
1030 hChildDlg = CreateDialogIndirectParamW(hinst, template, hwnd,
1032 (LPARAM)fodInfos->ofnInfos);
1033 else
1034 hChildDlg = CreateDialogIndirectParamA(hinst, template, hwnd,
1036 (LPARAM)fodInfos->ofnInfos);
1037 return hChildDlg;
1038 }
1039 else if (is_dialog_hooked(fodInfos))
1040 {
1041 RECT rectHwnd;
1042 struct {
1043 DLGTEMPLATE tmplate;
1044 WORD menu,class,title;
1045 } temp;
1046 GetClientRect(hwnd,&rectHwnd);
1048 temp.tmplate.dwExtendedStyle = 0;
1049 temp.tmplate.cdit = 0;
1050 temp.tmplate.x = 0;
1051 temp.tmplate.y = 0;
1052 temp.tmplate.cx = 0;
1053 temp.tmplate.cy = 0;
1054 temp.menu = temp.class = temp.title = 0;
1055
1057 hwnd, (DLGPROC)fodInfos->ofnInfos->lpfnHook, (LPARAM)fodInfos->ofnInfos);
1058
1059 return hChildDlg;
1060 }
1061 return NULL;
1062}
#define CDERR_LOADRESFAILURE
Definition: cderr.h:12
#define CDERR_FINDRESFAILURE
Definition: cderr.h:11
void COMDLG32_SetCommDlgExtendedError(DWORD err) DECLSPEC_HIDDEN
Definition: cdlg32.c:128
#define OFN_ENABLETEMPLATEHANDLE
Definition: commdlg.h:103
struct tagOFNA * LPOPENFILENAMEA
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
#define DLGPROC
Definition: maze.c:62
#define NULL
Definition: types.h:112
static INT_PTR CALLBACK FileOpenDlgProcUserTemplate(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: filedlg.c:969
static BOOL is_dialog_hooked(const FileOpenDlgInfos *info)
Definition: filedlg.c:234
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
unsigned short WORD
Definition: ntddk_ex.h:93
OPENFILENAME ofn
Definition: main.cpp:29
static HINSTANCE hinst
Definition: edit.c:551
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define RT_DIALOG
Definition: pedump.c:367
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
static char title[]
Definition: ps.c:92
static calc_node_t temp
Definition: rpn_ieee.c:38
LPCSTR lpTemplateName
Definition: commdlg.h:348
HINSTANCE hInstance
Definition: commdlg.h:362
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:378
LONG_PTR LPARAM
Definition: windef.h:208
CONST void * LPCVOID
Definition: windef.h:191
#define DS_3DLOOK
Definition: winuser.h:367
HWND WINAPI CreateDialogIndirectParamA(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
HWND WINAPI CreateDialogIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define DS_CONTROL
Definition: winuser.h:372
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by FileOpenDlgProc95().

◆ filedialog_is_readonly_hidden()

static BOOL filedialog_is_readonly_hidden ( const FileOpenDlgInfos info)
static

Definition at line 239 of file filedlg.c.

240{
241 return (info->ofnInfos->Flags & OFN_HIDEREADONLY) || (info->DlgInfos.dwDlgProp & FODPROP_SAVEDLG);
242}
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define FODPROP_SAVEDLG

Referenced by FILEDLG95_InitControls(), and FILEDLG95_ResizeControls().

◆ FILEDLG95_Clean()

void FILEDLG95_Clean ( HWND  hwnd)
static

Definition at line 2140 of file filedlg.c.

2141{
2145}
static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
Definition: filedlg.c:3720
static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
Definition: filedlg.c:4193
static void FILEDLG95_SHELL_Clean(HWND hwnd)
Definition: filedlg.c:3509

Referenced by FILEDLG95_OnOpen(), FILEDLG95_OnOpenMultipleFiles(), and FILEDLG95_OnWMCommand().

◆ FILEDLG95_FILENAME_FillFromSelection()

void FILEDLG95_FILENAME_FillFromSelection ( HWND  hwnd)

Definition at line 4244 of file filedlg.c.

4245{
4247 LPITEMIDLIST pidl;
4248 LPWSTR lpstrAllFiles, lpstrTmp;
4249 UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength;
4250 STGMEDIUM medium;
4251 LPIDA cida;
4252 FORMATETC formatetc = get_def_format();
4253
4254 TRACE("\n");
4255
4256 if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, &medium)))
4257 return;
4258
4259 cida = GlobalLock(medium.u.hGlobal);
4260 nFileSelected = cida->cidl;
4261
4262 /* Allocate a buffer */
4263 nAllFilesMaxLength = MAX_PATH + 3;
4264 lpstrAllFiles = heap_alloc_zero(nAllFilesMaxLength * sizeof(WCHAR));
4265 if (!lpstrAllFiles)
4266 goto ret;
4267
4268 /* Loop through the selection, handle only files (not folders) */
4269 for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++)
4270 {
4271 pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]);
4272 if (pidl)
4273 {
4274 if (!IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl))
4275 {
4276 if (nAllFilesLength + MAX_PATH + 3 > nAllFilesMaxLength)
4277 {
4278 nAllFilesMaxLength *= 2;
4279 lpstrTmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpstrAllFiles, nAllFilesMaxLength * sizeof(WCHAR));
4280 if (!lpstrTmp)
4281 goto ret;
4282 lpstrAllFiles = lpstrTmp;
4283 }
4284 nFiles += 1;
4285 lpstrAllFiles[nAllFilesLength++] = '"';
4286 GetName(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | SHGDN_FORPARSING, lpstrAllFiles + nAllFilesLength);
4287 nThisFileLength = lstrlenW(lpstrAllFiles + nAllFilesLength);
4288 nAllFilesLength += nThisFileLength;
4289 lpstrAllFiles[nAllFilesLength++] = '"';
4290 lpstrAllFiles[nAllFilesLength++] = ' ';
4291 }
4292 }
4293 }
4294
4295 if (nFiles != 0)
4296 {
4297 /* If there's only one file, use the name as-is without quotes */
4298 lpstrTmp = lpstrAllFiles;
4299 if (nFiles == 1)
4300 {
4301 lpstrTmp += 1;
4302 lpstrTmp[nThisFileLength] = 0;
4303 }
4304 SetWindowTextW(fodInfos->DlgInfos.hwndFileName, lpstrTmp);
4305 /* Select the file name like Windows does */
4306 if (filename_is_edit(fodInfos))
4307 SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
4308 }
4309
4310ret:
4311 heap_free(lpstrAllFiles);
4313}
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl, DWORD dwFlags, LPWSTR lpstrFileName)
Definition: filedlg.c:4468
static FORMATETC get_def_format(void)
Definition: filedlg.c:4225
static BOOL filename_is_edit(const FileOpenDlgInfos *info)
Definition: filedlg.c:1618
static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium)
Definition: filedlg.c:4382
#define GetProcessHeap()
Definition: compat.h:736
#define HeapReAlloc
Definition: compat.h:734
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
Definition: shlobj.h:499
UINT aoffset[1]
Definition: shlobj.h:500
UINT cidl
Definition: shlobj.h:499
struct FileOpenDlgInfos::@334 DlgInfos
unsigned char * LPBYTE
Definition: typedefs.h:53
int ret
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define EM_SETSEL
Definition: winuser.h:2008
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by IShellBrowserImpl_OnSelChange().

◆ FILEDLG95_FILENAME_GetFileNames()

static int FILEDLG95_FILENAME_GetFileNames ( HWND  hwnd,
LPWSTR lpstrFileList,
UINT sizeUsed 
)
static

Definition at line 4352 of file filedlg.c.

4353{
4355 UINT nFileCount = 0; /* number of files */
4356 UINT nStrLen = 0; /* length of string in edit control */
4357 LPWSTR lpstrEdit; /* buffer for string from edit control */
4358
4359 TRACE("\n");
4360
4361 /* get the filenames from the filename control */
4362 nStrLen = GetWindowTextLengthW( fodInfos->DlgInfos.hwndFileName );
4363 lpstrEdit = heap_alloc( (nStrLen+1)*sizeof(WCHAR) );
4364 GetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrEdit, nStrLen+1);
4365
4366 TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit));
4367
4368 nFileCount = COMDLG32_SplitFileNames(lpstrEdit, nStrLen, lpstrFileList, sizeUsed);
4369 heap_free(lpstrEdit);
4370 return nFileCount;
4371}
int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileList, UINT *sizeUsed)
Definition: filedlg.c:776
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
int WINAPI GetWindowTextLengthW(_In_ HWND)

Referenced by FILEDLG95_OnOpen().

◆ FILEDLG95_FILETYPE_Clean()

static void FILEDLG95_FILETYPE_Clean ( HWND  hwnd)
static

Definition at line 3720 of file filedlg.c.

3721{
3723 int iPos;
3724 int iCount;
3725
3726 iCount = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCOUNT, 0, 0);
3727
3728 TRACE("\n");
3729
3730 /* Delete each string of the combo and their associated data */
3731 if(iCount != CB_ERR)
3732 {
3733 for(iPos = iCount-1;iPos>=0;iPos--)
3734 {
3735 heap_free((void *)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
3736 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_DELETESTRING, iPos, 0);
3737 }
3738 }
3739 /* Current filter */
3740 heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
3741}
#define CBGetItemDataPtr(hwnd, iItemId)
Definition: filedlg.c:214
struct FileOpenDlgInfos::@333 ShellInfos
#define CB_ERR
Definition: winuser.h:2425
#define CB_GETCOUNT
Definition: winuser.h:1932
#define CB_DELETESTRING
Definition: winuser.h:1927

Referenced by FILEDLG95_Clean().

◆ FILEDLG95_FILETYPE_Init()

static HRESULT FILEDLG95_FILETYPE_Init ( HWND  hwnd)
static

Definition at line 3535 of file filedlg.c.

3536{
3538 int nFilters = 0; /* number of filters */
3539 int nFilterIndexCB;
3540
3541 TRACE("%p\n", hwnd);
3542
3543 if(fodInfos->customfilter)
3544 {
3545 /* customfilter has one entry... title\0ext\0
3546 * Set first entry of combo box item with customfilter
3547 */
3548 LPWSTR lpstrExt;
3549 LPCWSTR lpstrPos = fodInfos->customfilter;
3550
3551 /* Get the title */
3552 lpstrPos += lstrlenW(fodInfos->customfilter) + 1;
3553
3554 /* Copy the extensions */
3555 if (! *lpstrPos) return E_FAIL; /* malformed filter */
3556 if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
3557 lstrcpyW(lpstrExt,lpstrPos);
3558
3559 /* Add the item at the end of the combo */
3560 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)fodInfos->customfilter);
3561 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters, (LPARAM)lpstrExt);
3562
3563 nFilters++;
3564 }
3565 if(fodInfos->filter)
3566 {
3567 LPCWSTR lpstrPos = fodInfos->filter;
3568
3569 for(;;)
3570 {
3571 /* filter is a list... title\0ext\0......\0\0
3572 * Set the combo item text to the title and the item data
3573 * to the ext
3574 */
3575 LPCWSTR lpstrDisplay;
3576 LPWSTR lpstrExt;
3577
3578 /* Get the title */
3579 if(! *lpstrPos) break; /* end */
3580 lpstrDisplay = lpstrPos;
3581 lpstrPos += lstrlenW(lpstrPos) + 1;
3582
3583 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_ADDSTRING, 0, (LPARAM)lpstrDisplay);
3584
3585 nFilters++;
3586
3587 /* Copy the extensions */
3588 if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
3589 lstrcpyW(lpstrExt,lpstrPos);
3590 lpstrPos += lstrlenW(lpstrPos) + 1;
3591
3592 /* Add the item at the end of the combo */
3593 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETITEMDATA, nFilters - 1, (LPARAM)lpstrExt);
3594
3595 /* malformed filters are added anyway... */
3596 if (!*lpstrExt) break;
3597 }
3598 }
3599
3600 /*
3601 * Set the current filter to the one specified
3602 * in the initialisation structure
3603 */
3604 if (fodInfos->filter || fodInfos->customfilter)
3605 {
3606 LPWSTR lpstrFilter;
3607
3608 /* Check to make sure our index isn't out of bounds. */
3609 if ( fodInfos->ofnInfos->nFilterIndex >
3610 nFilters - (fodInfos->customfilter == NULL ? 0 : 1) )
3611 fodInfos->ofnInfos->nFilterIndex = (fodInfos->customfilter == NULL ? 1 : 0);
3612
3613 /* set default filter index */
3614 if(fodInfos->ofnInfos->nFilterIndex == 0 && fodInfos->customfilter == NULL)
3615 fodInfos->ofnInfos->nFilterIndex = 1;
3616
3617 /* calculate index of Combo Box item */
3618 nFilterIndexCB = fodInfos->ofnInfos->nFilterIndex;
3619 if (fodInfos->customfilter == NULL)
3620 nFilterIndexCB--;
3621
3622 /* Set the current index selection. */
3623 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, nFilterIndexCB, 0);
3624
3625 /* Get the corresponding text string from the combo box. */
3626 lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
3627 nFilterIndexCB);
3628
3629 if ((INT_PTR)lpstrFilter == CB_ERR) /* control is empty */
3630 lpstrFilter = NULL;
3631
3632 if(lpstrFilter)
3633 {
3634 DWORD len;
3635 CharLowerW(lpstrFilter); /* lowercase */
3636 len = lstrlenW(lpstrFilter)+1;
3637 fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
3638 lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
3639 }
3640 } else
3641 fodInfos->ofnInfos->nFilterIndex = 0;
3642 return S_OK;
3643}
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD nFilterIndex
Definition: commdlg.h:366
int32_t INT_PTR
Definition: typedefs.h:64
#define CB_SETITEMDATA
Definition: winuser.h:1956
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)
#define CB_SETCURSEL
Definition: winuser.h:1951
#define CB_ADDSTRING
Definition: winuser.h:1926
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by FILEDLG95_InitControls().

◆ FILEDLG95_FILETYPE_OnCommand()

static BOOL FILEDLG95_FILETYPE_OnCommand ( HWND  hwnd,
WORD  wNotifyCode 
)
static

Definition at line 3651 of file filedlg.c.

3652{
3654
3655 switch(wNotifyCode)
3656 {
3657 case CBN_SELENDOK:
3658 {
3659 LPWSTR lpstrFilter;
3660
3661 /* Get the current item of the filetype combo box */
3662 int iItem = SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_GETCURSEL, 0, 0);
3663
3664 /* set the current filter index */
3665 fodInfos->ofnInfos->nFilterIndex = iItem +
3666 (fodInfos->customfilter == NULL ? 1 : 0);
3667
3668 /* Set the current filter with the current selection */
3669 heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
3670
3671 lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
3672 iItem);
3673 if((INT_PTR)lpstrFilter != CB_ERR)
3674 {
3675 DWORD len;
3676 CharLowerW(lpstrFilter); /* lowercase */
3677 len = lstrlenW(lpstrFilter)+1;
3678 fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
3679 lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
3680 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
3682 }
3683
3684 /* Refresh the actual view to display the included items*/
3685 if (fodInfos->Shell.FOIShellView)
3686 IShellView_Refresh(fodInfos->Shell.FOIShellView);
3687 }
3688 }
3689 return FALSE;
3690}
#define CDN_TYPECHANGE
Definition: commdlg.h:39
#define CBN_SELENDOK
Definition: winuser.h:1971
#define CB_GETCURSEL
Definition: winuser.h:1933

Referenced by FILEDLG95_OnWMCommand().

◆ FILEDLG95_FILETYPE_SearchExt()

static int FILEDLG95_FILETYPE_SearchExt ( HWND  hwnd,
LPCWSTR  lpstrExt 
)
static

Definition at line 3696 of file filedlg.c.

3697{
3698 int i, iCount;
3699
3700 iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
3701
3702 TRACE("%s\n", debugstr_w(lpstrExt));
3703
3704 if(iCount != CB_ERR)
3705 {
3706 for(i=0;i<iCount;i++)
3707 {
3708 if(!lstrcmpiW(lpstrExt,(LPWSTR)CBGetItemDataPtr(hwnd,i)))
3709 return i;
3710 }
3711 }
3712 return -1;
3713}
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
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194

Referenced by FILEDLG95_OnOpen().

◆ FILEDLG95_FillControls()

static LRESULT FILEDLG95_FillControls ( HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 2103 of file filedlg.c.

2104{
2105 LPITEMIDLIST pidlItemId = NULL;
2106
2108
2109 TRACE("dir=%s file=%s\n",
2110 debugstr_w(fodInfos->initdir), debugstr_w(fodInfos->filename));
2111
2112 /* Get the initial directory pidl */
2113
2114 if(!(pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder,fodInfos->initdir)))
2115 {
2117
2119 pidlItemId = GetPidlFromName(fodInfos->Shell.FOIShellFolder, path);
2120 }
2121
2122 /* Initialise shell objects */
2124
2125 /* Initialize the Look In combo box */
2126 FILEDLG95_LOOKIN_Init(fodInfos->DlgInfos.hwndLookInCB);
2127
2128 /* Browse to the initial directory */
2129 IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,pidlItemId, SBSP_ABSOLUTE);
2130
2131 ILFree(pidlItemId);
2132
2133 return TRUE;
2134}
LPARAM lParam
Definition: combotst.c:139
static LRESULT FILEDLG95_SHELL_Init(HWND hwnd)
Definition: filedlg.c:3422
static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
Definition: filedlg.c:3769
static LPITEMIDLIST GetPidlFromName(IShellFolder *psf, LPWSTR lpcstrFileName)
Definition: filedlg.c:4543

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_Handle_GetFilePath()

static INT_PTR FILEDLG95_Handle_GetFilePath ( HWND  hwnd,
DWORD  size,
LPVOID  result 
)
static

Definition at line 1099 of file filedlg.c.

1100{
1101 UINT len, total;
1102 WCHAR *p, *buffer;
1104
1105 TRACE("CDM_GETFILEPATH:\n");
1106
1107 if ( ! (fodInfos->ofnInfos->Flags & OFN_EXPLORER ) )
1108 return -1;
1109
1110 /* get path and filenames */
1111 len = SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0 );
1112 buffer = heap_alloc( (len + 2 + MAX_PATH) * sizeof(WCHAR) );
1113 COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, buffer );
1114 if (len)
1115 {
1116 p = buffer + lstrlenW(buffer);
1117 *p++ = '\\';
1118 SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, len + 1, (LPARAM)p );
1119 }
1120 if (fodInfos->unicode)
1121 {
1122 total = lstrlenW( buffer) + 1;
1123 if (result) lstrcpynW( result, buffer, size );
1124 TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_w(result));
1125 }
1126 else
1127 {
1128 total = WideCharToMultiByte( CP_ACP, 0, buffer, -1, NULL, 0, NULL, NULL );
1130 TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_a(result));
1131 }
1132 heap_free( buffer );
1133 return total;
1134}
#define WideCharToMultiByte
Definition: compat.h:111
size_t total
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLfloat GLfloat p
Definition: glext.h:8902
GLuint64EXT * result
Definition: glext.h:11304
#define debugstr_a
Definition: kernel32.h:31
#define WM_GETTEXTLENGTH
Definition: winuser.h:1609
#define WM_GETTEXT
Definition: winuser.h:1608

Referenced by FILEDLG95_HandleCustomDialogMessages().

◆ FILEDLG95_HandleCustomDialogMessages()

static INT_PTR FILEDLG95_HandleCustomDialogMessages ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1141 of file filedlg.c.

1142{
1144 WCHAR lpstrPath[MAX_PATH];
1145 INT_PTR retval;
1146
1147 if(!fodInfos) return FALSE;
1148
1149 switch(uMsg)
1150 {
1151 case CDM_GETFILEPATH:
1153 break;
1154
1155 case CDM_GETFOLDERPATH:
1156 TRACE("CDM_GETFOLDERPATH:\n");
1157 COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);
1158 if (lParam)
1159 {
1160 if (fodInfos->unicode)
1161 lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);
1162 else
1163 WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
1164 (LPSTR)lParam, (int)wParam, NULL, NULL);
1165 }
1166 retval = lstrlenW(lpstrPath) + 1;
1167 break;
1168
1170 retval = ILGetSize(fodInfos->ShellInfos.pidlAbsCurrent);
1171 if (retval <= wParam)
1172 memcpy((void*)lParam, fodInfos->ShellInfos.pidlAbsCurrent, retval);
1173 break;
1174
1175 case CDM_GETSPEC:
1176 TRACE("CDM_GETSPEC:\n");
1177 retval = SendMessageW(fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0) + 1;
1178 if (lParam)
1179 {
1180 if (fodInfos->unicode)
1181 SendMessageW(fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, wParam, lParam);
1182 else
1183 SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_GETTEXT, wParam, lParam);
1184 }
1185 break;
1186
1187 case CDM_SETCONTROLTEXT:
1188 TRACE("CDM_SETCONTROLTEXT:\n");
1189 if ( lParam )
1190 {
1191 if( fodInfos->unicode )
1193 else
1195 }
1196 retval = TRUE;
1197 break;
1198
1199 case CDM_HIDECONTROL:
1200 /* MSDN states that it should fail for not OFN_EXPLORER case */
1201 if (fodInfos->ofnInfos->Flags & OFN_EXPLORER)
1202 {
1203 HWND control = GetDlgItem( hwnd, wParam );
1204 if (control) ShowWindow( control, SW_HIDE );
1205 retval = TRUE;
1206 }
1207 else retval = FALSE;
1208 break;
1209
1210 default:
1211 if (uMsg >= CDM_FIRST && uMsg <= CDM_LAST)
1212 FIXME("message CDM_FIRST+%04x not implemented\n", uMsg - CDM_FIRST);
1213 return FALSE;
1214 }
1216 return TRUE;
1217}
WPARAM wParam
Definition: combotst.c:138
#define CDM_SETCONTROLTEXT
Definition: commdlg.h:47
#define CDM_GETSPEC
Definition: commdlg.h:43
#define CDM_FIRST
Definition: commdlg.h:41
#define CDM_GETFOLDERIDLIST
Definition: commdlg.h:46
#define CDM_LAST
Definition: commdlg.h:42
#define CDM_HIDECONTROL
Definition: commdlg.h:48
#define CDM_GETFILEPATH
Definition: commdlg.h:44
#define CDM_GETFOLDERPATH
Definition: commdlg.h:45
static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result)
Definition: filedlg.c:1099
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ILGetSize
Definition: shellclasses.h:638
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
BOOL WINAPI SetDlgItemTextA(_In_ HWND, _In_ int, _In_ LPCSTR)
#define DWLP_MSGRESULT
Definition: winuser.h:864
#define SetWindowLongPtrW
Definition: winuser.h:5336

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_InitControls()

static LRESULT FILEDLG95_InitControls ( HWND  hwnd)
static

Definition at line 1629 of file filedlg.c.

1630{
1631 BOOL win2000plus = FALSE;
1632 BOOL win98plus = FALSE;
1633 BOOL handledPath = FALSE;
1634 OSVERSIONINFOW osVi;
1635 static const WCHAR szwSlash[] = { '\\', 0 };
1636 static const WCHAR szwStar[] = { '*',0 };
1637
1638 static const TBBUTTON tbb[] =
1639 {
1640 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1642 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1644 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1646 {0, 0, TBSTATE_ENABLED, BTNS_SEP, {0, 0}, 0, 0 },
1649 };
1650 static const TBADDBITMAP tba = {HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR};
1651
1652 RECT rectTB;
1653 RECT rectlook;
1654
1655 HIMAGELIST toolbarImageList;
1656 ITEMIDLIST *desktopPidl;
1658
1660
1661 TRACE("%p\n", fodInfos);
1662
1663 /* Get windows version emulating */
1664 osVi.dwOSVersionInfoSize = sizeof(osVi);
1665 GetVersionExW(&osVi);
1667 win98plus = ((osVi.dwMajorVersion > 4) || ((osVi.dwMajorVersion == 4) && (osVi.dwMinorVersion > 0)));
1668 } else if (osVi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
1669 win2000plus = (osVi.dwMajorVersion > 4);
1670 if (win2000plus) win98plus = TRUE;
1671 }
1672 TRACE("Running on 2000+ %d, 98+ %d\n", win2000plus, win98plus);
1673
1674
1675 /* Use either the edit or the comboboxex for the filename control */
1676 if (filename_is_edit( fodInfos ))
1677 {
1679 fodInfos->DlgInfos.hwndFileName = GetDlgItem( hwnd, edt1 );
1680 }
1681 else
1682 {
1684 fodInfos->DlgInfos.hwndFileName = GetDlgItem( hwnd, cmb13 );
1685 }
1686
1687 /* Get the hwnd of the controls */
1688 fodInfos->DlgInfos.hwndFileTypeCB = GetDlgItem(hwnd,IDC_FILETYPE);
1689 fodInfos->DlgInfos.hwndLookInCB = GetDlgItem(hwnd,IDC_LOOKIN);
1690
1691 GetWindowRect( fodInfos->DlgInfos.hwndLookInCB,&rectlook);
1692 MapWindowPoints( 0, hwnd,(LPPOINT)&rectlook,2);
1693
1694 /* construct the toolbar */
1696 MapWindowPoints( 0, hwnd,(LPPOINT)&rectTB,2);
1697
1698 rectTB.right = rectlook.right + rectTB.right - rectTB.left;
1699 rectTB.bottom = rectlook.top - 1 + rectTB.bottom - rectTB.top;
1700 rectTB.left = rectlook.right;
1701 rectTB.top = rectlook.top-1;
1702
1703 if (fodInfos->unicode)
1704 fodInfos->DlgInfos.hwndTB = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
1706 rectTB.left, rectTB.top,
1707 rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
1709 else
1710 fodInfos->DlgInfos.hwndTB = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL,
1712 rectTB.left, rectTB.top,
1713 rectTB.right - rectTB.left, rectTB.bottom - rectTB.top,
1715
1716 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
1717
1718/* FIXME: use TB_LOADIMAGES when implemented */
1719/* SendMessageW(fodInfos->DlgInfos.hwndTB, TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);*/
1720 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_SETMAXTEXTROWS, 0, 0);
1721 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBITMAP, 12, (LPARAM) &tba);
1722
1723 /* Retrieve and add desktop icon to the toolbar */
1724 toolbarImageList = (HIMAGELIST)SendMessageW(fodInfos->DlgInfos.hwndTB, TB_GETIMAGELIST, 0, 0L);
1726 SHGetFileInfoW((const WCHAR *)desktopPidl, 0, &fileinfo, sizeof(fileinfo),
1728 ImageList_AddIcon(toolbarImageList, fileinfo.hIcon);
1729
1730 DestroyIcon(fileinfo.hIcon);
1731 CoTaskMemFree(desktopPidl);
1732
1733 /* Finish Toolbar Construction */
1734 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_ADDBUTTONSW, 9, (LPARAM) tbb);
1735 SendMessageW(fodInfos->DlgInfos.hwndTB, TB_AUTOSIZE, 0, 0);
1736
1737 if (is_places_bar_enabled(fodInfos))
1738 {
1739 TBBUTTON tb = { 0 };
1741 RECT rect;
1742 int i, cx;
1743
1746 cx = rect.right - rect.left;
1747
1750
1752 for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
1753 {
1754 int index;
1755
1756 if (!fodInfos->places[i])
1757 continue;
1758
1759 memset(&fileinfo, 0, sizeof(fileinfo));
1760 SHGetFileInfoW((const WCHAR *)fodInfos->places[i], 0, &fileinfo, sizeof(fileinfo),
1763
1764 tb.iBitmap = index;
1765 tb.iString = (INT_PTR)fileinfo.szDisplayName;
1766 tb.fsState = TBSTATE_ENABLED | TBSTATE_WRAP;
1767 tb.idCommand = TBPLACES_CMDID_PLACE0 + i;
1769
1770 DestroyIcon(fileinfo.hIcon);
1771 }
1772
1775 }
1776
1777 /* Set the window text with the text specified in the OPENFILENAME structure */
1778 if(fodInfos->title)
1779 {
1780 SetWindowTextW(hwnd,fodInfos->title);
1781 }
1782 else if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
1783 {
1784 WCHAR buf[64];
1787 }
1788
1789 /* Initialise the file name edit control */
1790 handledPath = FALSE;
1791 TRACE("Before manipulation, file = %s, dir = %s\n", debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
1792
1793 if(fodInfos->filename)
1794 {
1795 /* 1. If win2000 or higher and filename contains a path, use it
1796 in preference over the lpstrInitialDir */
1797 if (win2000plus && *fodInfos->filename && wcspbrk(fodInfos->filename, szwSlash)) {
1798 WCHAR tmpBuf[MAX_PATH];
1799 WCHAR *nameBit;
1800 DWORD result;
1801
1802 result = GetFullPathNameW(fodInfos->filename, MAX_PATH, tmpBuf, &nameBit);
1803 if (result) {
1804
1805 /* nameBit is always shorter than the original filename. It may be NULL
1806 * when the filename contains only a drive name instead of file name */
1807 if (nameBit)
1808 {
1809 lstrcpyW(fodInfos->filename,nameBit);
1810 *nameBit = 0x00;
1811 }
1812 else
1813 *fodInfos->filename = '\0';
1814
1815 heap_free(fodInfos->initdir);
1816 fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
1817 lstrcpyW(fodInfos->initdir, tmpBuf);
1818 handledPath = TRUE;
1819 TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n",
1820 debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
1821 }
1822 SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
1823
1824 } else {
1825 SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
1826 }
1827 }
1828
1829 /* 2. (All platforms) If initdir is not null, then use it */
1830 if (!handledPath && fodInfos->initdir && *fodInfos->initdir)
1831 {
1832 /* Work out the proper path as supplied one might be relative */
1833 /* (Here because supplying '.' as dir browses to My Computer) */
1834 WCHAR tmpBuf[MAX_PATH];
1835 WCHAR tmpBuf2[MAX_PATH];
1836 WCHAR *nameBit;
1837 DWORD result;
1838
1839 lstrcpyW(tmpBuf, fodInfos->initdir);
1840 if (PathFileExistsW(tmpBuf)) {
1841 /* initdir does not have to be a directory. If a file is
1842 * specified, the dir part is taken */
1843 if (PathIsDirectoryW(tmpBuf)) {
1844 PathAddBackslashW(tmpBuf);
1845 lstrcatW(tmpBuf, szwStar);
1846 }
1847 result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
1848 if (result) {
1849 *nameBit = 0x00;
1850 heap_free(fodInfos->initdir);
1851 fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR));
1852 lstrcpyW(fodInfos->initdir, tmpBuf2);
1853 handledPath = TRUE;
1854 TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
1855 }
1856 }
1857 else if (fodInfos->initdir)
1858 {
1859 heap_free(fodInfos->initdir);
1860 fodInfos->initdir = NULL;
1861 TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
1862 }
1863 }
1864
1865#ifdef __REACTOS__
1866 if (!handledPath && (!fodInfos->initdir || !*fodInfos->initdir))
1867 {
1868 /* 2.5. Win2000+: Recently used defext */
1869 if (win2000plus) {
1870 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1871 fodInfos->initdir[0] = '\0';
1872
1873 FILEDLG95_MRU_load_ext(fodInfos->initdir, MAX_PATH, fodInfos->defext);
1874
1875 if (fodInfos->initdir[0] && PathIsDirectoryW(fodInfos->initdir)) {
1876 handledPath = TRUE;
1877 } else {
1878 heap_free(fodInfos->initdir);
1879 fodInfos->initdir = NULL;
1880 }
1881 }
1882 }
1883#endif
1884
1885 if (!handledPath && (!fodInfos->initdir || !*fodInfos->initdir))
1886 {
1887 /* 3. All except w2k+: if filename contains a path use it */
1888 if (!win2000plus && fodInfos->filename &&
1889 *fodInfos->filename &&
1890 wcspbrk(fodInfos->filename, szwSlash)) {
1891 WCHAR tmpBuf[MAX_PATH];
1892 WCHAR *nameBit;
1893 DWORD result;
1894
1896 tmpBuf, &nameBit);
1897 if (result) {
1898 int len;
1899
1900 /* nameBit is always shorter than the original filename */
1901 lstrcpyW(fodInfos->filename, nameBit);
1902 *nameBit = 0x00;
1903
1904 len = lstrlenW(tmpBuf);
1905 heap_free(fodInfos->initdir);
1906 fodInfos->initdir = heap_alloc((len+1)*sizeof(WCHAR));
1907 lstrcpyW(fodInfos->initdir, tmpBuf);
1908
1909 handledPath = TRUE;
1910 TRACE("Value in Filename includes path, overriding initdir: %s, %s\n",
1911 debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
1912 }
1913 SetWindowTextW( fodInfos->DlgInfos.hwndFileName, fodInfos->filename );
1914 }
1915
1916 /* 4. Win2000+: Recently used */
1917 if (!handledPath && win2000plus) {
1918 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1919 fodInfos->initdir[0] = '\0';
1920
1922
1923 if (fodInfos->initdir[0] && PathFileExistsW(fodInfos->initdir)){
1924 handledPath = TRUE;
1925 }else{
1926 heap_free(fodInfos->initdir);
1927 fodInfos->initdir = NULL;
1928 }
1929 }
1930
1931 /* 5. win98+ and win2000+ if any files of specified filter types in
1932 current directory, use it */
1933 if (win98plus && !handledPath && fodInfos->filter && *fodInfos->filter) {
1934
1935 LPCWSTR lpstrPos = fodInfos->filter;
1936 WIN32_FIND_DATAW FindFileData;
1937 HANDLE hFind;
1938
1939 while (1)
1940 {
1941 /* filter is a list... title\0ext\0......\0\0 */
1942
1943 /* Skip the title */
1944 if(! *lpstrPos) break; /* end */
1945 lpstrPos += lstrlenW(lpstrPos) + 1;
1946
1947 /* See if any files exist in the current dir with this extension */
1948 if(! *lpstrPos) break; /* end */
1949
1950 hFind = FindFirstFileW(lpstrPos, &FindFileData);
1951
1952 if (hFind == INVALID_HANDLE_VALUE) {
1953 /* None found - continue search */
1954 lpstrPos += lstrlenW(lpstrPos) + 1;
1955
1956 } else {
1957
1958 heap_free(fodInfos->initdir);
1959 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1961
1962 handledPath = TRUE;
1963 TRACE("No initial dir specified, but files of type %s found in current, so using it\n",
1964 debugstr_w(lpstrPos));
1965 FindClose(hFind);
1966 break;
1967 }
1968 }
1969 }
1970
1971 /* 6. Win98+ and 2000+: Use personal files dir, others use current dir */
1972 if (!handledPath && (win2000plus || win98plus)) {
1973 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1974
1975 if (SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir) == S_OK)
1976 {
1978 {
1979 /* last fallback */
1981 TRACE("No personal or desktop dir, using cwd as failsafe: %s\n", debugstr_w(fodInfos->initdir));
1982 }
1983 else
1984 TRACE("No personal dir, using desktop instead: %s\n", debugstr_w(fodInfos->initdir));
1985 }
1986 else
1987 TRACE("No initial dir specified, using personal files dir of %s\n", debugstr_w(fodInfos->initdir));
1988
1989 handledPath = TRUE;
1990 } else if (!handledPath) {
1991 fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
1993 handledPath = TRUE;
1994 TRACE("No initial dir specified, using current dir of %s\n", debugstr_w(fodInfos->initdir));
1995 }
1996 }
1997 SetFocus( fodInfos->DlgInfos.hwndFileName );
1998 TRACE("After manipulation, file = %s, dir = %s\n", debugstr_w(fodInfos->filename), debugstr_w(fodInfos->initdir));
1999
2000 /* Must the open as read only check box be checked ?*/
2001 if(fodInfos->ofnInfos->Flags & OFN_READONLY)
2002 {
2004 }
2005
2006 /* Must the open as read only check box be hidden? */
2007 if (filedialog_is_readonly_hidden(fodInfos))
2008 {
2011 }
2012
2013 /* Must the help button be hidden? */
2014 if (!(fodInfos->ofnInfos->Flags & OFN_SHOWHELP))
2015 {
2018 }
2019
2020 /* change Open to Save */
2021 if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
2022 {
2023#ifdef __REACTOS__
2024 WCHAR buf[24];
2025#else
2026 WCHAR buf[16];
2027#endif
2032 }
2033
2034 /* Initialize the filter combo box */
2036#ifdef __REACTOS__
2037 DoInitAutoCompleteWithCWD(fodInfos, fodInfos->DlgInfos.hwndFileName);
2038#endif
2039
2040 return 0;
2041}
#define index(s, c)
Definition: various.h:29
HIMAGELIST himl
#define IDS_SAVE_AS
Definition: cdlg.h:180
#define IDS_SAVE_BUTTON
Definition: cdlg.h:177
#define IDS_SAVE_IN
Definition: cdlg.h:178
EXTERN_C HRESULT DoInitAutoCompleteWithCWD(FileOpenDlgInfos *pInfo, HWND hwndEdit)
Definition: autocomp.cpp:12
#define OFN_READONLY
Definition: commdlg.h:118
#define OFN_SHOWHELP
Definition: commdlg.h:120
#define edt1
Definition: dlgs.h:65
#define cmb13
Definition: dlgs.h:60
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define TBPLACES_CMDID_PLACE0
Definition: filedlg.c:202
static void FILEDLG95_MRU_load_filename(LPWSTR stored_path)
Definition: filedlg.c:2576
static void filedlg_collect_places_pidls(FileOpenDlgInfos *fodInfos)
Definition: filedlg.c:378
static BOOL is_places_bar_enabled(const FileOpenDlgInfos *fodInfos)
Definition: filedlg.c:356
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
Definition: filedlg.c:3535
static BOOL filedialog_is_readonly_hidden(const FileOpenDlgInfos *info)
Definition: filedlg.c:239
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
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 GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3194
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2558
BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath)
Definition: path.c:1777
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
#define IDC_TOOLBARPLACES
#define IDC_LOOKINSTATIC
#define IDC_TOOLBARSTATIC
#define IDC_FILETYPE
#define IDC_OPENREADONLY
#define IDC_LOOKIN
GLuint index
Definition: glext.h:6031
static const WCHAR tb[]
Definition: suminfo.c:285
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:238
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:237
#define L(x)
Definition: ntvdm.h:50
#define WS_GROUP
Definition: pedump.c:633
#define BTNS_BUTTON
Definition: commctrl.h:998
#define VIEW_PARENTFOLDER
Definition: commctrl.h:1095
#define TB_AUTOSIZE
Definition: commctrl.h:1137
#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 TB_SETBUTTONSIZE
Definition: commctrl.h:1135
#define CCS_NODIVIDER
Definition: commctrl.h:2248
#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:2245
#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
#define TB_ADDBITMAP
Definition: commctrl.h:1056
#define TB_GETIMAGELIST
Definition: commctrl.h:1151
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_Control)
#define memset(x, y, z)
Definition: compat.h:39
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:415
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:163
#define SHGFI_ICON
Definition: shellapi.h:161
#define SHGFI_SMALLICON
Definition: shellapi.h:173
#define SHGFI_PIDL
Definition: shellapi.h:177
#define CSIDL_FLAG_CREATE
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2040
#define CSIDL_PERSONAL
Definition: shlobj.h:2030
#define CSIDL_DESKTOP
Definition: shlobj.h:2025
#define FCIDM_TB_DESKTOP
Definition: shresdef.h:836
#define FCIDM_TB_NEWFOLDER
Definition: shresdef.h:833
#define FCIDM_TB_SMALLICON
Definition: shresdef.h:834
#define FCIDM_TB_UPFOLDER
Definition: shresdef.h:832
#define FCIDM_TB_REPORTVIEW
Definition: shresdef.h:835
& rect
Definition: startmenu.cpp:1413
LPITEMIDLIST places[5]
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwPlatformId
Definition: rtltypes.h:250
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
ULONG dwMajorVersion
Definition: rtltypes.h:247
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
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)
#define IDOK
Definition: winuser.h:824
#define BM_SETCHECK
Definition: winuser.h:1911
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SM_CYICON
Definition: winuser.h:967
HWND WINAPI SetFocus(_In_opt_ HWND)
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)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SM_CXICON
Definition: winuser.h:966
BOOL WINAPI DestroyWindow(_In_ HWND)
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define IDC_TOOLBAR
Definition: wordpad.h:157

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_LOOKIN_AddItem()

static int FILEDLG95_LOOKIN_AddItem ( HWND  hwnd,
LPITEMIDLIST  pidl,
int  iInsertId 
)
static

Definition at line 3990 of file filedlg.c.

3991{
3992 LPITEMIDLIST pidlNext;
3993 SHFILEINFOW sfi;
3994 SFOLDER *tmpFolder;
3995 LookInInfos *liInfos;
3996
3997 TRACE("%p, %p, %d\n", hwnd, pidl, iInsertId);
3998
3999 if(!pidl)
4000 return -1;
4001
4002 if(!(liInfos = GetPropA(hwnd,LookInInfosStr)))
4003 return -1;
4004
4005 tmpFolder = heap_alloc_zero(sizeof(*tmpFolder));
4006 tmpFolder->m_iIndent = 0;
4007
4008 /* Calculate the indentation of the item in the lookin*/
4009 pidlNext = pidl;
4010 while ((pidlNext = ILGetNext(pidlNext)))
4011 {
4012 tmpFolder->m_iIndent++;
4013 }
4014
4015 tmpFolder->pidlItem = ILClone(pidl);
4016
4017 if(tmpFolder->m_iIndent > liInfos->iMaxIndentation)
4018 liInfos->iMaxIndentation = tmpFolder->m_iIndent;
4019
4020 sfi.dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
4021 SHGetFileInfoW((LPCWSTR)pidl,
4022 0,
4023 &sfi,
4024 sizeof(sfi),
4026
4027 TRACE("-- Add %s attr=0x%08x\n", debugstr_w(sfi.szDisplayName), sfi.dwAttributes);
4028
4029 if((sfi.dwAttributes & SFGAO_FILESYSANCESTOR) || (sfi.dwAttributes & SFGAO_FILESYSTEM))
4030 {
4031 int iItemID;
4032
4033 TRACE("-- Add %s at %u\n", debugstr_w(sfi.szDisplayName), tmpFolder->m_iIndent);
4034
4035 /* Add the item at the end of the list */
4036 if(iInsertId < 0)
4037 {
4038 iItemID = SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)sfi.szDisplayName);
4039 }
4040 /* Insert the item at the iInsertId position*/
4041 else
4042 {
4043 iItemID = SendMessageW(hwnd, CB_INSERTSTRING, iInsertId, (LPARAM)sfi.szDisplayName);
4044 }
4045
4046 SendMessageW(hwnd, CB_SETITEMDATA, iItemID, (LPARAM)tmpFolder);
4047 return iItemID;
4048 }
4049
4050 ILFree( tmpFolder->pidlItem );
4051 heap_free( tmpFolder );
4052 return -1;
4053
4054}
static const char LookInInfosStr[]
Definition: filedlg.c:217
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
#define SHGFI_ATTR_SPECIFIED
Definition: shellapi.h:171
#define SHGFI_ATTRIBUTES
Definition: shellapi.h:165
int m_iIndent
Definition: filedlg.c:100
LPITEMIDLIST pidlItem
Definition: filedlg.c:101
DWORD dwAttributes
Definition: shellapi.h:371
WCHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:372
int iMaxIndentation
Definition: filedlg.c:107
HANDLE WINAPI GetPropA(_In_ HWND, _In_ LPCSTR)
#define CB_INSERTSTRING
Definition: winuser.h:1947

Referenced by FILEDLG95_LOOKIN_Init(), and FILEDLG95_LOOKIN_InsertItemAfterParent().

◆ FILEDLG95_LOOKIN_Clean()

static void FILEDLG95_LOOKIN_Clean ( HWND  hwnd)
static

Definition at line 4193 of file filedlg.c.

4194{
4196 LookInInfos *liInfos = GetPropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
4197 int iPos, iCount;
4198
4199 iCount = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCOUNT, 0, 0);
4200
4201 TRACE("\n");
4202
4203 /* Delete each string of the combo and their associated data */
4204 if (iCount != CB_ERR)
4205 {
4206 for(iPos = iCount-1;iPos>=0;iPos--)
4207 {
4208 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos);
4209 ILFree(tmpFolder->pidlItem);
4210 heap_free(tmpFolder);
4211 SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_DELETESTRING, iPos, 0);
4212 }
4213 }
4214
4215 /* LookInInfos structure */
4216 heap_free(liInfos);
4217 RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
4218}
struct SFolder * LPSFOLDER
HANDLE WINAPI RemovePropA(_In_ HWND, _In_ LPCSTR)

Referenced by FILEDLG95_Clean().

◆ FILEDLG95_LOOKIN_DrawItem()

static LRESULT FILEDLG95_LOOKIN_DrawItem ( LPDRAWITEMSTRUCT  pDIStruct)
static

Definition at line 3854 of file filedlg.c.

3855{
3857 COLORREF crHighLight = GetSysColor(COLOR_HIGHLIGHT);
3859 RECT rectText;
3860 RECT rectIcon;
3861 SHFILEINFOW sfi;
3862 HIMAGELIST ilItemImage;
3863 int iIndentation;
3865 LPSFOLDER tmpFolder;
3867 UINT icon_width, icon_height;
3868
3869 TRACE("\n");
3870
3871 if(pDIStruct->itemID == -1)
3872 return 0;
3873
3874 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(pDIStruct->hwndItem,
3875 pDIStruct->itemID)))
3876 return 0;
3877
3878
3879 icon_width = GetSystemMetrics(SM_CXICON);
3880 icon_height = GetSystemMetrics(SM_CYICON);
3881 if (pDIStruct->rcItem.bottom - pDIStruct->rcItem.top < icon_height)
3882 {
3883 icon_width = GetSystemMetrics(SM_CXSMICON);
3884 icon_height = GetSystemMetrics(SM_CYSMICON);
3885 shgfi_flags |= SHGFI_SMALLICON;
3886 }
3887
3888 ilItemImage = (HIMAGELIST) SHGetFileInfoW ((LPCWSTR) tmpFolder->pidlItem,
3889 0, &sfi, sizeof (sfi), shgfi_flags );
3890
3891 /* Is this item selected ? */
3892 if(pDIStruct->itemState & ODS_SELECTED)
3893 {
3894 SetTextColor(pDIStruct->hDC,(0x00FFFFFF & ~(crText)));
3895 SetBkColor(pDIStruct->hDC,crHighLight);
3896 FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_HIGHLIGHT));
3897 }
3898 else
3899 {
3900 SetTextColor(pDIStruct->hDC,crText);
3901 SetBkColor(pDIStruct->hDC,crWin);
3902 FillRect(pDIStruct->hDC,&pDIStruct->rcItem,GetSysColorBrush(COLOR_WINDOW));
3903 }
3904
3905 /* Do not indent item if drawing in the edit of the combo */
3906 if(pDIStruct->itemState & ODS_COMBOBOXEDIT)
3907 iIndentation = 0;
3908 else
3909 iIndentation = tmpFolder->m_iIndent;
3910
3911 /* Draw text and icon */
3912
3913 /* Initialise the icon display area */
3914 rectIcon.left = pDIStruct->rcItem.left + 1 + icon_width/2 * iIndentation;
3915 rectIcon.top = (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - icon_height) / 2;
3916 rectIcon.right = rectIcon.left + icon_width + XTEXTOFFSET;
3917 rectIcon.bottom = (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + icon_height) / 2;
3918
3919 /* Initialise the text display area */
3920 GetTextMetricsW(pDIStruct->hDC, &tm);
3921 rectText.left = rectIcon.right;
3922 rectText.top =
3923 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom - tm.tmHeight) / 2;
3924 rectText.right = pDIStruct->rcItem.right;
3925 rectText.bottom =
3926 (pDIStruct->rcItem.top + pDIStruct->rcItem.bottom + tm.tmHeight) / 2;
3927
3928 /* Draw the icon from the image list */
3929 ImageList_Draw(ilItemImage,
3930 sfi.iIcon,
3931 pDIStruct->hDC,
3932 rectIcon.left,
3933 rectIcon.top,
3935
3936 /* Draw the associated text */
3937 TextOutW(pDIStruct->hDC,rectText.left,rectText.top,sfi.szDisplayName,lstrlenW(sfi.szDisplayName));
3938 return NOERROR;
3939}
BOOL WINAPI ImageList_Draw(HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
Definition: imagelist.c:1228
#define XTEXTOFFSET
Definition: filedlg.c:189
#define ILD_TRANSPARENT
Definition: commctrl.h:418
#define SHGFI_OPENICON
Definition: shellapi.h:175
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:168
Definition: time.h:68
DWORD COLORREF
Definition: windef.h:300
#define NOERROR
Definition: winerror.h:2354
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
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:918
DWORD WINAPI GetSysColor(_In_ int)
#define ODS_SELECTED
Definition: winuser.h:2535
#define COLOR_WINDOW
Definition: winuser.h:912
#define COLOR_WINDOWTEXT
Definition: winuser.h:915
#define COLOR_HIGHLIGHT
Definition: winuser.h:920
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define SM_CYSMICON
Definition: winuser.h:1007
#define SM_CXSMICON
Definition: winuser.h:1006

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_LOOKIN_Init()

static void FILEDLG95_LOOKIN_Init ( HWND  hwndCombo)
static

Definition at line 3769 of file filedlg.c.

3770{
3771 IShellFolder *psfRoot, *psfDrives;
3772 IEnumIDList *lpeRoot, *lpeDrives;
3773 LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
3774 HDC hdc;
3776 LookInInfos *liInfos = heap_alloc_zero(sizeof(*liInfos));
3777
3778 TRACE("%p\n", hwndCombo);
3779
3780 liInfos->iMaxIndentation = 0;
3781
3782 SetPropA(hwndCombo, LookInInfosStr, liInfos);
3783
3784 hdc = GetDC( hwndCombo );
3785 SelectObject( hdc, (HFONT)SendMessageW( hwndCombo, WM_GETFONT, 0, 0 ));
3786 GetTextMetricsW( hdc, &tm );
3787 ReleaseDC( hwndCombo, hdc );
3788
3789 /* set item height for both text field and listbox */
3790 SendMessageW(hwndCombo, CB_SETITEMHEIGHT, -1, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
3791 SendMessageW(hwndCombo, CB_SETITEMHEIGHT, 0, max(tm.tmHeight, GetSystemMetrics(SM_CYSMICON)));
3792
3793 /* Turn on the extended UI for the combo box like Windows does */
3794 SendMessageW(hwndCombo, CB_SETEXTENDEDUI, TRUE, 0);
3795
3796 /* Initialise data of Desktop folder */
3798 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
3799 ILFree(pidlTmp);
3800
3802
3803 SHGetDesktopFolder(&psfRoot);
3804
3805 if (psfRoot)
3806 {
3807 /* enumerate the contents of the desktop */
3808 if(SUCCEEDED(IShellFolder_EnumObjects(psfRoot, hwndCombo, SHCONTF_FOLDERS, &lpeRoot)))
3809 {
3810 while (S_OK == IEnumIDList_Next(lpeRoot, 1, &pidlTmp, NULL))
3811 {
3812 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlTmp,LISTEND);
3813
3814 /* If the unixfs extension is rooted, we don't expand the drives by default */
3816 {
3817 /* special handling for CSIDL_DRIVES */
3818 if (ILIsEqual(pidlTmp, pidlDrives))
3819 {
3820 if(SUCCEEDED(IShellFolder_BindToObject(psfRoot, pidlTmp, NULL, &IID_IShellFolder, (LPVOID*)&psfDrives)))
3821 {
3822 /* enumerate the drives */
3823 if(SUCCEEDED(IShellFolder_EnumObjects(psfDrives, hwndCombo,SHCONTF_FOLDERS, &lpeDrives)))
3824 {
3825 while (S_OK == IEnumIDList_Next(lpeDrives, 1, &pidlTmp1, NULL))
3826 {
3827 pidlAbsTmp = ILCombine(pidlTmp, pidlTmp1);
3828 FILEDLG95_LOOKIN_AddItem(hwndCombo, pidlAbsTmp,LISTEND);
3829 ILFree(pidlAbsTmp);
3830 ILFree(pidlTmp1);
3831 }
3832 IEnumIDList_Release(lpeDrives);
3833 }
3834 IShellFolder_Release(psfDrives);
3835 }
3836 }
3837 }
3838
3839 ILFree(pidlTmp);
3840 }
3841 IEnumIDList_Release(lpeRoot);
3842 }
3843 IShellFolder_Release(psfRoot);
3844 }
3845
3846 ILFree(pidlDrives);
3847}
#define LISTEND
Definition: filedlg.c:192
static int FILEDLG95_LOOKIN_AddItem(HWND hwnd, LPITEMIDLIST pidl, int iInsertId)
Definition: filedlg.c:3990
static BOOL FILEDLG95_unixfs_is_rooted_at_desktop(void)
Definition: filedlg.c:3752
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:535
#define CSIDL_DRIVES
Definition: shlobj.h:2041
#define max(a, b)
Definition: svc.c:63
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI SetPropA(_In_ HWND, _In_ LPCSTR, _In_opt_ HANDLE)
#define WM_GETFONT
Definition: winuser.h:1641
HDC WINAPI GetDC(_In_opt_ HWND)
#define CB_SETEXTENDEDUI
Definition: winuser.h:1954
#define CB_SETITEMHEIGHT
Definition: winuser.h:1957

Referenced by FILEDLG95_FillControls().

◆ FILEDLG95_LOOKIN_InsertItemAfterParent()

static int FILEDLG95_LOOKIN_InsertItemAfterParent ( HWND  hwnd,
LPITEMIDLIST  pidl 
)
static

Definition at line 4061 of file filedlg.c.

4062{
4063
4064 LPITEMIDLIST pidlParent = GetParentPidl(pidl);
4065 int iParentPos;
4066
4067 TRACE("\n");
4068
4069 if (pidl == pidlParent)
4070 return -1;
4071
4072 iParentPos = FILEDLG95_LOOKIN_SearchItem(hwnd,(WPARAM)pidlParent,SEARCH_PIDL);
4073
4074 if(iParentPos < 0)
4075 {
4076 iParentPos = FILEDLG95_LOOKIN_InsertItemAfterParent(hwnd,pidlParent);
4077 }
4078
4079 ILFree(pidlParent);
4080
4081 return FILEDLG95_LOOKIN_AddItem(hwnd,pidl,iParentPos + 1);
4082}
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl)
Definition: filedlg.c:4525
#define SEARCH_PIDL
Definition: filedlg.c:195
static int FILEDLG95_LOOKIN_SearchItem(HWND hwnd, WPARAM searchArg, int iSearchMethod)
Definition: filedlg.c:4163
static int FILEDLG95_LOOKIN_InsertItemAfterParent(HWND hwnd, LPITEMIDLIST pidl)
Definition: filedlg.c:4061
UINT_PTR WPARAM
Definition: windef.h:207

Referenced by FILEDLG95_LOOKIN_InsertItemAfterParent(), and FILEDLG95_LOOKIN_SelectItem().

◆ FILEDLG95_LOOKIN_OnCommand()

static BOOL FILEDLG95_LOOKIN_OnCommand ( HWND  hwnd,
WORD  wNotifyCode 
)
static

Definition at line 3947 of file filedlg.c.

3948{
3950
3951 TRACE("%p\n", fodInfos);
3952
3953 switch(wNotifyCode)
3954 {
3955 case CBN_SELENDOK:
3956 {
3957 LPSFOLDER tmpFolder;
3958 int iItem;
3959
3960 iItem = SendMessageW(fodInfos->DlgInfos.hwndLookInCB, CB_GETCURSEL, 0, 0);
3961
3962 if( iItem == CB_ERR) return FALSE;
3963
3964 if(!(tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,
3965 iItem)))
3966 return FALSE;
3967
3968
3969 if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
3970 tmpFolder->pidlItem,
3971 SBSP_ABSOLUTE)))
3972 {
3973 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
3975 return TRUE;
3976 }
3977 break;
3978 }
3979
3980 }
3981 return FALSE;
3982}

Referenced by FILEDLG95_OnWMCommand().

◆ FILEDLG95_LOOKIN_RemoveMostExpandedItem()

static int FILEDLG95_LOOKIN_RemoveMostExpandedItem ( HWND  hwnd)
static

Definition at line 4133 of file filedlg.c.

4134{
4135 int iItemPos;
4137
4138 TRACE("\n");
4139
4140 if(liInfos->iMaxIndentation <= 2)
4141 return -1;
4142
4143 if((iItemPos = FILEDLG95_LOOKIN_SearchItem(hwnd,liInfos->iMaxIndentation,SEARCH_EXP)) >=0)
4144 {
4145 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
4146 ILFree(tmpFolder->pidlItem);
4147 heap_free(tmpFolder);
4148 SendMessageW(hwnd, CB_DELETESTRING, iItemPos, 0);
4149 liInfos->iMaxIndentation--;
4150
4151 return iItemPos;
4152 }
4153
4154 return -1;
4155}
#define SEARCH_EXP
Definition: filedlg.c:196

Referenced by FILEDLG95_LOOKIN_SelectItem().

◆ FILEDLG95_LOOKIN_SearchItem()

static int FILEDLG95_LOOKIN_SearchItem ( HWND  hwnd,
WPARAM  searchArg,
int  iSearchMethod 
)
static

Definition at line 4163 of file filedlg.c.

4164{
4165 int i = 0;
4166 int iCount;
4167
4168 iCount = SendMessageW(hwnd, CB_GETCOUNT, 0, 0);
4169
4170 TRACE("0x%08lx 0x%x\n",searchArg, iSearchMethod);
4171
4172 if (iCount != CB_ERR)
4173 {
4174 for(;i<iCount;i++)
4175 {
4176 LPSFOLDER tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,i);
4177
4178 if (iSearchMethod == SEARCH_PIDL && ILIsEqual((LPITEMIDLIST)searchArg, tmpFolder->pidlItem))
4179 return i;
4180 if(iSearchMethod == SEARCH_EXP && tmpFolder->m_iIndent == (int)searchArg)
4181 return i;
4182 }
4183 }
4184
4185 return -1;
4186}

Referenced by FILEDLG95_LOOKIN_InsertItemAfterParent(), FILEDLG95_LOOKIN_RemoveMostExpandedItem(), and FILEDLG95_LOOKIN_SelectItem().

◆ FILEDLG95_LOOKIN_SelectItem()

int FILEDLG95_LOOKIN_SelectItem ( HWND  hwnd,
LPITEMIDLIST  pidl 
)

Definition at line 4090 of file filedlg.c.

4091{
4092 int iItemPos;
4093 LookInInfos *liInfos;
4094
4095 TRACE("%p, %p\n", hwnd, pidl);
4096
4098
4099 liInfos = GetPropA(hwnd,LookInInfosStr);
4100
4101 if(iItemPos < 0)
4102 {
4105 }
4106
4107 else
4108 {
4109 SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
4110 while(liInfos->iMaxIndentation > tmpFolder->m_iIndent)
4111 {
4112 int iRemovedItem;
4113
4114 if(-1 == (iRemovedItem = FILEDLG95_LOOKIN_RemoveMostExpandedItem(hwnd)))
4115 break;
4116 if(iRemovedItem < iItemPos)
4117 iItemPos--;
4118 }
4119 }
4120
4121 SendMessageW(hwnd, CB_SETCURSEL, iItemPos, 0);
4122 liInfos->uSelectedItem = iItemPos;
4123
4124 return 0;
4125
4126}
static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
Definition: filedlg.c:4133
UINT uSelectedItem
Definition: filedlg.c:108

Referenced by IShellBrowserImpl_BrowseObject().

◆ FILEDLG95_MRU_get_slot()

static WCHAR FILEDLG95_MRU_get_slot ( LPCWSTR  module_name,
LPWSTR  stored_path,
PHKEY  hkey_ret 
)
static

Definition at line 2414 of file filedlg.c.

2415{
2416 WCHAR mru_list[32], *cur_mru_slot;
2417 BOOL taken[25] = {0};
2418 DWORD mru_list_size = sizeof(mru_list), key_type = -1, i;
2419 HKEY hkey_tmp, *hkey;
2420 LONG ret;
2421
2422 if(hkey_ret)
2423 hkey = hkey_ret;
2424 else
2425 hkey = &hkey_tmp;
2426
2427 if(stored_path)
2428 *stored_path = '\0';
2429
2431 if(ret){
2432 WARN("Unable to create MRU key: %d\n", ret);
2433 return 0;
2434 }
2435
2436 ret = RegGetValueW(*hkey, NULL, MRUListW, RRF_RT_REG_SZ, &key_type,
2437 (LPBYTE)mru_list, &mru_list_size);
2438 if(ret || key_type != REG_SZ){
2440 return 'a';
2441
2442 WARN("Error getting MRUList data: type: %d, ret: %d\n", key_type, ret);
2443 RegCloseKey(*hkey);
2444 return 0;
2445 }
2446
2447 for(cur_mru_slot = mru_list; *cur_mru_slot; ++cur_mru_slot){
2448 WCHAR value_data[MAX_PATH], value_name[2] = {0};
2449 DWORD value_data_size = sizeof(value_data);
2450
2451 *value_name = *cur_mru_slot;
2452
2453 ret = RegGetValueW(*hkey, NULL, value_name, RRF_RT_REG_BINARY,
2454 &key_type, (LPBYTE)value_data, &value_data_size);
2455 if(ret || key_type != REG_BINARY){
2456 WARN("Error getting MRU slot data: type: %d, ret: %d\n", key_type, ret);
2457 continue;
2458 }
2459
2460 if(!wcsicmp(module_name, value_data)){
2461 if(!hkey_ret)
2462 RegCloseKey(*hkey);
2463 if(stored_path)
2464 lstrcpyW(stored_path, value_data + lstrlenW(value_data) + 1);
2465 return *value_name;
2466 }
2467 }
2468
2469 if(!hkey_ret)
2470 RegCloseKey(*hkey);
2471
2472 /* the module name isn't in the registry, so find the next open slot */
2473 for(cur_mru_slot = mru_list; *cur_mru_slot; ++cur_mru_slot)
2474 taken[*cur_mru_slot - 'a'] = TRUE;
2475 for(i = 0; i < 25; ++i){
2476 if(!taken[i])
2477 return i + 'a';
2478 }
2479
2480 /* all slots are taken, so return the last one in MRUList */
2481 --cur_mru_slot;
2482 return *cur_mru_slot;
2483}
#define WARN(fmt,...)
Definition: debug.h:112
#define RegCloseKey(hKey)
Definition: registry.h:47
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:170
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1965
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
static const WCHAR MRUListW[]
Definition: filedlg.c:225
static const WCHAR LastVisitedMRUW[]
Definition: filedlg.c:220
#define wcsicmp
Definition: compat.h:15
#define RRF_RT_REG_BINARY
Definition: driver.c:577
#define RRF_RT_REG_SZ
Definition: driver.c:575
#define REG_SZ
Definition: layer.c:22
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define REG_BINARY
Definition: nt_native.h:1496
long LONG
Definition: pedump.c:60
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by FILEDLG95_MRU_load_filename(), and FILEDLG95_MRU_save_filename().

◆ FILEDLG95_MRU_load_filename()

static void FILEDLG95_MRU_load_filename ( LPWSTR  stored_path)
static

Definition at line 2576 of file filedlg.c.

2577{
2578 WCHAR module_path[MAX_PATH], *module_name;
2579
2580 /* get the current executable's name */
2581 if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
2582 {
2583 WARN("GotModuleFileName failed: %d\n", GetLastError());
2584 return;
2585 }
2586 module_name = wcsrchr(module_path, '\\');
2587 if(!module_name)
2588 module_name = module_path;
2589 else
2590 module_name += 1;
2591
2593 TRACE("got MRU path: %s\n", wine_dbgstr_w(stored_path));
2594}
static WCHAR FILEDLG95_MRU_get_slot(LPCWSTR module_name, LPWSTR stored_path, PHKEY hkey_ret)
Definition: filedlg.c:2414
#define wcsrchr
Definition: compat.h:16
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define wine_dbgstr_w
Definition: kernel32.h:34
DWORD WINAPI GetLastError(void)
Definition: except.c:1040

Referenced by FILEDLG95_InitControls().

◆ FILEDLG95_MRU_save_filename()

static void FILEDLG95_MRU_save_filename ( LPCWSTR  filename)
static

Definition at line 2486 of file filedlg.c.

2487{
2488 WCHAR module_path[MAX_PATH], *module_name, slot, slot_name[2] = {0};
2489 LONG ret;
2490 HKEY hkey;
2491
2492 /* get the current executable's name */
2493 if (!GetModuleFileNameW(GetModuleHandleW(NULL), module_path, ARRAY_SIZE(module_path)))
2494 {
2495 WARN("GotModuleFileName failed: %d\n", GetLastError());
2496 return;
2497 }
2498 module_name = wcsrchr(module_path, '\\');
2499 if(!module_name)
2500 module_name = module_path;
2501 else
2502 module_name += 1;
2503
2505 if(!slot)
2506 return;
2507 *slot_name = slot;
2508
2509 { /* update the slot's info */
2510 WCHAR *path_ends, *final;
2511 DWORD path_len, final_len;
2512
2513 /* use only the path segment of `filename' */
2514 path_ends = wcsrchr(filename, '\\');
2515 path_len = path_ends - filename;
2516
2517 final_len = path_len + lstrlenW(module_name) + 2;
2518
2519 final = heap_alloc(final_len * sizeof(WCHAR));
2520 if(!final)
2521 return;
2522 lstrcpyW(final, module_name);
2523 memcpy(final + lstrlenW(final) + 1, filename, path_len * sizeof(WCHAR));
2524 final[final_len-1] = '\0';
2525
2526 ret = RegSetValueExW(hkey, slot_name, 0, REG_BINARY, (LPBYTE)final,
2527 final_len * sizeof(WCHAR));
2528 if(ret){
2529 WARN("Error saving MRU data to slot %s: %d\n", wine_dbgstr_w(slot_name), ret);
2530 heap_free(final);
2531 RegCloseKey(hkey);
2532 return;
2533 }
2534
2535 heap_free(final);
2536 }
2537
2538 { /* update MRUList value */
2539 WCHAR old_mru_list[32], new_mru_list[32];
2540 WCHAR *old_mru_slot, *new_mru_slot = new_mru_list;
2541 DWORD mru_list_size = sizeof(old_mru_list), key_type;
2542
2543 ret = RegGetValueW(hkey, NULL, MRUListW, RRF_RT_ANY, &key_type,
2544 (LPBYTE)old_mru_list, &mru_list_size);
2545 if(ret || key_type != REG_SZ){
2547 new_mru_list[0] = slot;
2548 new_mru_list[1] = '\0';
2549 }else{
2550 WARN("Error getting MRUList data: type: %d, ret: %d\n", key_type, ret);
2551 RegCloseKey(hkey);
2552 return;
2553 }
2554 }else{
2555 /* copy old list data over so that the new slot is at the start
2556 * of the list */
2557 *new_mru_slot++ = slot;
2558 for(old_mru_slot = old_mru_list; *old_mru_slot; ++old_mru_slot){
2559 if(*old_mru_slot != slot)
2560 *new_mru_slot++ = *old_mru_slot;
2561 }
2562 *new_mru_slot = '\0';
2563 }
2564
2565 ret = RegSetValueExW(hkey, MRUListW, 0, REG_SZ, (LPBYTE)new_mru_list,
2566 (lstrlenW(new_mru_list) + 1) * sizeof(WCHAR));
2567 if(ret){
2568 WARN("Error saving MRUList data: %d\n", ret);
2569 RegCloseKey(hkey);
2570 return;
2571 }
2572 }
2573}
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:4900
const char * filename
Definition: ioapi.h:137
static DWORD path_len
Definition: batch.c:31
Definition: vfat.h:185
struct _slot slot
Definition: vfat.h:196
#define RRF_RT_ANY
Definition: winreg.h:64

Referenced by FILEDLG95_OnOpen().

◆ FILEDLG95_OnOpen()

BOOL FILEDLG95_OnOpen ( HWND  hwnd)
static

Definition at line 2953 of file filedlg.c.

2954{
2956 LPWSTR lpstrFileList;
2957 UINT nFileCount = 0;
2958 UINT sizeUsed = 0;
2959 BOOL ret = TRUE;
2960 WCHAR lpstrPathAndFile[MAX_PATH];
2961 LPSHELLFOLDER lpsf = NULL;
2962 int nOpenAction;
2963
2964 TRACE("hwnd=%p\n", hwnd);
2965
2966 /* try to browse the selected item */
2968 return FALSE;
2969
2970 /* get the files from the edit control */
2971 nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed);
2972
2973 if(nFileCount == 0)
2974 return FALSE;
2975
2976 if(nFileCount > 1)
2977 {
2978 ret = FILEDLG95_OnOpenMultipleFiles(hwnd, lpstrFileList, nFileCount, sizeUsed);
2979 goto ret;
2980 }
2981
2982 TRACE("count=%u len=%u file=%s\n", nFileCount, sizeUsed, debugstr_w(lpstrFileList));
2983
2984/*
2985 Step 1: Build a complete path name from the current folder and
2986 the filename or path in the edit box.
2987 Special cases:
2988 - the path in the edit box is a root path
2989 (with or without drive letter)
2990 - the edit box contains ".." (or a path with ".." in it)
2991*/
2992
2993 COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile);
2994 heap_free(lpstrFileList);
2995
2996/*
2997 Step 2: here we have a cleaned up path
2998
2999 We have to parse the path step by step to see if we have to browse
3000 to a folder if the path points to a directory or the last
3001 valid element is a directory.
3002
3003 valid variables:
3004 lpstrPathAndFile: cleaned up path
3005 */
3006
3007 if (nFileCount &&
3008 (fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
3009 !(fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST))
3010 nOpenAction = ONOPEN_OPEN;
3011 else
3012 nOpenAction = ONOPEN_BROWSE;
3013
3014 nOpenAction = FILEDLG95_ValidatePathAction(lpstrPathAndFile, &lpsf, hwnd,
3015 fodInfos->ofnInfos->Flags,
3016 fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG,
3017 nOpenAction);
3018 if(!nOpenAction)
3019 goto ret;
3020
3021/*
3022 Step 3: here we have a cleaned up and validated path
3023
3024 valid variables:
3025 lpsf: ShellFolder bound to the rightmost valid path component
3026 lpstrPathAndFile: cleaned up path
3027 nOpenAction: action to do
3028*/
3029 TRACE("end validate sf=%p\n", lpsf);
3030
3031 switch(nOpenAction)
3032 {
3033 case ONOPEN_SEARCH: /* set the current filter to the file mask and refresh */
3034 TRACE("ONOPEN_SEARCH %s\n", debugstr_w(lpstrPathAndFile));
3035 {
3036 int iPos;
3037 LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);
3038 DWORD len;
3039
3040 /* replace the current filter */
3041 heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
3042 len = lstrlenW(lpszTemp)+1;
3043 fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc(len * sizeof(WCHAR));
3044 lstrcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
3045
3046 /* set the filter cb to the extension when possible */
3047 if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))
3048 SendMessageW(fodInfos->DlgInfos.hwndFileTypeCB, CB_SETCURSEL, iPos, 0);
3049 }
3050 /* fall through */
3051 case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */
3052 TRACE("ONOPEN_BROWSE\n");
3053 {
3054 IPersistFolder2 * ppf2;
3055 if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))
3056 {
3057 LPITEMIDLIST pidlCurrent;
3058 IPersistFolder2_GetCurFolder(ppf2, &pidlCurrent);
3059 IPersistFolder2_Release(ppf2);
3060 if (!ILIsEqual(pidlCurrent, fodInfos->ShellInfos.pidlAbsCurrent))
3061 {
3062 if (SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE))
3063 && fodInfos->ofnInfos->Flags & OFN_EXPLORER)
3064 {
3066 SendMessageA(fodInfos->DlgInfos.hwndFileName, WM_SETTEXT, 0, (LPARAM)"");
3067 }
3068 }
3069 else if( nOpenAction == ONOPEN_SEARCH )
3070 {
3071 if (fodInfos->Shell.FOIShellView)
3072 IShellView_Refresh(fodInfos->Shell.FOIShellView);
3073 }
3074 ILFree(pidlCurrent);
3075 if (filename_is_edit( fodInfos ))
3076 SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
3077 else
3078 {
3079 HWND hwnd;
3080
3081 hwnd = (HWND)SendMessageA(fodInfos->DlgInfos.hwndFileName, CBEM_GETEDITCONTROL, 0, 0);
3082 SendMessageW(hwnd, EM_SETSEL, 0, -1);
3083 }
3084 }
3085 }
3086 ret = FALSE;
3087 break;
3088 case ONOPEN_OPEN: /* fill in the return struct and close the dialog */
3089 TRACE("ONOPEN_OPEN %s\n", debugstr_w(lpstrPathAndFile));
3090 {
3091 WCHAR *ext = NULL;
3092
3093 /* update READONLY check box flag */
3095 fodInfos->ofnInfos->Flags |= OFN_READONLY;
3096 else
3097 fodInfos->ofnInfos->Flags &= ~OFN_READONLY;
3098
3099 /* Attach the file extension with file name*/
3100 ext = PathFindExtensionW(lpstrPathAndFile);
3101#ifdef __REACTOS__
3102 {
3103 LPWSTR filterExt = NULL, lpstrFilter = NULL, pch, pchNext;
3104 LPCWSTR the_ext = NULL;
3105 static const WCHAR szwDot[] = {'.',0};
3106 int PathLength = lstrlenW(lpstrPathAndFile);
3107
3108 /* get filter extensions */
3109 lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
3110 fodInfos->ofnInfos->nFilterIndex - 1);
3111 if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
3112 {
3113 LPWSTR filterSearchIndex, pchFirst = NULL;
3114 filterExt = heap_alloc((lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR));
3115 if (filterExt)
3116 {
3117 strcpyW(filterExt, lpstrFilter);
3118
3119 if (ext && *ext)
3120 {
3121 /* find ext in filter */
3122 for (pch = filterExt; pch && *pch; pch = pchNext)
3123 {
3124 filterSearchIndex = strchrW(pch, ';');
3125 if (filterSearchIndex)
3126 {
3127 filterSearchIndex[0] = 0;
3128 pchNext = filterSearchIndex + 1;
3129 }
3130 else
3131 {
3132 pchNext = NULL;
3133 }
3134
3135 while (*pch == '*' || *pch == '.' || *pch == '?')
3136 {
3137 ++pch;
3138 }
3139
3140 if (!pchFirst)
3141 pchFirst = pch;
3142
3143 if (lstrcmpiW(pch, &ext[1]) == 0)
3144 {
3145 the_ext = pch;
3146 break;
3147 }
3148 }
3149
3150 /* use first one if not found */
3151 if (!the_ext && pchFirst && *pchFirst)
3152 {
3153 the_ext = pchFirst;
3154 }
3155 }
3156 }
3157 }
3158
3159 if (!the_ext)
3160 {
3161 /* use default extension if no extension in filter */
3162 the_ext = fodInfos->defext;
3163 }
3164
3165 if (the_ext && *the_ext && lstrcmpiW(&ext[1], the_ext) != 0)
3166 {
3167 if (strlenW(lpstrPathAndFile) + 1 + strlenW(the_ext) + 1 <=
3168 fodInfos->ofnInfos->nMaxFile)
3169 {
3170 /* append the dot */
3171 lstrcatW(lpstrPathAndFile, szwDot);
3172 /* append the extension */
3173 lstrcatW(lpstrPathAndFile, the_ext);
3174 /* update ext */
3175 ext = PathFindExtensionW(lpstrPathAndFile);
3176 }
3177 }
3178
3179 heap_free(filterExt);
3180
3181 /* In Open dialog: if file does not exist try without extension */
3182 if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
3183 lpstrPathAndFile[PathLength] = 0;
3184
3185 /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */
3186 if (*ext)
3187 ext++;
3188 if (!lstrcmpiW(fodInfos->defext, ext))
3189 fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT;
3190 else
3192 }
3193
3194 /* update dialog data */
3195 SetWindowTextW(fodInfos->DlgInfos.hwndFileName, PathFindFileNameW(lpstrPathAndFile));
3196#else /* __REACTOS__ */
3197 if (! *ext && fodInfos->defext)
3198 {
3199 /* if no extension is specified with file name, then */
3200 /* attach the extension from file filter or default one */
3201
3202 WCHAR *filterExt = NULL;
3203 LPWSTR lpstrFilter = NULL;
3204 static const WCHAR szwDot[] = {'.',0};
3205 int PathLength = lstrlenW(lpstrPathAndFile);
3206
3207 /*Get the file extension from file type filter*/
3208 lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
3209 fodInfos->ofnInfos->nFilterIndex-1);
3210
3211 if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
3212 {
3213 WCHAR* filterSearchIndex;
3214 filterExt = heap_alloc((lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR));
3215 lstrcpyW(filterExt, lpstrFilter);
3216
3217 /* if a semicolon-separated list of file extensions was given, do not include the
3218 semicolon or anything after it in the extension.
3219 example: if filterExt was "*.abc;*.def", it will become "*.abc" */
3220 filterSearchIndex = wcschr(filterExt, ';');
3221 if (filterSearchIndex)
3222 {
3223 filterSearchIndex[0] = '\0';
3224 }
3225
3226 /* find the file extension by searching for the first dot in filterExt */
3227 /* strip the * or anything else from the extension, "*.abc" becomes "abc" */
3228 /* if the extension is invalid or contains a glob, ignore it */
3229 filterSearchIndex = wcschr(filterExt, '.');
3230 if (filterSearchIndex++ && !wcschr(filterSearchIndex, '*') && !wcschr(filterSearchIndex, '?'))
3231 {
3232 lstrcpyW(filterExt, filterSearchIndex);
3233 }
3234 else
3235 {
3236 heap_free(filterExt);
3237 filterExt = NULL;
3238 }
3239 }
3240
3241 if (!filterExt)
3242 {
3243 /* use the default file extension */
3244 filterExt = heap_alloc((lstrlenW(fodInfos->defext) + 1) * sizeof(WCHAR));
3245 lstrcpyW(filterExt, fodInfos->defext);
3246 }
3247
3248 if (*filterExt) /* ignore filterExt="" */
3249 {
3250 /* Attach the dot*/
3251 lstrcatW(lpstrPathAndFile, szwDot);
3252 /* Attach the extension */
3253 lstrcatW(lpstrPathAndFile, filterExt);
3254 }
3255
3256 heap_free(filterExt);
3257
3258 /* In Open dialog: if file does not exist try without extension */
3259 if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
3260 lpstrPathAndFile[PathLength] = '\0';
3261
3262 /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */
3263 if (*ext)
3264 ext++;
3265 if (!lstrcmpiW(fodInfos->defext, ext))
3266 fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT;
3267 else
3269 }
3270#endif /* __REACTOS__ */
3271
3272 /* In Save dialog: check if the file already exists */
3273 if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG
3274 && fodInfos->ofnInfos->Flags & OFN_OVERWRITEPROMPT
3275 && PathFileExistsW(lpstrPathAndFile))
3276 {
3277 WCHAR lpstrOverwrite[100];
3278 int answer;
3279
3280 LoadStringW(COMDLG32_hInstance, IDS_OVERWRITEFILE, lpstrOverwrite, 100);
3281 answer = MessageBoxW(hwnd, lpstrOverwrite, fodInfos->title,
3283 if (answer == IDNO || answer == IDCANCEL)
3284 {
3285 ret = FALSE;
3286 goto ret;
3287 }
3288 }
3289
3290 /* In Open dialog: check if it should be created if it doesn't exist */
3291 if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG)
3292 && fodInfos->ofnInfos->Flags & OFN_CREATEPROMPT
3293 && !PathFileExistsW(lpstrPathAndFile))
3294 {
3295 WCHAR lpstrCreate[100];
3296 int answer;
3297
3298 LoadStringW(COMDLG32_hInstance, IDS_CREATEFILE, lpstrCreate, 100);
3299 answer = MessageBoxW(hwnd, lpstrCreate, fodInfos->title,
3301 if (answer == IDNO || answer == IDCANCEL)
3302 {
3303 ret = FALSE;
3304 goto ret;
3305 }
3306 }
3307
3308 /* Check that the size of the file does not exceed buffer size.
3309 (Allow for extra \0 if OFN_MULTISELECT is set.) */
3310 if(lstrlenW(lpstrPathAndFile) < fodInfos->ofnInfos->nMaxFile -
3311 ((fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT) ? 1 : 0))
3312 {
3313
3314 /* fill destination buffer */
3315 if (fodInfos->ofnInfos->lpstrFile)
3316 {
3317 if(fodInfos->unicode)
3318 {
3319 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
3320
3321 lstrcpynW(ofn->lpstrFile, lpstrPathAndFile, ofn->nMaxFile);
3323 ofn->lpstrFile[lstrlenW(ofn->lpstrFile) + 1] = '\0';
3324 }
3325 else
3326 {
3328
3329 WideCharToMultiByte(CP_ACP, 0, lpstrPathAndFile, -1,
3332 ofn->lpstrFile[lstrlenA(ofn->lpstrFile) + 1] = '\0';
3333 }
3334 }
3335
3336 if(fodInfos->unicode)
3337 {
3338 LPWSTR lpszTemp;
3339
3340 /* set filename offset */
3341 lpszTemp = PathFindFileNameW(lpstrPathAndFile);
3342 fodInfos->ofnInfos->nFileOffset = (lpszTemp - lpstrPathAndFile);
3343
3344 /* set extension offset */
3345 lpszTemp = PathFindExtensionW(lpstrPathAndFile);
3346 fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - lpstrPathAndFile) + 1 : 0;
3347 }
3348 else
3349 {
3350 LPSTR lpszTemp;
3351 CHAR tempFileA[MAX_PATH];
3352
3353 /* avoid using fodInfos->ofnInfos->lpstrFile since it can be NULL */
3354 WideCharToMultiByte(CP_ACP, 0, lpstrPathAndFile, -1,
3355 tempFileA, sizeof(tempFileA), NULL, NULL);
3356
3357 /* set filename offset */
3358 lpszTemp = PathFindFileNameA(tempFileA);
3359 fodInfos->ofnInfos->nFileOffset = (lpszTemp - tempFileA);
3360
3361 /* set extension offset */
3362 lpszTemp = PathFindExtensionA(tempFileA);
3363 fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - tempFileA) + 1 : 0;
3364 }
3365
3366 /* copy currently selected filter to lpstrCustomFilter */
3367 if (fodInfos->ofnInfos->lpstrCustomFilter)
3368 {
3370 int len = WideCharToMultiByte(CP_ACP, 0, fodInfos->ShellInfos.lpstrCurrentFilter, -1,
3371 NULL, 0, NULL, NULL);
3373 {
3376 WideCharToMultiByte(CP_ACP, 0, fodInfos->ShellInfos.lpstrCurrentFilter, -1,
3377 s, len, NULL, NULL);
3378 }
3379 }
3380
3381
3382 if ( !FILEDLG95_SendFileOK(hwnd, fodInfos) )
3383 goto ret;
3384
3385 FILEDLG95_MRU_save_filename(lpstrPathAndFile);
3386#ifdef __REACTOS__
3387 FILEDLG95_MRU_save_ext(lpstrPathAndFile);
3388#endif
3389
3390 TRACE("close\n");
3392 ret = EndDialog(hwnd, TRUE);
3393 }
3394 else
3395 {
3396 WORD size;
3397
3398 size = lstrlenW(lpstrPathAndFile) + 1;
3399 if (fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT)
3400 size += 1;
3401 /* return needed size in first two bytes of lpstrFile */
3402 if(fodInfos->ofnInfos->lpstrFile)
3403 *(WORD *)fodInfos->ofnInfos->lpstrFile = size;
3405 ret = EndDialog(hwnd, FALSE);
3407 }
3408 }
3409 break;
3410 }
3411
3412ret:
3413 if(lpsf) IShellFolder_Release(lpsf);
3414 return ret;
3415}
static USHORT PathLength
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define FNERR_BUFFERTOOSMALL
Definition: cderr.h:37
#define ONOPEN_OPEN
Definition: cdlg.h:214
#define ONOPEN_BROWSE
Definition: cdlg.h:213
#define ONOPEN_SEARCH
Definition: cdlg.h:215
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define OFN_EXTENSIONDIFFERENT
Definition: commdlg.h:105
#define OFN_CREATEPROMPT
Definition: commdlg.h:97
#define OFN_NOVALIDATE
Definition: commdlg.h:115
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_ALLOWMULTISELECT
Definition: commdlg.h:96
void COMDLG32_GetCanonicalPath(PCIDLIST_ABSOLUTE pidlAbsCurrent, LPWSTR lpstrFile, LPWSTR lpstrPathAndFile)
Definition: filedlg.c:736
static void FILEDLG95_Clean(HWND hwnd)
Definition: filedlg.c:2140
int FILEDLG95_ValidatePathAction(LPWSTR lpstrPathAndFile, IShellFolder **ppsf, HWND hwnd, DWORD flags, BOOL isSaveDlg, int defAction)
Definition: filedlg.c:2829
static int FILEDLG95_FILENAME_GetFileNames(HWND hwnd, LPWSTR *lpstrFileList, UINT *sizeUsed)
Definition: filedlg.c:4352
static BOOL BrowseSelectedFolder(HWND hwnd)
Definition: filedlg.c:4586
static BOOL FILEDLG95_SendFileOK(HWND hwnd, FileOpenDlgInfos *fodInfos)
Definition: filedlg.c:2264
static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
Definition: filedlg.c:2301
static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
Definition: filedlg.c:2486
static int FILEDLG95_FILETYPE_SearchExt(HWND hwnd, LPCWSTR lpstrExt)
Definition: filedlg.c:3696
#define wcschr
Definition: compat.h:17
HANDLE HWND
Definition: compat.h:19
static const WCHAR *const ext[]
Definition: module.c:53
LPSTR WINAPI PathFindFileNameA(LPCSTR lpszPath)
Definition: path.c:373
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
Definition: path.c:447
LPSTR WINAPI PathFindExtensionA(LPCSTR lpszPath)
Definition: path.c:422
#define IDS_CREATEFILE
#define IDS_OVERWRITEFILE
GLdouble s
Definition: gl.h:2039
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define pch(ap)
Definition: match.c:418
#define CBEM_GETEDITCONTROL
Definition: commctrl.h:3833
#define strchrW(s, c)
Definition: unicode.h:34
#define strlenW(s)
Definition: unicode.h:28
#define strcpyW(d, s)
Definition: unicode.h:29
DWORD nMaxCustFilter
Definition: commdlg.h:334
LPSTR lpstrCustomFilter
Definition: commdlg.h:333
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD nMaxFile
Definition: commdlg.h:337
WORD nFileExtension
Definition: commdlg.h:375
LPWSTR lpstrFile
Definition: commdlg.h:367
WORD nFileOffset
Definition: commdlg.h:374
LPWSTR lpstrCustomFilter
Definition: commdlg.h:364
DWORD nMaxFile
Definition: commdlg.h:368
#define MB_YESNO
Definition: winuser.h:811
#define WM_SETTEXT
Definition: winuser.h:1607
#define IDNO
Definition: winuser.h:830
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1908
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
char CHAR
Definition: xmlstorage.h:175

Referenced by FILEDLG95_OnWMCommand().

◆ FILEDLG95_OnOpenMessage()

void FILEDLG95_OnOpenMessage ( HWND  hwnd,
int  idCaption,
int  idText 
)

Definition at line 2817 of file filedlg.c.

2818{
2819 WCHAR strMsgTitle[MAX_PATH];
2820 WCHAR strMsgText [MAX_PATH];
2821 if (idCaption)
2822 LoadStringW(COMDLG32_hInstance, idCaption, strMsgTitle, ARRAY_SIZE(strMsgTitle));
2823 else
2824 strMsgTitle[0] = '\0';
2825 LoadStringW(COMDLG32_hInstance, idText, strMsgText, ARRAY_SIZE(strMsgText));
2826 MessageBoxW(hwnd,strMsgText, strMsgTitle, MB_OK | MB_ICONHAND);
2827}
#define MB_ICONHAND
Definition: winuser.h:782

Referenced by FILEDLG95_ValidatePathAction(), and on_default_action().

◆ FILEDLG95_OnOpenMultipleFiles()

BOOL FILEDLG95_OnOpenMultipleFiles ( HWND  hwnd,
LPWSTR  lpstrFileList,
UINT  nFileCount,
UINT  sizeUsed 
)
static

Definition at line 2301 of file filedlg.c.

2302{
2304 WCHAR lpstrPathSpec[MAX_PATH] = {0};
2305 UINT nCount, nSizePath;
2306
2307 TRACE("\n");
2308
2309 if(fodInfos->unicode)
2310 {
2311 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
2312 ofn->lpstrFile[0] = '\0';
2313 }
2314 else
2315 {
2317 ofn->lpstrFile[0] = '\0';
2318 }
2319
2320 COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );
2321
2322 if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&
2323 ( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&
2324 ! ( fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG ) )
2325 {
2326 LPWSTR lpstrTemp = lpstrFileList;
2327
2328 for ( nCount = 0; nCount < nFileCount; nCount++ )
2329 {
2330 LPITEMIDLIST pidl;
2331
2332 pidl = GetPidlFromName(fodInfos->Shell.FOIShellFolder, lpstrTemp);
2333 if (!pidl)
2334 {
2335 WCHAR lpstrNotFound[100];
2336 WCHAR lpstrMsg[100];
2337 WCHAR tmp[400];
2338 static const WCHAR nl[] = {'\n',0};
2339
2340 LoadStringW(COMDLG32_hInstance, IDS_FILENOTFOUND, lpstrNotFound, 100);
2342
2343 lstrcpyW(tmp, lpstrTemp);
2344 lstrcatW(tmp, nl);
2345 lstrcatW(tmp, lpstrNotFound);
2346 lstrcatW(tmp, nl);
2347 lstrcatW(tmp, lpstrMsg);
2348
2349 MessageBoxW(hwnd, tmp, fodInfos->title, MB_OK | MB_ICONEXCLAMATION);
2350 return FALSE;
2351 }
2352
2353 /* move to the next file in the list of files */
2354 lpstrTemp += lstrlenW(lpstrTemp) + 1;
2355 ILFree(pidl);
2356 }
2357 }
2358
2359 nSizePath = lstrlenW(lpstrPathSpec) + 1;
2360 if ( !(fodInfos->ofnInfos->Flags & OFN_EXPLORER) )
2361 {
2362 /* For "oldstyle" dialog the components have to
2363 be separated by blanks (not '\0'!) and short
2364 filenames have to be used! */
2365 FIXME("Components have to be separated by blanks\n");
2366 }
2367 if(fodInfos->unicode)
2368 {
2369 LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
2370 lstrcpyW( ofn->lpstrFile, lpstrPathSpec);
2371 memcpy( ofn->lpstrFile + nSizePath, lpstrFileList, sizeUsed*sizeof(WCHAR) );
2372 }
2373 else
2374 {
2376
2377 if (ofn->lpstrFile != NULL)
2378 {
2379 nSizePath = WideCharToMultiByte(CP_ACP, 0, lpstrPathSpec, -1,
2381 if (ofn->nMaxFile > nSizePath)
2382 {
2383 WideCharToMultiByte(CP_ACP, 0, lpstrFileList, sizeUsed,
2384 ofn->lpstrFile + nSizePath,
2385 ofn->nMaxFile - nSizePath, NULL, NULL);
2386 }
2387 }
2388 }
2389
2390 fodInfos->ofnInfos->nFileOffset = nSizePath;
2391 fodInfos->ofnInfos->nFileExtension = 0;
2392
2393 if ( !FILEDLG95_SendFileOK(hwnd, fodInfos) )
2394 return FALSE;
2395
2396 /* clean and exit */
2398 return EndDialog(hwnd,TRUE);
2399}
#define IDS_FILENOTFOUND
#define IDS_VERIFYFILE
if(dx< 0)
Definition: linetemp.h:194

Referenced by FILEDLG95_OnOpen().

◆ FILEDLG95_OnWMCommand()

static LRESULT FILEDLG95_OnWMCommand ( HWND  hwnd,
WPARAM  wParam 
)
static

Definition at line 2165 of file filedlg.c.

2166{
2168 WORD wNotifyCode = HIWORD(wParam); /* notification code */
2169 WORD id = LOWORD(wParam); /* item, control, or accelerator identifier */
2170
2171 switch (id)
2172 {
2173 /* OK button */
2174 case IDOK:
2176 break;
2177 /* Cancel button */
2178 case IDCANCEL:
2181 break;
2182 /* Filetype combo box */
2183 case IDC_FILETYPE:
2185 break;
2186 /* LookIn combo box */
2187 case IDC_LOOKIN:
2188 FILEDLG95_LOOKIN_OnCommand(hwnd,wNotifyCode);
2189 break;
2190
2191 /* --- toolbar --- */
2192 /* Up folder button */
2193 case FCIDM_TB_UPFOLDER:
2195 break;
2196 /* New folder button */
2197 case FCIDM_TB_NEWFOLDER:
2198 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_NEWFOLDERA);
2199 break;
2200 /* List option button */
2201 case FCIDM_TB_SMALLICON:
2202 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWLISTA);
2203 break;
2204 /* Details option button */
2206 FILEDLG95_SHELL_ExecuteCommand(hwnd,CMDSTR_VIEWDETAILSA);
2207 break;
2208
2209 case FCIDM_TB_DESKTOP:
2210 {
2211 LPITEMIDLIST pidl;
2212
2214 filedlg_browse_to_pidl(fodInfos, pidl);
2215 ILFree(pidl);
2216 break;
2217 }
2218
2219 /* Places bar */
2225 filedlg_browse_to_pidl(fodInfos, fodInfos->places[id - TBPLACES_CMDID_PLACE0]);
2226 break;
2227
2228 case edt1:
2229 case cmb13:
2230 break;
2231
2232 }
2233 /* Do not use the listview selection anymore */
2234 fodInfos->DlgInfos.dwDlgProp &= ~FODPROP_USEVIEW;
2235 return 0;
2236}
#define TBPLACES_CMDID_PLACE1
Definition: filedlg.c:203
#define TBPLACES_CMDID_PLACE3
Definition: filedlg.c:205
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb)
Definition: filedlg.c:3457
static void filedlg_browse_to_pidl(const FileOpenDlgInfos *info, LPITEMIDLIST pidl)
Definition: filedlg.c:2151
#define TBPLACES_CMDID_PLACE4
Definition: filedlg.c:206
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
Definition: filedlg.c:3488
#define TBPLACES_CMDID_PLACE2
Definition: filedlg.c:204
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
Definition: filedlg.c:3947
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
Definition: filedlg.c:3651
static BOOL FILEDLG95_OnOpen(HWND hwnd)
Definition: filedlg.c:2953
#define LOWORD(l)
Definition: pedump.c:82
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_OnWMGetIShellBrowser()

static LRESULT FILEDLG95_OnWMGetIShellBrowser ( HWND  hwnd)
static

Definition at line 2243 of file filedlg.c.

2244{
2246
2247 TRACE("\n");
2248
2249 SetWindowLongPtrW(hwnd,DWLP_MSGRESULT,(LONG_PTR)fodInfos->Shell.FOIShellBrowser);
2250
2251 return TRUE;
2252}
__int3264 LONG_PTR
Definition: mstsclib_h.h:276

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_OnWMGetMMI()

static LRESULT FILEDLG95_OnWMGetMMI ( HWND  hwnd,
LPMINMAXINFO  mmiptr 
)
static

Definition at line 1224 of file filedlg.c.

1225{
1227 if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
1228 if( fodInfos->initial_size.x || fodInfos->initial_size.y)
1229 {
1230 mmiptr->ptMinTrackSize = fodInfos->initial_size;
1231 }
1232 return TRUE;
1233}
#define OFN_ENABLESIZING
Definition: commdlg.h:101
POINT ptMinTrackSize
Definition: winuser.h:3620
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_OnWMSize()

static LRESULT FILEDLG95_OnWMSize ( HWND  hwnd,
WPARAM  wParam 
)
static

Definition at line 1245 of file filedlg.c.

1246{
1247 RECT rc, rcview;
1248 int chgx, chgy;
1249 HWND ctrl;
1250 HDWP hdwp;
1251 FileOpenDlgInfos *fodInfos;
1252
1253 if( wParam != SIZE_RESTORED) return FALSE;
1254 fodInfos = get_filedlg_infoptr(hwnd);
1255 if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
1256 /* get the new dialog rectangle */
1257 GetWindowRect( hwnd, &rc);
1258 TRACE("%p, size from %d,%d to %d,%d\n", hwnd, fodInfos->sizedlg.cx, fodInfos->sizedlg.cy,
1259 rc.right -rc.left, rc.bottom -rc.top);
1260 /* not initialized yet */
1261 if( (fodInfos->sizedlg.cx == 0 && fodInfos->sizedlg.cy == 0) ||
1262 ((fodInfos->sizedlg.cx == rc.right -rc.left) && /* no change */
1263 (fodInfos->sizedlg.cy == rc.bottom -rc.top)))
1264 return FALSE;
1265 chgx = rc.right - rc.left - fodInfos->sizedlg.cx;
1266 chgy = rc.bottom - rc.top - fodInfos->sizedlg.cy;
1267 fodInfos->sizedlg.cx = rc.right - rc.left;
1268 fodInfos->sizedlg.cy = rc.bottom - rc.top;
1269 /* change the size of the view window */
1270 GetWindowRect( fodInfos->ShellInfos.hwndView, &rcview);
1271 MapWindowPoints( NULL, hwnd, (LPPOINT) &rcview, 2);
1272 hdwp = BeginDeferWindowPos( 10);
1273 DeferWindowPos( hdwp, fodInfos->ShellInfos.hwndView, NULL, 0, 0,
1274 rcview.right - rcview.left + chgx,
1275 rcview.bottom - rcview.top + chgy,
1277 /* change position and sizes of the controls */
1279 {
1280 int ctrlid = GetDlgCtrlID( ctrl);
1281 GetWindowRect( ctrl, &rc);
1282 MapWindowPoints( NULL, hwnd, (LPPOINT) &rc, 2);
1283 if( ctrl == fodInfos->DlgInfos.hwndGrip)
1284 {
1285 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top + chgy,
1286 0, 0,
1288 }
1289 else if( rc.top > rcview.bottom)
1290 {
1291 /* if it was below the shell view
1292 * move to bottom */
1293 switch( ctrlid)
1294 {
1295 /* file name (edit or comboboxex) and file types combo change also width */
1296 case edt1:
1297 case cmb13:
1298 case cmb1:
1299 DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
1300 rc.right - rc.left + chgx, rc.bottom - rc.top,
1302 break;
1303 /* then these buttons must move out of the way */
1304 case IDOK:
1305 case IDCANCEL:
1306 case pshHelp:
1307 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top + chgy,
1308 0, 0,
1310 break;
1311 default:
1312 DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
1313 0, 0,
1315 }
1316 }
1317 else if( rc.left > rcview.right)
1318 {
1319 /* if it was to the right of the shell view
1320 * move to right */
1321 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
1322 0, 0,
1324 }
1325 else
1326 /* special cases */
1327 {
1328 switch( ctrlid)
1329 {
1330#if 0 /* this is Win2k, Win XP. Vista and Higher don't move/size these controls */
1331 case IDC_LOOKIN:
1332 DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
1333 rc.right - rc.left + chgx, rc.bottom - rc.top,
1335 break;
1336 case IDC_TOOLBARSTATIC:
1337 case IDC_TOOLBAR:
1338 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
1339 0, 0,
1341 break;
1342#endif
1343 /* not resized in windows. Since wine uses this invisible control
1344 * to size the browser view it needs to be resized */
1345 case IDC_SHELLSTATIC:
1346 DeferWindowPos( hdwp, ctrl, NULL, 0, 0,
1347 rc.right - rc.left + chgx,
1348 rc.bottom - rc.top + chgy,
1350 break;
1351 case IDC_TOOLBARPLACES:
1352 DeferWindowPos( hdwp, ctrl, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top + chgy,
1354 break;
1355 }
1356 }
1357 }
1358 if(fodInfos->DlgInfos.hwndCustomDlg &&
1360 {
1361 for( ctrl = GetWindow( fodInfos->DlgInfos.hwndCustomDlg, GW_CHILD);
1363 {
1364 GetWindowRect( ctrl, &rc);
1365 MapWindowPoints( NULL, hwnd, (LPPOINT) &rc, 2);
1366 if( rc.top > rcview.bottom)
1367 {
1368 /* if it was below the shell view
1369 * move to bottom */
1370 DeferWindowPos( hdwp, ctrl, NULL, rc.left, rc.top + chgy,
1371 rc.right - rc.left, rc.bottom - rc.top,
1373 }
1374 else if( rc.left > rcview.right)
1375 {
1376 /* if it was to the right of the shell view
1377 * move to right */
1378 DeferWindowPos( hdwp, ctrl, NULL, rc.left + chgx, rc.top,
1379 rc.right - rc.left, rc.bottom - rc.top,
1381 }
1382 }
1383 /* size the custom dialog at the end: some applications do some
1384 * control re-arranging at this point */
1385 GetClientRect(hwnd, &rc);
1386 DeferWindowPos( hdwp,fodInfos->DlgInfos.hwndCustomDlg, NULL,
1388 }
1389 EndDeferWindowPos( hdwp);
1390 /* should not be needed */
1392 return TRUE;
1393}
#define cmb1
Definition: dlgs.h:48
#define IDC_SHELLSTATIC
#define ctrl
Definition: input.c:1756
LONG cx
Definition: windef.h:334
LONG cy
Definition: windef.h:335
#define SWP_NOACTIVATE
Definition: winuser.h:1232
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
#define RDW_ALLCHILDREN
Definition: winuser.h:1211
#define SIZE_RESTORED
Definition: winuser.h:2495
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 RDW_INVALIDATE
Definition: winuser.h:1204
HDWP WINAPI BeginDeferWindowPos(_In_ int)

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_ResizeControls()

static LRESULT FILEDLG95_ResizeControls ( HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 2048 of file filedlg.c.

2049{
2051
2052 if (fodInfos->DlgInfos.hwndCustomDlg)
2053 {
2054 RECT rc;
2056
2057 ArrangeCtrlPositions(fodInfos->DlgInfos.hwndCustomDlg, hwnd,
2058 filedialog_is_readonly_hidden(fodInfos) && !(fodInfos->ofnInfos->Flags & OFN_SHOWHELP));
2059
2060 /* resize the custom dialog to the parent size */
2062 GetClientRect(hwnd, &rc);
2063 else
2064 {
2065 /* our own fake template is zero sized and doesn't have children, so
2066 * there is no need to resize it. Picasa depends on it.
2067 */
2068 flags |= SWP_NOSIZE;
2069 SetRectEmpty(&rc);
2070 }
2071 SetWindowPos(fodInfos->DlgInfos.hwndCustomDlg, HWND_BOTTOM,
2072 0, 0, rc.right, rc.bottom, flags);
2073 }
2074 else
2075 {
2076 /* Resize the height; if opened as read-only, checkbox and help button are
2077 * hidden and we are not using a custom template nor a customDialog
2078 */
2079 if (filedialog_is_readonly_hidden(fodInfos) &&
2080 (!(fodInfos->ofnInfos->Flags &
2082 {
2083 RECT rectDlg, rectHelp, rectCancel;
2084 GetWindowRect(hwnd, &rectDlg);
2085 GetWindowRect(GetDlgItem(hwnd, pshHelp), &rectHelp);
2086 GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel);
2087 /* subtract the height of the help button plus the space between the help
2088 * button and the cancel button to the height of the dialog
2089 */
2090 SetWindowPos(hwnd, 0, 0, 0, rectDlg.right-rectDlg.left,
2091 (rectDlg.bottom-rectDlg.top) - (rectHelp.bottom - rectCancel.bottom),
2093 }
2094 }
2095 return TRUE;
2096}
static void ArrangeCtrlPositions(HWND hwndChildDlg, HWND hwndParentDlg, BOOL hide_help)
Definition: filedlg.c:824
GLbitfield flags
Definition: glext.h:7161
#define HWND_BOTTOM
Definition: winuser.h:1195

Referenced by FileOpenDlgProc95().

◆ FILEDLG95_SendFileOK()

static BOOL FILEDLG95_SendFileOK ( HWND  hwnd,
FileOpenDlgInfos fodInfos 
)
static

Definition at line 2264 of file filedlg.c.

2265{
2266 /* ask the hook if we can close */
2267 if (is_dialog_hooked(fodInfos))
2268 {
2269 LRESULT retval = 0;
2270
2271 TRACE("---\n");
2272 /* First send CDN_FILEOK as MSDN doc says */
2273 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
2275 if( retval)
2276 {
2277 TRACE("canceled\n");
2278 return FALSE;
2279 }
2280
2281 /* fodInfos->ofnInfos points to an ASCII or UNICODE structure as appropriate */
2282 retval = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,
2283 fodInfos->HookMsg.fileokstring, 0, (LPARAM)fodInfos->ofnInfos);
2284 if( retval)
2285 {
2286 TRACE("canceled\n");
2287 return FALSE;
2288 }
2289 }
2290 return TRUE;
2291}
#define CDN_FILEOK
Definition: commdlg.h:38
struct FileOpenDlgInfos::@335 HookMsg
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by FILEDLG95_OnOpen(), and FILEDLG95_OnOpenMultipleFiles().

◆ FILEDLG95_SHELL_Clean()

static void FILEDLG95_SHELL_Clean ( HWND  hwnd)
static

Definition at line 3509 of file filedlg.c.

3510{
3512
3513 TRACE("\n");
3514
3515 ILFree(fodInfos->ShellInfos.pidlAbsCurrent);
3516
3517 /* clean Shell interfaces */
3518 if (fodInfos->Shell.FOIShellView)
3519 {
3520 IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
3521 IShellView_Release(fodInfos->Shell.FOIShellView);
3522 }
3523 if (fodInfos->Shell.FOIShellFolder)
3524 IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
3525 IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
3526 if (fodInfos->Shell.FOIDataObject)
3527 IDataObject_Release(fodInfos->Shell.FOIDataObject);
3528}

Referenced by FILEDLG95_Clean().

◆ FILEDLG95_SHELL_ExecuteCommand()

static BOOL FILEDLG95_SHELL_ExecuteCommand ( HWND  hwnd,
LPCSTR  lpVerb 
)
static

Definition at line 3457 of file filedlg.c.

3458{
3460 IContextMenu * pcm;
3461
3462 TRACE("(%p,%p)\n", hwnd, lpVerb);
3463
3464 if(SUCCEEDED(IShellView_GetItemObject(fodInfos->Shell.FOIShellView,
3465 SVGIO_BACKGROUND,
3466 &IID_IContextMenu,
3467 (LPVOID*)&pcm)))
3468 {
3469 CMINVOKECOMMANDINFO ci;
3470 ZeroMemory(&ci, sizeof(CMINVOKECOMMANDINFO));
3471 ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
3472 ci.lpVerb = lpVerb;
3473 ci.hwnd = hwnd;
3474
3475 IContextMenu_InvokeCommand(pcm, &ci);
3476 IContextMenu_Release(pcm);
3477 }
3478
3479 return FALSE;
3480}
#define ZeroMemory
Definition: winbase.h:1670

Referenced by FILEDLG95_OnWMCommand().

◆ FILEDLG95_SHELL_Init()

static LRESULT FILEDLG95_SHELL_Init ( HWND  hwnd)
static

Definition at line 3422 of file filedlg.c.

3423{
3425
3426 TRACE("%p\n", hwnd);
3427
3428 /*
3429 * Initialisation of the FileOpenDialogInfos structure
3430 */
3431
3432 /* Shell */
3433
3434 /*ShellInfos */
3435 fodInfos->ShellInfos.hwndOwner = hwnd;
3436
3437 /* Disable multi-select if flag not set */
3438 if (!(fodInfos->ofnInfos->Flags & OFN_ALLOWMULTISELECT))
3439 {
3440 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_SINGLESEL;
3441 }
3442 fodInfos->ShellInfos.folderSettings.fFlags |= FWF_AUTOARRANGE | FWF_ALIGNLEFT;
3443 fodInfos->ShellInfos.folderSettings.ViewMode = FVM_LIST;
3444
3445 /* Construct the IShellBrowser interface */
3446 fodInfos->Shell.FOIShellBrowser = IShellBrowserImpl_Construct(hwnd);
3447
3448 return NOERROR;
3449}
static IShellBrowser * IShellBrowserImpl_Construct(void)
Definition: shlview.c:278
@ FWF_AUTOARRANGE
Definition: shobjidl.idl:631
@ FWF_ALIGNLEFT
Definition: shobjidl.idl:642
@ FWF_SINGLESEL
Definition: shobjidl.idl:637
@ FVM_LIST
Definition: shobjidl.idl:671

Referenced by FILEDLG95_FillControls().

◆ FILEDLG95_SHELL_UpFolder()

static BOOL FILEDLG95_SHELL_UpFolder ( HWND  hwnd)
static

Definition at line 3488 of file filedlg.c.

3489{
3491
3492 TRACE("\n");
3493
3494 if(SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser,
3495 NULL,
3496 SBSP_PARENT)))
3497 {
3498 if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
3500 return TRUE;
3501 }
3502 return FALSE;
3503}

Referenced by FILEDLG95_OnWMCommand().

◆ FILEDLG95_unixfs_is_rooted_at_desktop()

static BOOL FILEDLG95_unixfs_is_rooted_at_desktop ( void  )
inlinestatic

Definition at line 3752 of file filedlg.c.

3752 {
3753 HKEY hKey;
3754 static const WCHAR wszRootedAtDesktop[] = { 'S','o','f','t','w','a','r','e','\\',
3755 'M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s','\\',
3756 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
3757 'E','x','p','l','o','r','e','r','\\','D','e','s','k','t','o','p','\\',
3758 'N','a','m','e','S','p','a','c','e','\\','{','9','D','2','0','A','A','E','8',
3759 '-','0','6','2','5','-','4','4','B','0','-','9','C','A','7','-',
3760 '7','1','8','8','9','C','2','2','5','4','D','9','}',0 };
3761
3762 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, wszRootedAtDesktop, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
3763 return FALSE;
3764
3766 return TRUE;
3767}
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
FxAutoRegKey hKey
#define KEY_READ
Definition: nt_native.h:1023
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by FILEDLG95_LOOKIN_Init().

◆ FILEDLG95_ValidatePathAction()

int FILEDLG95_ValidatePathAction ( LPWSTR  lpstrPathAndFile,
IShellFolder **  ppsf,
HWND  hwnd,
DWORD  flags,
BOOL  isSaveDlg,
int  defAction 
)

Definition at line 2829 of file filedlg.c.

2831{
2832 int nOpenAction = defAction;
2833 LPWSTR lpszTemp, lpszTemp1;
2834 LPITEMIDLIST pidl = NULL;
2835 static const WCHAR szwInvalid[] = { '/',':','<','>','|', 0};
2836
2837 /* check for invalid chars */
2838 if((wcspbrk(lpstrPathAndFile+3, szwInvalid) != NULL) && !(flags & OFN_NOVALIDATE))
2839 {
2841 return FALSE;
2842 }
2843
2844 if (FAILED (SHGetDesktopFolder(ppsf))) return FALSE;
2845
2846 lpszTemp1 = lpszTemp = lpstrPathAndFile;
2847 while (lpszTemp1)
2848 {
2849 LPSHELLFOLDER lpsfChild;
2850 WCHAR lpwstrTemp[MAX_PATH];
2851 DWORD dwEaten, dwAttributes;
2852 LPWSTR p;
2853
2854 lstrcpyW(lpwstrTemp, lpszTemp);
2855 p = PathFindNextComponentW(lpwstrTemp);
2856
2857 if (!p) break; /* end of path */
2858
2859 *p = 0;
2860 lpszTemp = lpszTemp + lstrlenW(lpwstrTemp);
2861
2862 /* There are no wildcards when OFN_NOVALIDATE is set */
2863 if(*lpszTemp==0 && !(flags & OFN_NOVALIDATE))
2864 {
2865 static const WCHAR wszWild[] = { '*', '?', 0 };
2866 /* if the last element is a wildcard do a search */
2867 if(wcspbrk(lpszTemp1, wszWild) != NULL)
2868 {
2869 nOpenAction = ONOPEN_SEARCH;
2870 break;
2871 }
2872 }
2873 lpszTemp1 = lpszTemp;
2874
2875 TRACE("parse now=%s next=%s sf=%p\n",debugstr_w(lpwstrTemp), debugstr_w(lpszTemp), *ppsf);
2876
2877 /* append a backslash to drive letters */
2878 if(lstrlenW(lpwstrTemp)==2 && lpwstrTemp[1] == ':' &&
2879 ((lpwstrTemp[0] >= 'a' && lpwstrTemp[0] <= 'z') ||
2880 (lpwstrTemp[0] >= 'A' && lpwstrTemp[0] <= 'Z')))
2881 {
2882 PathAddBackslashW(lpwstrTemp);
2883 }
2884
2885 dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSANCESTOR;
2886 if(SUCCEEDED(IShellFolder_ParseDisplayName(*ppsf, hwnd, NULL, lpwstrTemp, &dwEaten, &pidl, &dwAttributes)))
2887 {
2888 /* the path component is valid, we have a pidl of the next path component */
2889 TRACE("parse OK attr=0x%08x pidl=%p\n", dwAttributes, pidl);
2890 if((dwAttributes & (SFGAO_FOLDER | SFGAO_FILESYSANCESTOR)) == (SFGAO_FOLDER | SFGAO_FILESYSANCESTOR))
2891 {
2892 if(FAILED(IShellFolder_BindToObject(*ppsf, pidl, 0, &IID_IShellFolder, (LPVOID*)&lpsfChild)))
2893 {
2894 ERR("bind to failed\n"); /* should not fail */
2895 break;
2896 }
2897 IShellFolder_Release(*ppsf);
2898 *ppsf = lpsfChild;
2899 lpsfChild = NULL;
2900 }
2901 else
2902 {
2903 TRACE("value\n");
2904
2905 /* end dialog, return value */
2906 nOpenAction = ONOPEN_OPEN;
2907 break;
2908 }
2909 ILFree(pidl);
2910 pidl = NULL;
2911 }
2912 else if (!(flags & OFN_NOVALIDATE))
2913 {
2914 if(*lpszTemp || /* points to trailing null for last path element */
2915 (lpwstrTemp[lstrlenW(lpwstrTemp)-1] == '\\')) /* or if last element ends in '\' */
2916 {
2918 {
2920 break;
2921 }
2922 }
2923 else
2924 {
2925 if( (flags & OFN_FILEMUSTEXIST) && !isSaveDlg )
2926 {
2928 break;
2929 }
2930 }
2931 /* change to the current folder */
2932 nOpenAction = ONOPEN_OPEN;
2933 break;
2934 }
2935 else
2936 {
2937 nOpenAction = ONOPEN_OPEN;
2938 break;
2939 }
2940 }
2941 ILFree(pidl);
2942
2943 return nOpenAction;
2944}
#define ERR(fmt,...)
Definition: debug.h:110
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)
Definition: filedlg.c:2817
LPWSTR WINAPI PathFindNextComponentW(LPCWSTR lpszPath)
Definition: path.c:2579
#define IDS_INVALID_FILENAME_TITLE
#define IDS_FILENOTEXISTING
#define IDS_INVALID_FILENAME
DWORD dwAttributes
Definition: vdmdbg.h:34

Referenced by FILEDLG95_OnOpen(), and on_default_action().

◆ filedlg_browse_to_pidl()

static void filedlg_browse_to_pidl ( const FileOpenDlgInfos info,
LPITEMIDLIST  pidl 
)
static

Definition at line 2151 of file filedlg.c.

2152{
2153 TRACE("%p, %p\n", info->ShellInfos.hwndOwner, pidl);
2154
2155 IShellBrowser_BrowseObject(info->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
2156 if (info->ofnInfos->Flags & OFN_EXPLORER)
2158}

Referenced by FILEDLG95_OnWMCommand().

◆ filedlg_collect_places_pidls()

static void filedlg_collect_places_pidls ( FileOpenDlgInfos fodInfos)
static

Definition at line 378 of file filedlg.c.

379{
380 static const int default_places[] =
381 {
382#ifdef __REACTOS__
388#else
392#endif
393 };
394 unsigned int i;
395 HKEY hkey;
396
397 if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Comdlg32\\Placesbar",
398 &hkey))
399 {
400 for (i = 0; i < ARRAY_SIZE(fodInfos->places); i++)
401 {
402 static const WCHAR placeW[] = {'P','l','a','c','e','%','d',0};
403 WCHAR nameW[8];
404 DWORD value;
405 HRESULT hr;
406 WCHAR *str;
407
408 swprintf(nameW, placeW, i);
409 if (get_config_key_dword(hkey, nameW, &value))
410 {
412 if (FAILED(hr))
413 WARN("Unrecognized special folder %u.\n", value);
414 }
415 else if (get_config_key_string(hkey, nameW, &str))
416 {
417 hr = SHParseDisplayName(str, NULL, &fodInfos->places[i], 0, NULL);
418 if (FAILED(hr))
419 WARN("Failed to parse custom places location, %s.\n", debugstr_w(str));
420 heap_free(str);
421 }
422 }
423
424 /* FIXME: eliminate duplicates. */
425
426 RegCloseKey(hkey);
427 return;
428 }
429
430 for (i = 0; i < ARRAY_SIZE(default_places); i++)
431 SHGetSpecialFolderLocation(NULL, default_places[i], &fodInfos->places[i]);
432}
static const WCHAR nameW[]
Definition: main.c:46
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
static BOOL get_config_key_dword(HKEY hkey, const WCHAR *name, DWORD *value)
Definition: filedlg.c:320
static BOOL get_config_key_string(HKEY hkey, const WCHAR *name, WCHAR **value)
Definition: filedlg.c:334
#define swprintf
Definition: precomp.h:40
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1381
const WCHAR * str
HRESULT hr
Definition: shlfolder.c:183
#define CSIDL_RECENT
Definition: shlobj.h:2033
#define CSIDL_MYDOCUMENTS
Definition: shlobj.h:2037
#define CSIDL_NETWORK
Definition: shlobj.h:2042
Definition: pdh_main.c:94

Referenced by FILEDLG95_InitControls().

◆ filename_is_edit()

static BOOL filename_is_edit ( const FileOpenDlgInfos info)
inlinestatic

Definition at line 1618 of file filedlg.c.

1619{
1620 return (info->ofnInfos->lStructSize ==