static void FILEDLG95_SHELL_Clean(HWND hwnd);\r
static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd);\r
\r
+/* Functions used by the EDIT box */\r
+static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator);\r
+\r
/* Functions used by the filetype combo box */\r
static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd);\r
static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode);\r
static void FILEDLG95_FILETYPE_Clean(HWND hwnd);\r
\r
/* Functions used by the Look In combo box */\r
-static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo);\r
+static void FILEDLG95_LOOKIN_Init(HWND hwndCombo);\r
static LRESULT FILEDLG95_LOOKIN_DrawItem(LPDRAWITEMSTRUCT pDIStruct);\r
static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode);\r
static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId);\r
static void FILEDLG95_LOOKIN_Clean(HWND hwnd);\r
\r
/* Miscellaneous tool functions */\r
-HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);\r
-HRESULT GetFileName(HWND hwnd, LPITEMIDLIST pidl, LPSTR lpstrFileName);\r
+static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName);\r
IShellFolder* GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);\r
LPITEMIDLIST GetParentPidl(LPITEMIDLIST pidl);\r
LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);\r
static void *MemAlloc(UINT size);\r
static void MemFree(void *mem);\r
\r
-BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos);\r
INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
-HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);\r
-HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
-BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);\r
+void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);\r
+static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\r
+static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);\r
static BOOL BrowseSelectedFolder(HWND hwnd);\r
\r
/***********************************************************************\r
* OUT : TRUE on success\r
* FALSE on cancel, error, close or filename-does-not-fit-in-buffer.\r
*/\r
-BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos)\r
+static BOOL WINAPI GetFileName95(FileOpenDlgInfos *fodInfos)\r
{\r
\r
LRESULT lRes;\r
return ret;\r
}\r
\r
+/******************************************************************************\r
+ * COMDLG32_GetDisplayNameOf [internal]\r
+ *\r
+ * Helper function to get the display name for a pidl.\r
+ */\r
+static BOOL COMDLG32_GetDisplayNameOf(LPCITEMIDLIST pidl, LPWSTR pwszPath) {\r
+ LPSHELLFOLDER psfDesktop;\r
+ STRRET strret;\r
+ \r
+ if (FAILED(SHGetDesktopFolder(&psfDesktop)))\r
+ return FALSE;\r
+\r
+ if (FAILED(IShellFolder_GetDisplayNameOf(psfDesktop, pidl, SHGDN_FORPARSING, &strret))) {\r
+ IShellFolder_Release(psfDesktop);\r
+ return FALSE;\r
+ }\r
+\r
+ IShellFolder_Release(psfDesktop);\r
+ return SUCCEEDED(StrRetToBufW(&strret, pidl, pwszPath, MAX_PATH));\r
+}\r
+\r
/***********************************************************************\r
* ArrangeCtrlPositions [internal]\r
*\r
* Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog\r
*/\r
\r
-HRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)\r
+void SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)\r
{\r
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwndParentDlg,FileOpenDlgInfosStr);\r
\r
TRACE("%p 0x%04x\n",hwndParentDlg, uCode);\r
\r
- if(!fodInfos) return 0;\r
+ if(!fodInfos) return;\r
\r
if(fodInfos->DlgInfos.hwndCustomDlg)\r
{\r
- HRESULT ret;\r
TRACE("CALL NOTIFY for %x\n", uCode);\r
if(fodInfos->unicode)\r
{\r
ofnNotify.hdr.code = uCode;\r
ofnNotify.lpOFN = fodInfos->ofnInfos;\r
ofnNotify.pszFile = NULL;\r
- ret = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);\r
+ SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);\r
}\r
else\r
{\r
ofnNotify.hdr.code = uCode;\r
ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;\r
ofnNotify.pszFile = NULL;\r
- ret = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);\r
+ SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);\r
}\r
TRACE("RET NOTIFY\n");\r
- return ret;\r
}\r
- return TRUE;\r
}\r
\r
-HRESULT FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)\r
+static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID buffer)\r
{\r
- UINT sizeUsed = 0, n, total;\r
+ INT_PTR sizeUsed = 0, n, total;\r
LPWSTR lpstrFileList = NULL;\r
WCHAR lpstrCurrentDir[MAX_PATH];\r
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);\r
return -1;\r
\r
/* get path and filenames */\r
- SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrCurrentDir);\r
+ COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrCurrentDir);\r
n = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, ' ');\r
\r
TRACE("path >%s< filespec >%s< %d files\n",\r
return total;\r
}\r
\r
-HRESULT FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)\r
+static INT_PTR FILEDLG95_Handle_GetFileSpec(HWND hwnd, DWORD size, LPVOID buffer)\r
{\r
- UINT sizeUsed = 0;\r
+ INT_PTR sizeUsed = 0;\r
LPWSTR lpstrFileList = NULL;\r
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);\r
\r
*\r
* Handle Custom Dialog Messages (CDM_FIRST -- CDM_LAST) messages\r
*/\r
-HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
{\r
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);\r
- if(!fodInfos) return -1;\r
+ WCHAR lpstrPath[MAX_PATH];\r
+ INT_PTR retval;\r
+\r
+ if(!fodInfos) return FALSE;\r
\r
switch(uMsg)\r
{\r
case CDM_GETFILEPATH:\r
- return FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam);\r
+ retval = FILEDLG95_Handle_GetFilePath(hwnd, (UINT)wParam, (LPVOID)lParam);\r
+ break;\r
\r
case CDM_GETFOLDERPATH:\r
TRACE("CDM_GETFOLDERPATH:\n");\r
- if( fodInfos->unicode )\r
- {\r
- WCHAR lpstrPath[MAX_PATH], *bufW = (LPWSTR)lParam;\r
- SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);\r
- if (bufW)\r
- lstrcpynW(bufW,lpstrPath,(int)wParam);\r
- return strlenW(lpstrPath);\r
- }\r
- else\r
+ COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPath);\r
+ if (lParam) \r
{\r
- char lpstrPath[MAX_PATH], *bufA = (LPSTR)lParam;\r
- SHGetPathFromIDListA(fodInfos->ShellInfos.pidlAbsCurrent,lpstrPath);\r
- if (bufA)\r
- lstrcpynA(bufA,lpstrPath,(int)wParam);\r
- return strlen(lpstrPath);\r
- }\r
+ if (fodInfos->unicode)\r
+ lstrcpynW((LPWSTR)lParam, lpstrPath, (int)wParam);\r
+ else\r
+ WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1, \r
+ (LPSTR)lParam, (int)wParam, NULL, NULL);\r
+ } \r
+ retval = strlenW(lpstrPath);\r
+ break;\r
\r
case CDM_GETSPEC:\r
- return FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);\r
+ retval = FILEDLG95_Handle_GetFileSpec(hwnd, (UINT)wParam, (LPSTR)lParam);\r
+ break;\r
\r
case CDM_SETCONTROLTEXT:\r
TRACE("CDM_SETCONTROLTEXT:\n");\r
else\r
SetDlgItemTextA( hwnd, (UINT) wParam, (LPSTR) lParam );\r
}\r
- return TRUE;\r
+ retval = TRUE;\r
+ break;\r
\r
case CDM_HIDECONTROL:\r
case CDM_SETDEFEXT:\r
FIXME("CDM_HIDECONTROL,CDM_SETCONTROLTEXT,CDM_SETDEFEXT not implemented\n");\r
- return -1;\r
+ retval = -1;\r
+ break;\r
+\r
+ default:\r
+ return FALSE;\r
}\r
+ SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, retval);\r
return TRUE;\r
}\r
\r
ofn->lpstrFile[0] = '\0';\r
}\r
\r
- SHGetPathFromIDListW( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );\r
+ COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathSpec );\r
\r
if ( !(fodInfos->ofnInfos->Flags & OFN_NOVALIDATE) &&\r
( fodInfos->ofnInfos->Flags & OFN_FILEMUSTEXIST) &&\r
*\r
* If the function succeeds, the return value is nonzero.\r
*/\r
-#define ONOPEN_BROWSE 1\r
-#define ONOPEN_OPEN 2\r
-#define ONOPEN_SEARCH 3\r
+#define ONOPEN_OPEN 1\r
+#define ONOPEN_SEARCH 2\r
static void FILEDLG95_OnOpenMessage(HWND hwnd, int idCaption, int idText)\r
{\r
WCHAR strMsgTitle[MAX_PATH];\r
\r
TRACE("hwnd=%p\n", hwnd);\r
\r
+ if(BrowseSelectedFolder(hwnd))\r
+ return FALSE;\r
+\r
/* get the files from the edit control */\r
nFileCount = FILEDLG95_FILENAME_GetFileNames(hwnd, &lpstrFileList, &sizeUsed, '\0');\r
\r
/* try if the user selected a folder in the shellview */\r
if(nFileCount == 0)\r
- {\r
- BrowseSelectedFolder(hwnd);\r
return FALSE;\r
- }\r
\r
if(nFileCount > 1)\r
{\r
*/\r
\r
/* Get the current directory name */\r
- if (!SHGetPathFromIDListW(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))\r
+ if (!COMDLG32_GetDisplayNameOf(fodInfos->ShellInfos.pidlAbsCurrent, lpstrPathAndFile))\r
{\r
- /* we are in a special folder, default to desktop */\r
- if(FAILED(COMDLG32_SHGetFolderPathW(hwnd, CSIDL_DESKTOPDIRECTORY|CSIDL_FLAG_CREATE, 0, 0, lpstrPathAndFile)))\r
- {\r
- /* last fallback */\r
- GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);\r
- }\r
+ /* last fallback */\r
+ GetCurrentDirectoryW(MAX_PATH, lpstrPathAndFile);\r
}\r
PathAddBackslashW(lpstrPathAndFile);\r
\r
lpstrPathAndFile: cleaned up path\r
*/\r
\r
- nOpenAction = ONOPEN_BROWSE;\r
+ nOpenAction = ONOPEN_OPEN;\r
\r
/* don't apply any checks with OFN_NOVALIDATE */\r
{\r
int iPos;\r
LPWSTR lpszTemp = PathFindFileNameW(lpstrPathAndFile);\r
DWORD len;\r
+ IPersistFolder2 * ppf2;\r
\r
/* replace the current filter */\r
if(fodInfos->ShellInfos.lpstrCurrentFilter)\r
/* set the filter cb to the extension when possible */\r
if(-1 < (iPos = FILEDLG95_FILETYPE_SearchExt(fodInfos->DlgInfos.hwndFileTypeCB, lpszTemp)))\r
CBSetCurSel(fodInfos->DlgInfos.hwndFileTypeCB, iPos);\r
- }\r
- /* fall through */\r
- case ONOPEN_BROWSE: /* browse to the highest folder we could bind to */\r
- TRACE("ONOPEN_BROWSE\n");\r
- {\r
- IPersistFolder2 * ppf2;\r
+\r
if(SUCCEEDED(IShellFolder_QueryInterface( lpsf, &IID_IPersistFolder2, (LPVOID*)&ppf2)))\r
{\r
LPITEMIDLIST pidlCurrent;\r
{\r
IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE);\r
}\r
- else if( nOpenAction == ONOPEN_SEARCH )\r
+ else\r
{\r
IShellView_Refresh(fodInfos->Shell.FOIShellView);\r
}\r
+ SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);\r
COMDLG32_SHFree(pidlCurrent);\r
}\r
}\r
fodInfos->ofnInfos->Flags &= ~OFN_READONLY;\r
\r
/* Attach the file extension with file name*/\r
- ext = PathFindExtensionW(lpstrPathAndFile);\r
- if (! *ext)\r
+\r
+ if(!PathIsDirectoryW(lpstrPathAndFile))\r
{\r
- /* if no extension is specified with file name, then */\r
- /* attach the extension from file filter or default one */\r
+ if((ext = PathFindExtensionW(lpstrPathAndFile)) == NULL)\r
+ {\r
+ /* if no extension is specified with file name, then */\r
+ /* attach the extension from file filter or default one */\r
\r
- WCHAR *filterExt = NULL;\r
- LPWSTR lpstrFilter = NULL;\r
- static const WCHAR szwDot[] = {'.',0};\r
- int PathLength = strlenW(lpstrPathAndFile);\r
+ WCHAR *filterExt = NULL;\r
+ LPWSTR lpstrFilter = NULL;\r
+ static const WCHAR szwDot[] = {'.',0};\r
+ int PathLength = strlenW(lpstrPathAndFile);\r
\r
- /* Attach the dot*/\r
- strcatW(lpstrPathAndFile, szwDot);\r
+ /* Attach the dot*/\r
+ strcatW(lpstrPathAndFile, szwDot);\r
\r
- /*Get the file extension from file type filter*/\r
- lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,\r
- fodInfos->ofnInfos->nFilterIndex-1);\r
+ /*Get the file extension from file type filter*/\r
+ lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,\r
+ fodInfos->ofnInfos->nFilterIndex-1);\r
\r
- if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */\r
- filterExt = PathFindExtensionW(lpstrFilter);\r
+ if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */\r
+ filterExt = PathFindExtensionW(lpstrFilter);\r
\r
- if ( filterExt && *filterExt ) /* attach the file extension from file type filter*/\r
- strcatW(lpstrPathAndFile, filterExt + 1);\r
- else if ( fodInfos->defext ) /* attach the default file extension*/\r
- strcatW(lpstrPathAndFile, fodInfos->defext);\r
+ if ( filterExt && *filterExt ) /* attach the file extension from file type filter*/\r
+ strcatW(lpstrPathAndFile, filterExt + 1);\r
+ else if ( fodInfos->defext ) /* attach the default file extension*/\r
+ strcatW(lpstrPathAndFile, fodInfos->defext);\r
\r
- /* In Open dialog: if file does not exist try without extension */\r
- if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))\r
- lpstrPathAndFile[PathLength] = '\0';\r
+ /* In Open dialog: if file does not exist try without extension */\r
+ if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))\r
+ lpstrPathAndFile[PathLength] = '\0';\r
+ }\r
+ \r
+ if (fodInfos->defext) /* add default extension */\r
+ {\r
+ /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */\r
+ if (*ext)\r
+ ext++;\r
+ if (!lstrcmpiW(fodInfos->defext, ext))\r
+ fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT;\r
+ else\r
+ fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT;\r
+ }\r
}\r
\r
- if (fodInfos->defext) /* add default extension */\r
- {\r
- /* Set/clear the output OFN_EXTENSIONDIFFERENT flag */\r
- if (*ext)\r
- ext++;\r
- if (!lstrcmpiW(fodInfos->defext, ext))\r
- fodInfos->ofnInfos->Flags &= ~OFN_EXTENSIONDIFFERENT;\r
- else\r
- fodInfos->ofnInfos->Flags |= OFN_EXTENSIONDIFFERENT;\r
- }\r
-\r
/* In Save dialog: check if the file already exists */\r
if (fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG\r
&& fodInfos->ofnInfos->Flags & OFN_OVERWRITEPROMPT\r
NULL,\r
SBSP_PARENT)))\r
{\r
+ SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);\r
return TRUE;\r
}\r
return FALSE;\r
\r
SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);\r
hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);\r
+ SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);\r
COMDLG32_SHFree(pidl);\r
return SUCCEEDED(hres);\r
}\r
}\r
} else\r
fodInfos->ofnInfos->nFilterIndex = 0;\r
-\r
- return NOERROR;\r
+ return S_OK;\r
}\r
\r
/***********************************************************************\r
*\r
* Initialisation of the look in combo box\r
*/\r
-static HRESULT FILEDLG95_LOOKIN_Init(HWND hwndCombo)\r
+static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)\r
{\r
IShellFolder *psfRoot, *psfDrives;\r
IEnumIDList *lpeRoot, *lpeDrives;\r
}\r
\r
COMDLG32_SHFree(pidlDrives);\r
- return NOERROR;\r
}\r
\r
/***********************************************************************\r
tmpFolder->pidlItem,\r
SBSP_ABSOLUTE)))\r
{\r
+ SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);\r
return TRUE;\r
}\r
break;\r
}\r
\r
\r
-/* copied from shell32 to avoid linking to it */\r
+/* copied from shell32 to avoid linking to it\r
+ * FIXME: why? shell32 is already linked\r
+ */\r
static HRESULT COMDLG32_StrRetToStrNA (LPVOID dest, DWORD len, LPSTRRET src, LPITEMIDLIST pidl)\r
{\r
switch (src->uType)\r
{\r
*(LPSTR)dest = '\0';\r
}\r
- return(FALSE);\r
+ return(E_FAIL);\r
}\r
return S_OK;\r
}\r
* The delimiter is specified by the parameter 'separator',\r
* usually either a space or a nul\r
*/\r
-int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator)\r
+static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, UINT * sizeUsed, char separator)\r
{\r
FileOpenDlgInfos *fodInfos = (FileOpenDlgInfos *) GetPropA(hwnd,FileOpenDlgInfosStr);\r
UINT nStrCharCount = 0; /* index in src buffer */\r
* E_FAIL otherwise\r
*/\r
\r
-HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName)\r
+static HRESULT GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST pidl,DWORD dwFlags,LPSTR lpstrFileName)\r
{\r
STRRET str;\r
HRESULT hRes;\r
' ','n','o','t',' ','e','x','i','s','t',0};\r
MessageBoxW( hwnd, notexist, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );\r
}\r
-\r
- bBrowseSelFolder = TRUE;\r
+ bBrowseSelFolder = TRUE;\r
+ SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);\r
}\r
COMDLG32_SHFree( pidlSelection );\r
}\r
* PrintDlg:\r
* * The Collate Icons do not display, even though they are in the code.\r
* * The Properties Button(s) should call DocumentPropertiesA().\r
- * PrintSetupDlg:\r
- * * The Paper Orientation Icons are not implemented yet.\r
- * * The Properties Button(s) should call DocumentPropertiesA().\r
- * * Settings are not yet taken from a provided DevMode or\r
- * default printer settings.\r
*/\r
\r
BOOL WINAPI PrintDlgA(\r
* PageSetupDlg\r
* rad1 - portrait\r
* rad2 - landscape\r
+ * cmb1 - printer select (not in standart dialog template)\r
* cmb2 - paper size\r
* cmb3 - source (tray?)\r
* edt4 - border left\r
}\r
\r
\r
+/***********************************************************************\r
+ * DefaultPagePaintHook\r
+ * Default hook paint procedure that receives WM_PSD_* messages from the dialog box \r
+ * whenever the sample page is redrawn.\r
+*/\r
+\r
+static UINT_PTR\r
+PRINTDLG_DefaultPagePaintHook(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, PageSetupDataA *pda)\r
+{\r
+ LPRECT lprc = (LPRECT) lParam;\r
+ HDC hdc = (HDC) wParam;\r
+ HPEN hpen, holdpen;\r
+ LOGFONTW lf;\r
+ HFONT hfont, holdfont;\r
+ INT oldbkmode;\r
+ TRACE("uMsg: WM_USER+%d\n",uMsg-WM_USER);\r
+\r
+ /* Call user paint hook if enable */\r
+ if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK)\r
+ if (pda->dlga->lpfnPagePaintHook(hwndDlg, uMsg, wParam, lParam))\r
+ return TRUE;\r
+\r
+ switch (uMsg) {\r
+ /* LPPAGESETUPDLG in lParam */\r
+ case WM_PSD_PAGESETUPDLG:\r
+ /* Inform about the sample page rectangle */\r
+ case WM_PSD_FULLPAGERECT:\r
+ /* Inform about the margin rectangle */\r
+ case WM_PSD_MINMARGINRECT:\r
+ return FALSE;\r
+\r
+ /* Draw dashed rectangle showing margins */\r
+ case WM_PSD_MARGINRECT:\r
+ hpen = CreatePen(PS_DASH, 1, GetSysColor(COLOR_3DSHADOW));\r
+ holdpen = SelectObject(hdc, hpen);\r
+ Rectangle(hdc, lprc->left, lprc->top, lprc->right, lprc->bottom);\r
+ DeleteObject(SelectObject(hdc, holdpen));\r
+ return TRUE;\r
+\r
+\r
+ /* Draw the fake document */\r
+ case WM_PSD_GREEKTEXTRECT:\r
+ /* select a nice scalable font, because we want the text really small */\r
+ SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);\r
+ lf.lfHeight = 6; /* value chosen based on visual effect */\r
+ hfont = CreateFontIndirectW(&lf);\r
+ holdfont = SelectObject(hdc, hfont);\r
+\r
+ /* if text not loaded, then do so now */\r
+ if (wszFakeDocumentText[0] == '\0')\r
+ LoadStringW(COMDLG32_hInstance,\r
+ IDS_FAKEDOCTEXT,\r
+ wszFakeDocumentText,\r
+ sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0]));\r
+\r
+ oldbkmode = SetBkMode(hdc, TRANSPARENT);\r
+ DrawTextW(hdc, wszFakeDocumentText, -1, lprc, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK);\r
+ SetBkMode(hdc, oldbkmode);\r
+\r
+ DeleteObject(SelectObject(hdc, holdfont));\r
+ return TRUE;\r
+\r
+ /* Envelope stamp */\r
+ case WM_PSD_ENVSTAMPRECT:\r
+ /* Return address */\r
+ case WM_PSD_YAFULLPAGERECT:\r
+ FIXME("envelope/stamp is not implemented\n");\r
+ return FALSE;\r
+ default:\r
+ FIXME("Unknown message %x\n",uMsg);\r
+ return FALSE;\r
+ }\r
+ return TRUE;\r
+}\r
+\r
+/***********************************************************************\r
+ * PagePaintProc\r
+ * The main paint procedure for the PageSetupDlg function.\r
+ * The Page Setup dialog box includes an image of a sample page that shows how\r
+ * the user's selections affect the appearance of the printed output.\r
+ * The image consists of a rectangle that represents the selected paper\r
+ * or envelope type, with a dotted-line rectangle representing\r
+ * the current margins, and partial (Greek text) characters\r
+ * to show how text looks on the printed page. \r
+ *\r
+ * The following messages in the order sends to user hook procedure:\r
+ * WM_PSD_PAGESETUPDLG Draw the contents of the sample page\r
+ * WM_PSD_FULLPAGERECT Inform about the bounding rectangle\r
+ * WM_PSD_MINMARGINRECT Inform about the margin rectangle (min margin?)\r
+ * WM_PSD_MARGINRECT Draw the margin rectangle\r
+ * WM_PSD_GREEKTEXTRECT Draw the Greek text inside the margin rectangle\r
+ * If any of first three messages returns TRUE, painting done.\r
+ *\r
+ * PARAMS:\r
+ * hWnd [in] Handle to the Page Setup dialog box\r
+ * uMsg [in] Received message\r
+ *\r
+ * TODO:\r
+ * WM_PSD_ENVSTAMPRECT Draw in the envelope-stamp rectangle (for envelopes only)\r
+ * WM_PSD_YAFULLPAGERECT Draw the return address portion (for envelopes and other paper sizes)\r
+ *\r
+ * RETURNS:\r
+ * FALSE if all done correctly\r
+ *\r
+ */\r
static LRESULT CALLBACK\r
-PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
{\r
- if (uMsg == WM_PAINT)\r
- {\r
- PAINTSTRUCT ps;\r
- RECT rcClient;\r
- HPEN hpen, holdpen;\r
- HDC hdc;\r
- HFONT hfont, holdfont;\r
- LOGFONTW lf;\r
- HBRUSH hbrush, holdbrush;\r
- INT oldbkmode;\r
+ PAINTSTRUCT ps;\r
+ RECT rcClient, rcMargin;\r
+ HPEN hpen, holdpen;\r
+ HDC hdc;\r
+ HBRUSH hbrush, holdbrush;\r
+ PageSetupDataA *pda;\r
+ int papersize=0, orientation=0; /* FIXME: set this values */\r
+\r
+#define CALLPAINTHOOK(msg,lprc) PRINTDLG_DefaultPagePaintHook( hWnd, msg, (WPARAM)hdc, (LPARAM)lprc, pda)\r
+\r
+ if (uMsg != WM_PAINT)\r
+ return CallWindowProcA(lpfnStaticWndProc, hWnd, uMsg, wParam, lParam);\r
+\r
+ /* Processing WM_PAINT message */\r
+ pda = (PageSetupDataA*)GetPropA(hWnd, "__WINE_PAGESETUPDLGDATA");\r
+ if (!pda) {\r
+ WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");\r
+ return FALSE;\r
+ }\r
+ if (PRINTDLG_DefaultPagePaintHook(hWnd, WM_PSD_PAGESETUPDLG, MAKELONG(papersize, orientation), (LPARAM)pda->dlga, pda))\r
+ return FALSE;\r
\r
- hdc = BeginPaint(hWnd, &ps);\r
+ hdc = BeginPaint(hWnd, &ps);\r
+ GetClientRect(hWnd, &rcClient);\r
\r
- GetClientRect(hWnd, &rcClient);\r
+ /* FIXME: use real margin values */\r
+ rcMargin = rcClient;\r
+ rcMargin.left += 5;\r
+ rcMargin.top += 5;\r
+ rcMargin.right -= 5;\r
+ rcMargin.bottom -= 5;\r
\r
+ /* if the space is too small then we make sure to not draw anything */\r
+ rcMargin.left = min(rcMargin.left, rcMargin.right);\r
+ rcMargin.top = min(rcMargin.top, rcMargin.bottom);\r
+\r
+ if (!CALLPAINTHOOK(WM_PSD_FULLPAGERECT, &rcClient) &&\r
+ !CALLPAINTHOOK(WM_PSD_MINMARGINRECT, &rcMargin) )\r
+ {\r
/* fill background */\r
hbrush = GetSysColorBrush(COLOR_3DHIGHLIGHT);\r
FillRect(hdc, &rcClient, hbrush);\r
hpen = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));\r
holdpen = SelectObject(hdc, hpen);\r
\r
+ \r
/* paint left edge */\r
MoveToEx(hdc, rcClient.left, rcClient.top, NULL);\r
LineTo(hdc, rcClient.left, rcClient.bottom-1);\r
MoveToEx(hdc, rcClient.left, rcClient.bottom-1, NULL);\r
LineTo(hdc, rcClient.right, rcClient.bottom-1);\r
\r
- hpen = CreatePen(PS_DASH, 1, GetSysColor(COLOR_3DSHADOW));\r
- DeleteObject(SelectObject(hdc, hpen));\r
-\r
- /* draw dashed rectangle showing margins */\r
-\r
- /* FIXME: use real margin values */\r
- rcClient.left += 5;\r
- rcClient.top += 5;\r
- rcClient.right -= 5;\r
- rcClient.bottom -= 5;\r
-\r
- /* if the space is too small then we make sure to not draw anything */\r
- rcClient.left = min(rcClient.left,rcClient.right);\r
- rcClient.top = min(rcClient.top,rcClient.bottom);\r
+ DeleteObject(SelectObject(hdc, holdpen));\r
+ DeleteObject(SelectObject(hdc, holdbrush));\r
\r
- Rectangle(hdc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);\r
\r
- DeleteObject(SelectObject(hdc, holdpen));\r
+ CALLPAINTHOOK(WM_PSD_MARGINRECT, &rcMargin);\r
\r
- /* draw the fake document */\r
\r
/* give text a bit of a space from the frame */\r
- rcClient.left += 2;\r
- rcClient.top += 2;\r
- rcClient.right -= 2;\r
- rcClient.bottom -= 2;\r
-\r
+ rcMargin.left += 2;\r
+ rcMargin.top += 2;\r
+ rcMargin.right -= 2;\r
+ rcMargin.bottom -= 2;\r
+ \r
/* if the space is too small then we make sure to not draw anything */\r
- rcClient.left = min(rcClient.left,rcClient.right);\r
- rcClient.top = min(rcClient.top,rcClient.bottom);\r
-\r
- /* select a nice scalable font, because we want the text really small */\r
- SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);\r
- lf.lfHeight = 6; /* value chosen based on visual effect */\r
- hfont = CreateFontIndirectW(&lf);\r
- holdfont = SelectObject(hdc, hfont);\r
-\r
- /* if text not loaded, then do so now */\r
- if (wszFakeDocumentText[0] == '\0')\r
- LoadStringW(COMDLG32_hInstance,\r
- IDS_FAKEDOCTEXT,\r
- wszFakeDocumentText,\r
- sizeof(wszFakeDocumentText)/sizeof(wszFakeDocumentText[0]));\r
-\r
- oldbkmode = SetBkMode(hdc, TRANSPARENT);\r
- DrawTextW(hdc, wszFakeDocumentText, -1, &rcClient, DT_TOP|DT_LEFT|DT_NOPREFIX|DT_WORDBREAK);\r
- SetBkMode(hdc, oldbkmode);\r
-\r
- DeleteObject(SelectObject(hdc, holdfont));\r
+ rcMargin.left = min(rcMargin.left, rcMargin.right);\r
+ rcMargin.top = min(rcMargin.top, rcMargin.bottom);\r
\r
- SelectObject(hdc, holdbrush);\r
-\r
- EndPaint(hWnd, &ps);\r
- return 0;\r
+ CALLPAINTHOOK(WM_PSD_GREEKTEXTRECT, &rcMargin);\r
}\r
- else\r
- return CallWindowProcW(lpfnStaticWndProc, hWnd, uMsg, wParam, lParam);\r
+\r
+ EndPaint(hWnd, &ps);\r
+ return FALSE;\r
+#undef CALLPAINTHOOK\r
}\r
\r
+/***********************************************************************\r
+ * PRINTDLG_PageDlgProcA\r
+ * Message handler \r
+ */\r
static INT_PTR CALLBACK\r
-PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
+PRINTDLG_PageDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
{\r
PageSetupDataA *pda;\r
INT_PTR res = FALSE;\r
\r
- if (uMsg==WM_INITDIALOG) {\r
+ if (uMsg == WM_INITDIALOG) {\r
+ pda = (PageSetupDataA*)lParam;\r
+ TRACE("set property to %p", pda);\r
+ SetPropA(hDlg, "__WINE_PAGESETUPDLGDATA", pda);\r
+ SetPropA(GetDlgItem(hDlg, rct1), "__WINE_PAGESETUPDLGDATA", pda);\r
lpfnStaticWndProc = (WNDPROC)SetWindowLongPtrW(\r
GetDlgItem(hDlg, rct1),\r
GWLP_WNDPROC,\r
- (ULONG_PTR)PagePaintProc);\r
+ (ULONG_PTR)PRINTDLG_PagePaintProc);\r
res = TRUE;\r
- pda = (PageSetupDataA*)lParam;\r
- SetPropA(hDlg,"__WINE_PAGESETUPDLGDATA",pda);\r
if (pda->dlga->Flags & PSD_ENABLEPAGESETUPHOOK) {\r
res = pda->dlga->lpfnPageSetupHook(hDlg,uMsg,wParam,(LPARAM)pda->dlga);\r
if (!res) {\r
res = TRUE;\r
}\r
}\r
- if (pda->dlga->Flags & PSD_ENABLEPAGEPAINTHOOK) {\r
- FIXME("PagePaintHook not yet implemented!\n");\r
- }\r
+\r
if (pda->dlga->Flags & PSD_DISABLEPRINTER)\r
EnableWindow(GetDlgItem(hDlg, psh3), FALSE);\r
if (pda->dlga->Flags & PSD_DISABLEMARGINS) {\r
\r
/***********************************************************************\r
* PageSetupDlgA (COMDLG32.@)\r
+ *\r
+ * Displays the the PAGE SETUP dialog box, which enables the user to specify\r
+ * specific properties of a printed page such as\r
+ * size, source, orientation and the width of the page margins.\r
+ *\r
+ * PARAMS\r
+ * setupdlg [in] PAGESETUPDLGA struct\r
+ *\r
+ * RETURNS\r
+ * TRUE if the user pressed the OK button\r
+ * FALSE if the user cancelled the window or an error occurred\r
+ *\r
+ * NOTES\r
+ * The values of hDevMode and hDevNames are filled on output and can be\r
+ * changed in PAGESETUPDLG when they are passed in PageSetupDlg.\r
+ * BUGS\r
+ * PrintSetupDlg:\r
+ * * The Paper Orientation Icons are not implemented yet.\r
+ * * The Properties Button(s) should call DocumentPropertiesA().\r
+ * * Settings are not yet taken from a provided DevMode or\r
+ * default printer settings.\r
*/\r
+\r
BOOL WINAPI PageSetupDlgA(LPPAGESETUPDLGA setupdlg) {\r
HGLOBAL hDlgTmpl;\r
LPVOID ptr;\r
setupdlg->hDevNames,\r
setupdlg->hInstance, setupdlg->Flags, flagstr);\r
}\r
+ if (setupdlg->Flags & PSD_ENABLEPAGEPAINTHOOK)\r
+ if (setupdlg->lpfnPagePaintHook == NULL) {\r
+ COMDLG32_SetCommDlgExtendedError(CDERR_NOHOOK);\r
+ return FALSE;\r
+ }\r
\r
/* First get default printer data, we need it right after that. */\r
memset(&pdlg,0,sizeof(pdlg));\r
setupdlg->hInstance,\r
ptr,\r
setupdlg->hwndOwner,\r
- PageDlgProcA,\r
+ PRINTDLG_PageDlgProcA,\r
(LPARAM)pda)\r
);\r
return bRet;\r
BOOL bRet;\r
PageSetupDataW *pdw;\r
PRINTDLGW pdlg;\r
-\r
+ FIXME("Unicode implementation is not done yet\n");\r
if(TRACE_ON(commdlg)) {\r
char flagstr[1000] = "";\r
struct pd_flags *pflag = psd_flags;\r