From 2118ce0fa9785ce301370738b12b8f38a23ca86b Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 20 Mar 2018 10:37:50 +0300 Subject: [PATCH] comdlg32: Add a helper to test if file dialog hook is enabled. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comdlg32/filedlg.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index 81eaecafc35..e721c081dd0 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -84,8 +84,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg); OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\ OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/) -#define IsHooked(fodInfos) \ - ((fodInfos->ofnInfos->Flags & OFN_ENABLEHOOK) && fodInfos->ofnInfos->lpfnHook) /*********************************************************************** * Data structure and global variables */ @@ -184,6 +182,11 @@ FileOpenDlgInfos *get_filedlg_infoptr(HWND hwnd) return GetPropW(hwnd, filedlg_info_propnameW); } +static BOOL is_dialog_hooked(const FileOpenDlgInfos *info) +{ + return (info->ofnInfos->Flags & OFN_ENABLEHOOK) && info->ofnInfos->lpfnHook; +} + /*********************************************************************** * Prototypes */ @@ -307,7 +310,7 @@ static BOOL GetFileName95(FileOpenDlgInfos *fodInfos) } /* old style hook messages */ - if (IsHooked(fodInfos)) + if (is_dialog_hooked(fodInfos)) { fodInfos->HookMsg.fileokstring = RegisterWindowMessageW(FILEOKSTRINGW); fodInfos->HookMsg.lbselchstring = RegisterWindowMessageW(LBSELCHSTRINGW); @@ -824,15 +827,15 @@ static HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd) } if (fodInfos->unicode) hChildDlg = CreateDialogIndirectParamW(hinst, template, hwnd, - IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate, + is_dialog_hooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate, (LPARAM)fodInfos->ofnInfos); else hChildDlg = CreateDialogIndirectParamA(hinst, template, hwnd, - IsHooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate, + is_dialog_hooked(fodInfos) ? (DLGPROC)fodInfos->ofnInfos->lpfnHook : FileOpenDlgProcUserTemplate, (LPARAM)fodInfos->ofnInfos); return hChildDlg; } - else if( IsHooked(fodInfos)) + else if (is_dialog_hooked(fodInfos)) { RECT rectHwnd; struct { @@ -2014,7 +2017,7 @@ static LRESULT FILEDLG95_OnWMGetIShellBrowser(HWND hwnd) static BOOL FILEDLG95_SendFileOK( HWND hwnd, FileOpenDlgInfos *fodInfos ) { /* ask the hook if we can close */ - if(IsHooked(fodInfos)) + if (is_dialog_hooked(fodInfos)) { LRESULT retval = 0;