#define CBSetExtendedUI(hwnd,flag) \
SendMessageW(hwnd, CB_SETEXTENDEDUI, (WPARAM)(flag), 0)
-const char FileOpenDlgInfosStr[] = "FileOpenDlgInfos"; /* windows property description string */
static const char LookInInfosStr[] = "LookInInfos"; /* LOOKIN combo box property */
static SIZE MemDialogSize = { 0, 0}; /* keep size of the (resizable) dialog */
'L','a','s','t','V','i','s','i','t','e','d','M','R','U',0};
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};
+
+FileOpenDlgInfos *get_filedlg_infoptr(HWND hwnd)
+{
+ return GetPropW(hwnd, filedlg_info_propnameW);
+}
+
/***********************************************************************
* Prototypes
*/
return lRes;
}
-/***********************************************************************
- * GetFileDialog95A
- *
- * Call GetFileName95 with this structure and clean the memory.
- *
- * IN : The OPENFILENAMEA initialisation structure passed to
- * GetOpenFileNameA win api function (see filedlg.c)
- */
-static BOOL GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
+static WCHAR *heap_strdupAtoW(const char *str)
{
- BOOL ret;
- FileOpenDlgInfos fodInfos;
- LPSTR lpstrSavDir = NULL;
- LPWSTR title = NULL;
- LPWSTR defext = NULL;
- LPWSTR filter = NULL;
- LPWSTR customfilter = NULL;
- INITCOMMONCONTROLSEX icc;
-
- /* Initialize ComboBoxEx32 */
- icc.dwSize = sizeof(icc);
- icc.dwICC = ICC_USEREX_CLASSES;
- InitCommonControlsEx(&icc);
-
- /* Initialize CommDlgExtendedError() */
- COMDLG32_SetCommDlgExtendedError(0);
-
- /* Initialize FileOpenDlgInfos structure */
- ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
-
- /* Pass in the original ofn */
- fodInfos.ofnInfos = (LPOPENFILENAMEW)ofn;
-
- /* save current directory */
- if (ofn->Flags & OFN_NOCHANGEDIR)
- {
- lpstrSavDir = MemAlloc(MAX_PATH);
- GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
- }
+ WCHAR *ret;
+ INT len;
- fodInfos.unicode = FALSE;
+ if (!str)
+ return NULL;
- /* convert all the input strings to unicode */
- if(ofn->lpstrInitialDir)
- {
- DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrInitialDir, -1, NULL, 0 );
- fodInfos.initdir = MemAlloc((len+1)*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrInitialDir, -1, fodInfos.initdir, len);
- }
- else
- fodInfos.initdir = NULL;
+ len = MultiByteToWideChar(CP_ACP, 0, str, -1, 0, 0);
+ ret = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
- if(ofn->lpstrFile)
- {
- fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFile, -1, fodInfos.filename, ofn->nMaxFile);
- }
- else
- fodInfos.filename = NULL;
+ return ret;
+}
- if(ofn->lpstrDefExt)
- {
- DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrDefExt, -1, NULL, 0 );
- defext = MemAlloc((len+1)*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrDefExt, -1, defext, len);
- }
- fodInfos.defext = defext;
+static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
+{
+ INITCOMMONCONTROLSEX icc;
- if(ofn->lpstrTitle)
- {
- DWORD len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrTitle, -1, NULL, 0 );
- title = MemAlloc((len+1)*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrTitle, -1, title, len);
- }
- fodInfos.title = title;
+ /* Initialize ComboBoxEx32 */
+ icc.dwSize = sizeof(icc);
+ icc.dwICC = ICC_USEREX_CLASSES;
+ InitCommonControlsEx(&icc);
- if (ofn->lpstrFilter)
- {
- LPCSTR s;
- int n, len;
-
- /* filter is a list... title\0ext\0......\0\0 */
- s = ofn->lpstrFilter;
- while (*s) s = s+strlen(s)+1;
- s++;
- n = s - ofn->lpstrFilter;
- len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0 );
- filter = MemAlloc(len*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrFilter, n, filter, len );
- }
- fodInfos.filter = filter;
+ /* Initialize CommDlgExtendedError() */
+ COMDLG32_SetCommDlgExtendedError(0);
- /* convert lpstrCustomFilter */
- if (ofn->lpstrCustomFilter)
- {
- LPCSTR s;
- int n, len;
-
- /* customfilter contains a pair of strings... title\0ext\0 */
- s = ofn->lpstrCustomFilter;
- if (*s) s = s+strlen(s)+1;
- if (*s) s = s+strlen(s)+1;
- n = s - ofn->lpstrCustomFilter;
- len = MultiByteToWideChar( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0 );
- customfilter = MemAlloc(len*sizeof(WCHAR));
- MultiByteToWideChar( CP_ACP, 0, ofn->lpstrCustomFilter, n, customfilter, len );
- }
- fodInfos.customfilter = customfilter;
+ memset(info, 0, sizeof(*info));
- /* Initialize the dialog property */
- fodInfos.DlgInfos.dwDlgProp = 0;
- fodInfos.DlgInfos.hwndCustomDlg = NULL;
+ /* Pass in the original ofn */
+ info->ofnInfos = ofn;
- switch(iDlgType)
- {
- case OPEN_DIALOG :
- ret = GetFileName95(&fodInfos);
- break;
- case SAVE_DIALOG :
- fodInfos.DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
- ret = GetFileName95(&fodInfos);
- break;
- default :
- ret = FALSE;
- }
-
- /* set the lpstrFileTitle */
- if (ret && ofn->lpstrFile && ofn->lpstrFileTitle)
- {
- LPSTR lpstrFileTitle = PathFindFileNameA(ofn->lpstrFile);
- lstrcpynA(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
- }
+ info->title = ofn->lpstrTitle;
+ info->defext = ofn->lpstrDefExt;
+ info->filter = ofn->lpstrFilter;
+ info->customfilter = ofn->lpstrCustomFilter;
- if (lpstrSavDir)
- {
- SetCurrentDirectoryA(lpstrSavDir);
- MemFree(lpstrSavDir);
- }
-
- MemFree(title);
- MemFree(defext);
- MemFree(filter);
- MemFree(customfilter);
- MemFree(fodInfos.initdir);
- MemFree(fodInfos.filename);
+ if (ofn->lpstrFile)
+ {
+ info->filename = MemAlloc(ofn->nMaxFile * sizeof(WCHAR));
+ lstrcpynW(info->filename, ofn->lpstrFile, ofn->nMaxFile);
+ }
- TRACE("selected file: %s\n",ofn->lpstrFile);
+ if (ofn->lpstrInitialDir)
+ {
+ DWORD len = ExpandEnvironmentStringsW(ofn->lpstrInitialDir, NULL, 0);
+ if (len)
+ {
+ info->initdir = MemAlloc(len * sizeof(WCHAR));
+ ExpandEnvironmentStringsW(ofn->lpstrInitialDir, info->initdir, len);
+ }
+ }
- return ret;
+ info->unicode = TRUE;
}
-/***********************************************************************
- * GetFileDialog95W
- *
- * Copy the OPENFILENAMEW structure in a FileOpenDlgInfos structure.
- * Call GetFileName95 with this structure and clean the memory.
- *
- */
-static BOOL GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
+static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
{
- BOOL ret;
- FileOpenDlgInfos fodInfos;
- LPWSTR lpstrSavDir = NULL;
- INITCOMMONCONTROLSEX icc;
+ OPENFILENAMEW ofnW;
+ int len;
- /* Initialize ComboBoxEx32 */
- icc.dwSize = sizeof(icc);
- icc.dwICC = ICC_USEREX_CLASSES;
- InitCommonControlsEx(&icc);
+ ofnW = *(OPENFILENAMEW *)ofn;
- /* Initialize CommDlgExtendedError() */
- COMDLG32_SetCommDlgExtendedError(0);
+ ofnW.lpstrInitialDir = heap_strdupAtoW(ofn->lpstrInitialDir);
+ ofnW.lpstrDefExt = heap_strdupAtoW(ofn->lpstrDefExt);
+ ofnW.lpstrTitle = heap_strdupAtoW(ofn->lpstrTitle);
- /* Initialize FileOpenDlgInfos structure */
- ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
+ if (ofn->lpstrFile)
+ {
+ len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, NULL, 0);
+ ofnW.lpstrFile = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, ofnW.lpstrFile, len);
+ ofnW.nMaxFile = len;
+ }
- /* Pass in the original ofn */
- fodInfos.ofnInfos = ofn;
+ if (ofn->lpstrFilter)
+ {
+ LPCSTR s;
+ int n;
+
+ /* filter is a list... title\0ext\0......\0\0 */
+ s = ofn->lpstrFilter;
+ while (*s) s = s+strlen(s)+1;
+ s++;
+ n = s - ofn->lpstrFilter;
+ len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0);
+ ofnW.lpstrFilter = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, (WCHAR *)ofnW.lpstrFilter, len);
+ }
- fodInfos.title = ofn->lpstrTitle;
- fodInfos.defext = ofn->lpstrDefExt;
- fodInfos.filter = ofn->lpstrFilter;
- fodInfos.customfilter = ofn->lpstrCustomFilter;
+ /* convert lpstrCustomFilter */
+ if (ofn->lpstrCustomFilter)
+ {
+ int n, len;
+ LPCSTR s;
+
+ /* customfilter contains a pair of strings... title\0ext\0 */
+ s = ofn->lpstrCustomFilter;
+ if (*s) s = s+strlen(s)+1;
+ if (*s) s = s+strlen(s)+1;
+ n = s - ofn->lpstrCustomFilter;
+ len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0);
+ ofnW.lpstrCustomFilter = MemAlloc(len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, ofnW.lpstrCustomFilter, len);
+ }
- /* convert string arguments, save others */
- if(ofn->lpstrFile)
- {
- fodInfos.filename = MemAlloc(ofn->nMaxFile*sizeof(WCHAR));
- lstrcpynW(fodInfos.filename,ofn->lpstrFile,ofn->nMaxFile);
- }
- else
- fodInfos.filename = NULL;
+ init_filedlg_infoW(&ofnW, info);
- if(ofn->lpstrInitialDir)
- {
- /* fodInfos.initdir = strdupW(ofn->lpstrInitialDir); */
- DWORD len = lstrlenW(ofn->lpstrInitialDir)+1;
- fodInfos.initdir = MemAlloc(len*sizeof(WCHAR));
- memcpy(fodInfos.initdir,ofn->lpstrInitialDir,len*sizeof(WCHAR));
- }
- else
- fodInfos.initdir = NULL;
+ /* fixup A-specific fields */
+ info->ofnInfos = (OPENFILENAMEW *)ofn;
+ info->unicode = FALSE;
- /* save current directory */
- if (ofn->Flags & OFN_NOCHANGEDIR)
- {
- lpstrSavDir = MemAlloc(MAX_PATH*sizeof(WCHAR));
- GetCurrentDirectoryW(MAX_PATH, lpstrSavDir);
- }
+ /* free what was duplicated */
+ MemFree((WCHAR *)ofnW.lpstrInitialDir);
+ MemFree((WCHAR *)ofnW.lpstrFile);
+}
- fodInfos.unicode = TRUE;
+/***********************************************************************
+ * GetFileDialog95
+ *
+ * Call GetFileName95 with this structure and clean the memory.
+ */
+static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
+{
+ WCHAR *current_dir = NULL;
+ BOOL ret;
- switch(iDlgType)
- {
- case OPEN_DIALOG :
- ret = GetFileName95(&fodInfos);
- break;
- case SAVE_DIALOG :
- fodInfos.DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
- ret = GetFileName95(&fodInfos);
- break;
- default :
- ret = FALSE;
- }
+ /* save current directory */
+ if (info->ofnInfos->Flags & OFN_NOCHANGEDIR)
+ {
+ current_dir = MemAlloc(MAX_PATH * sizeof(WCHAR));
+ GetCurrentDirectoryW(MAX_PATH, current_dir);
+ }
- /* set the lpstrFileTitle */
- if (ret && ofn->lpstrFile && ofn->lpstrFileTitle)
- {
- LPWSTR lpstrFileTitle = PathFindFileNameW(ofn->lpstrFile);
- lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
- }
+ switch (dlg_type)
+ {
+ case OPEN_DIALOG:
+ ret = GetFileName95(info);
+ break;
+ case SAVE_DIALOG:
+ info->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
+ ret = GetFileName95(info);
+ break;
+ default:
+ ret = FALSE;
+ }
- if (lpstrSavDir)
- {
- SetCurrentDirectoryW(lpstrSavDir);
- MemFree(lpstrSavDir);
- }
+ /* set the lpstrFileTitle */
+ if (ret && info->ofnInfos->lpstrFile && info->ofnInfos->lpstrFileTitle)
+ {
+ if (info->unicode)
+ {
+ LPOPENFILENAMEW ofn = info->ofnInfos;
+ WCHAR *file_title = PathFindFileNameW(ofn->lpstrFile);
+ lstrcpynW(ofn->lpstrFileTitle, file_title, ofn->nMaxFileTitle);
+ }
+ else
+ {
+ LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)info->ofnInfos;
+ char *file_title = PathFindFileNameA(ofn->lpstrFile);
+ lstrcpynA(ofn->lpstrFileTitle, file_title, ofn->nMaxFileTitle);
+ }
+ }
- /* restore saved IN arguments and convert OUT arguments back */
- MemFree(fodInfos.filename);
- MemFree(fodInfos.initdir);
- return ret;
+ if (current_dir)
+ {
+ SetCurrentDirectoryW(current_dir);
+ MemFree(current_dir);
+ }
+
+ if (!info->unicode)
+ {
+ MemFree((WCHAR *)info->defext);
+ MemFree((WCHAR *)info->title);
+ MemFree((WCHAR *)info->filter);
+ MemFree((WCHAR *)info->customfilter);
+ }
+
+ MemFree(info->filename);
+ MemFree(info->initdir);
+ return ret;
}
/******************************************************************************
LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwndParentDlg);
LRESULT hook_result = 0;
- FileOpenDlgInfos *fodInfos = GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
TRACE("%p 0x%04x\n",hwndParentDlg, uCode);
{
UINT len, total;
WCHAR *p, *buffer;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("CDM_GETFILEPATH:\n");
*/
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
WCHAR lpstrPath[MAX_PATH];
INT_PTR retval;
*/
static LRESULT FILEDLG95_OnWMGetMMI( HWND hwnd, LPMINMAXINFO mmiptr)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
if( fodInfos->initial_size.x || fodInfos->initial_size.y)
{
FileOpenDlgInfos *fodInfos;
if( wParam != SIZE_RESTORED) return FALSE;
- fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ fodInfos = get_filedlg_infoptr(hwnd);
if( !(fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)) return FALSE;
/* get the new dialog rectangle */
GetWindowRect( hwnd, &rc);
if (SUCCEEDED(OleInitialize(NULL)))
fodInfos->ole_initialized = TRUE;
- /* Adds the FileOpenDlgInfos in the property list of the dialog
- so it will be easily accessible through a GetPropA(...) */
- SetPropA(hwnd, FileOpenDlgInfosStr, fodInfos);
+ SetPropW(hwnd, filedlg_info_propnameW, fodInfos);
FILEDLG95_InitControls(hwnd);
case WM_DESTROY:
{
- FileOpenDlgInfos * fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos * fodInfos = get_filedlg_infoptr(hwnd);
if (fodInfos && fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
MemDialogSize = fodInfos->sizedlg;
- RemovePropA(hwnd, FileOpenDlgInfosStr);
+ RemovePropW(hwnd, filedlg_info_propnameW);
return FALSE;
}
case WM_NOTIFY:
SHFILEINFOA shFileInfo;
ITEMIDLIST *desktopPidl;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("%p\n", fodInfos);
*/
static LRESULT FILEDLG95_OnWMCommand(HWND hwnd, WPARAM wParam)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
WORD wNotifyCode = HIWORD(wParam); /* notification code */
WORD wID = LOWORD(wParam); /* item, control, or accelerator identifier */
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
switch(wID)
{
*/
static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("\n");
*/
BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
WCHAR lpstrPathSpec[MAX_PATH] = {0};
UINT nCount, nSizePath;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("\n");
*/
BOOL FILEDLG95_OnOpen(HWND hwnd)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LPWSTR lpstrFileList;
UINT nFileCount = 0;
UINT sizeUsed = 0;
WCHAR lpstrPathAndFile[MAX_PATH];
LPSHELLFOLDER lpsf = NULL;
int nOpenAction;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("hwnd=%p\n", hwnd);
*/
static LRESULT FILEDLG95_SHELL_Init(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("\n");
*/
static BOOL FILEDLG95_SHELL_ExecuteCommand(HWND hwnd, LPCSTR lpVerb)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
IContextMenu * pcm;
TRACE("(%p,%p)\n", hwnd, lpVerb);
*/
static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("\n");
*/
static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LPITEMIDLIST pidl;
HRESULT hres;
*/
static void FILEDLG95_SHELL_Clean(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("\n");
*/
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
int nFilters = 0; /* number of filters */
int nFilterIndexCB;
*/
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
switch(wNotifyCode)
{
*/
static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
int iPos;
int iCount = CBGetCount(fodInfos->DlgInfos.hwndFileTypeCB);
*/
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
TRACE("%p\n", fodInfos);
0,
&sfi,
sizeof(sfi),
- SHGFI_DISPLAYNAME | SHGFI_SYSICONINDEX
- | SHGFI_PIDL | SHGFI_SMALLICON | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
+ SHGFI_DISPLAYNAME | SHGFI_PIDL | SHGFI_ATTRIBUTES | SHGFI_ATTR_SPECIFIED);
TRACE("-- Add %s attr=%08x\n", debugstr_w(sfi.szDisplayName), sfi.dwAttributes);
*/
static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LookInInfos *liInfos = GetPropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
int iPos;
int iCount = CBGetCount(fodInfos->DlgInfos.hwndLookInCB);
*/
void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
{
- FileOpenDlgInfos *fodInfos;
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
LPITEMIDLIST pidl;
LPWSTR lpstrAllFiles, lpstrTmp;
UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, nThisFileLength, nAllFilesMaxLength;
FORMATETC formatetc = get_def_format();
TRACE("\n");
- fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, &medium)))
return;
*/
static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed)
{
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
UINT nFileCount = 0; /* number of files */
UINT nStrLen = 0; /* length of string in edit control */
LPWSTR lpstrEdit; /* buffer for string from edit control */
*/
static BOOL BrowseSelectedFolder(HWND hwnd)
{
+ FileOpenDlgInfos *fodInfos = get_filedlg_infoptr(hwnd);
BOOL bBrowseSelFolder = FALSE;
- FileOpenDlgInfos *fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
TRACE("\n");
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
-BOOL WINAPI GetOpenFileNameA(
- LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
+BOOL WINAPI GetOpenFileNameA(OPENFILENAMEA *ofn)
{
TRACE("flags %08x\n", ofn->Flags);
if (is_win16_looks(ofn->Flags))
return GetFileName31A(ofn, OPEN_DIALOG);
else
- return GetFileDialog95A(ofn, OPEN_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoA(ofn, &info);
+ return GetFileDialog95(&info, OPEN_DIALOG);
+ }
}
/***********************************************************************
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
-BOOL WINAPI GetOpenFileNameW(
- LPOPENFILENAMEW ofn) /* [in/out] address of init structure */
+BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
{
TRACE("flags %08x\n", ofn->Flags);
if (is_win16_looks(ofn->Flags))
return GetFileName31W(ofn, OPEN_DIALOG);
else
- return GetFileDialog95W(ofn, OPEN_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoW(ofn, &info);
+ return GetFileDialog95(&info, OPEN_DIALOG);
+ }
}
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
*
*/
-BOOL WINAPI GetSaveFileNameA(
- LPOPENFILENAMEA ofn) /* [in/out] address of init structure */
+BOOL WINAPI GetSaveFileNameA(OPENFILENAMEA *ofn)
{
if (!valid_struct_size( ofn->lStructSize ))
{
if (is_win16_looks(ofn->Flags))
return GetFileName31A(ofn, SAVE_DIALOG);
else
- return GetFileDialog95A(ofn, SAVE_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoA(ofn, &info);
+ return GetFileDialog95(&info, SAVE_DIALOG);
+ }
}
/***********************************************************************
if (is_win16_looks(ofn->Flags))
return GetFileName31W(ofn, SAVE_DIALOG);
else
- return GetFileDialog95W(ofn, SAVE_DIALOG);
+ {
+ FileOpenDlgInfos info;
+
+ init_filedlg_infoW(ofn, &info);
+ return GetFileDialog95(&info, SAVE_DIALOG);
+ }
}
/***********************************************************************
LPWSTR custom_filenamelabel;
UINT cctrl_width, cctrl_def_height, cctrls_cols;
- UINT cctrl_indent;
+ UINT cctrl_indent, dpi_x, dpi_y;
HWND cctrls_hwnd;
struct list cctrls;
UINT_PTR cctrl_next_dlgid;
RECT rc;
HDC hdc;
WCHAR *c;
+ HFONT font;
TRACE("\n");
SendMessageW(hctrl, WM_GETTEXT, len+1, (LPARAM)text);
hdc = GetDC(hctrl);
+ font = (HFONT)SendMessageW(hctrl, WM_GETFONT, 0, 0);
+ font = SelectObject(hdc, font);
GetTextExtentPoint32W(hdc, text, lstrlenW(text), &size);
+ SelectObject(hdc, font);
ReleaseDC(hctrl, hdc);
if(len && multiline)
{
RECT rc;
UINT total_height;
- UINT max_width;
+ UINT max_width, size;
customctrl *sub_ctrl;
switch(ctrl->type)
case IDLG_CCTRL_COMBOBOX:
case IDLG_CCTRL_CHECKBUTTON:
case IDLG_CCTRL_TEXT:
- ctrl_resize(ctrl->hwnd, 160, 160, TRUE);
+ size = MulDiv(160, This->dpi_x, USER_DEFAULT_SCREEN_DPI);
+ ctrl_resize(ctrl->hwnd, size, size, TRUE);
GetWindowRect(ctrl->hwnd, &rc);
SetWindowPos(ctrl->wrapper_hwnd, NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top,
SWP_NOZORDER|SWP_NOMOVE);
LIST_FOR_EACH_ENTRY(item, &ctrl->sub_items, cctrl_item, entry)
{
- ctrl_resize(item->hwnd, 160, 160, TRUE);
+ size = MulDiv(160, This->dpi_x, USER_DEFAULT_SCREEN_DPI);
+ ctrl_resize(item->hwnd, size, size, TRUE);
SetWindowPos(item->hwnd, NULL, 0, total_height, 0, 0,
SWP_NOZORDER|SWP_NOSIZE);
UINT cur_col_pos, cur_row_pos;
customctrl *ctrl;
BOOL fits_height;
- static const UINT cspacing = 90; /* Columns are spaced with 90px */
- static const UINT rspacing = 4; /* Rows are spaced with 4 px. */
+ UINT cspacing = MulDiv(90, This->dpi_x, USER_DEFAULT_SCREEN_DPI); /* Columns are spaced with 90px */
+ UINT rspacing = MulDiv(4, This->dpi_y, USER_DEFAULT_SCREEN_DPI); /* Rows are spaced with 4 px. */
/* Given the new width of the container, this function determines the
* needed height of the container and places the controls according to
return container_height;
}
+static void ctrl_set_font(customctrl *ctrl, HFONT font)
+{
+ customctrl *sub_ctrl;
+ cctrl_item* item;
+
+ SendMessageW(ctrl->hwnd, WM_SETFONT, (WPARAM)font, TRUE);
+
+ LIST_FOR_EACH_ENTRY(sub_ctrl, &ctrl->sub_cctrls, customctrl, sub_cctrls_entry)
+ {
+ ctrl_set_font(sub_ctrl, font);
+ }
+
+ if (ctrl->type == IDLG_CCTRL_RADIOBUTTONLIST)
+ {
+ LIST_FOR_EACH_ENTRY(item, &ctrl->sub_items, cctrl_item, entry)
+ {
+ SendMessageW(item->hwnd, WM_SETFONT, (WPARAM)font, TRUE);
+ }
+ }
+}
+
static void ctrl_container_reparent(FileDialogImpl *This, HWND parent)
{
LONG wndstyle;
if(parent)
{
- customctrl *ctrl, *sub_ctrl;
+ customctrl *ctrl;
HFONT font;
wndstyle = GetWindowLongW(This->cctrls_hwnd, GWL_STYLE);
LIST_FOR_EACH_ENTRY(ctrl, &This->cctrls, customctrl, entry)
{
- if(font) SendMessageW(ctrl->hwnd, WM_SETFONT, (WPARAM)font, TRUE);
-
- /* If this is a VisualGroup */
- LIST_FOR_EACH_ENTRY(sub_ctrl, &ctrl->sub_cctrls, customctrl, sub_cctrls_entry)
- {
- if(font) SendMessageW(sub_ctrl->hwnd, WM_SETFONT, (WPARAM)font, TRUE);
- }
-
- if (ctrl->type == IDLG_CCTRL_RADIOBUTTONLIST)
- {
- cctrl_item* item;
- LIST_FOR_EACH_ENTRY(item, &ctrl->sub_items, cctrl_item, entry)
- {
- if (font) SendMessageW(item->hwnd, WM_SETFONT, (WPARAM)font, TRUE);
- }
- }
-
+ if(font) ctrl_set_font(ctrl, font);
customctrl_resize(This, ctrl);
}
}
static HRESULT init_custom_controls(FileDialogImpl *This)
{
WNDCLASSW wc;
+ HDC hdc;
static const WCHAR ctrl_container_classname[] =
{'i','d','l','g','_','c','o','n','t','a','i','n','e','r','_','p','a','n','e',0};
InitCommonControlsEx(NULL);
- This->cctrl_width = 160; /* Controls have a fixed width */
- This->cctrl_indent = 100;
- This->cctrl_def_height = 23;
- This->cctrls_cols = 0;
-
- This->cctrl_next_dlgid = 0x2000;
- list_init(&This->cctrls);
- This->cctrl_active_vg = NULL;
-
if( !GetClassInfoW(COMDLG32_hInstance, ctrl_container_classname, &wc) )
{
wc.style = CS_HREDRAW | CS_VREDRAW;
if(!This->cctrls_hwnd)
return E_FAIL;
+ hdc = GetDC(This->cctrls_hwnd);
+ This->dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
+ This->dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
+ ReleaseDC(This->cctrls_hwnd, hdc);
+
+ This->cctrl_width = MulDiv(160, This->dpi_x, USER_DEFAULT_SCREEN_DPI); /* Controls have a fixed width */
+ This->cctrl_indent = MulDiv(100, This->dpi_x, USER_DEFAULT_SCREEN_DPI);
+ This->cctrl_def_height = MulDiv(23, This->dpi_y, USER_DEFAULT_SCREEN_DPI);
+ This->cctrls_cols = 0;
+
+ This->cctrl_next_dlgid = 0x2000;
+ list_init(&This->cctrls);
+ This->cctrl_active_vg = NULL;
+
SetWindowLongW(This->cctrls_hwnd, GWL_STYLE, WS_TABSTOP);
/* Register class for */
HWND hitem;
LPCWSTR custom_okbutton;
cctrl_item* item;
+ UINT min_width = MulDiv(50, This->dpi_x, USER_DEFAULT_SCREEN_DPI);
+ UINT max_width = MulDiv(250, This->dpi_x, USER_DEFAULT_SCREEN_DPI);
if(This->custom_title)
SetWindowTextW(This->dlg_hwnd, This->custom_title);
(hitem = GetDlgItem(This->dlg_hwnd, IDOK)))
{
SetWindowTextW(hitem, custom_okbutton);
- ctrl_resize(hitem, 50, 250, FALSE);
+ ctrl_resize(hitem, min_width, max_width, FALSE);
}
if(This->custom_cancelbutton &&
(hitem = GetDlgItem(This->dlg_hwnd, IDCANCEL)))
{
SetWindowTextW(hitem, This->custom_cancelbutton);
- ctrl_resize(hitem, 50, 250, FALSE);
+ ctrl_resize(hitem, min_width, max_width, FALSE);
}
if(This->custom_filenamelabel &&
(hitem = GetDlgItem(This->dlg_hwnd, IDC_FILENAMESTATIC)))
{
SetWindowTextW(hitem, This->custom_filenamelabel);
- ctrl_resize(hitem, 50, 250, FALSE);
+ ctrl_resize(hitem, min_width, max_width, FALSE);
}
}