comdlg32: implement CDN_INCLUDEITEM notification and send it

Ricardo Filipe ricardojdfilipe at gmail.com
Wed Mar 4 18:58:00 CST 2009


hi.
this patch implements the CDN_INCLUDEITEM notification according to MSDN and
to some manual tests i did.
http://msdn.microsoft.com/en-us/library/ms646862.aspx
the first part of the patch is the actual implementation, the
SendCustomDlgNotificationMessage function needs to receive the pidl of the
object to send in the new notification.
the implementation is basically extending what existed already and sending
the new information when CDN_INCLUDEITEM is sent, using the required
structure.
the rest, and biggest, part of the patch is just accomodating the calls to
the SendCustomDlgNotificationMessage function to receive the pidl as
parameter (NULL in other notifications).

the notification is sent everytime
IShellBrowserImpl_ICommDlgBrowser_IncludeObject is called, which means one
time per object, and only if OFN_ENABLEINCLUDENOTIFY was sent in the dialog
Flags.

this patch fixes part of http://bugs.winehq.org/show_bug.cgi?id=8072

i was not able to make an automated test for this... although i did make
manual tests on wine and windows to confirm the implementation and Media
Player Classic is happy. although if  anyone has any idea for a test on this
please drop me a message.

regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090305/514b8cb2/attachment-0001.htm>
-------------- next part --------------
From 4a95ff32644dbe14da6c1967e5ac539ac1f7d282 Mon Sep 17 00:00:00 2001
From: Ricardo Filipe <ricardo_barbano at hotmail.com>
Date: Wed, 4 Mar 2009 22:41:49 +0000
Subject: comdlg32: implement CDN_INCLUDEITEM notification and send it

---
 dlls/comdlg32/filedlg.c        |   88 +++++++++++++++++++++++++++-------------
 dlls/comdlg32/filedlgbrowser.c |   11 ++++-
 dlls/comdlg32/filedlgbrowser.h |    2 +-
 3 files changed, 68 insertions(+), 33 deletions(-)

diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index a2826c8..c5b1cf0 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -82,8 +82,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 
 #define UNIMPLEMENTED_FLAGS \
-(OFN_DONTADDTORECENT |\
-OFN_ENABLEINCLUDENOTIFY | OFN_ENABLESIZING |\
+(OFN_DONTADDTORECENT | OFN_ENABLESIZING |\
 OFN_NODEREFERENCELINKS | OFN_NOREADONLYRETURN |\
 OFN_NOTESTFILECREATE /*| OFN_USEMONIKERS*/)
 
@@ -821,7 +820,7 @@ static HWND CreateTemplateDialog(FileOpenDlgInfos *fodInfos, HWND hwnd)
 * Send CustomDialogNotification (CDN_FIRST -- CDN_LAST) message to the custom template dialog
 */
 
-LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
+LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode, LPCITEMIDLIST pidl)
 {
     LRESULT hook_result = 0;
     FileOpenDlgInfos *fodInfos = GetPropA(hwndParentDlg,FileOpenDlgInfosStr);
@@ -832,28 +831,59 @@ LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode)
 
     if(fodInfos->DlgInfos.hwndCustomDlg)
     {
-	TRACE("CALL NOTIFY for %x\n", uCode);
+        TRACE("CALL NOTIFY for %x pidl=%p\n", uCode, pidl);
         if(fodInfos->unicode)
         {
-            OFNOTIFYW ofnNotify;
-            ofnNotify.hdr.hwndFrom=hwndParentDlg;
-            ofnNotify.hdr.idFrom=0;
-            ofnNotify.hdr.code = uCode;
-            ofnNotify.lpOFN = fodInfos->ofnInfos;
-            ofnNotify.pszFile = NULL;
-            hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+            if(uCode == CDN_INCLUDEITEM)
+            {
+                OFNOTIFYEXW ofnNotify;
+                ofnNotify.psf = fodInfos->Shell.FOIShellFolder;
+                ofnNotify.pidl = (LPITEMIDLIST)pidl;
+                ofnNotify.hdr.hwndFrom = hwndParentDlg;
+                ofnNotify.hdr.idFrom = 0;
+                ofnNotify.hdr.code = uCode;
+                ofnNotify.lpOFN = fodInfos->ofnInfos;
+
+                hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+            }
+            else
+            {
+                OFNOTIFYW ofnNotify;
+                ofnNotify.pszFile = NULL;
+                ofnNotify.hdr.hwndFrom = hwndParentDlg;
+                ofnNotify.hdr.idFrom = 0;
+                ofnNotify.hdr.code = uCode;
+                ofnNotify.lpOFN = fodInfos->ofnInfos;
+
+                hook_result = SendMessageW(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+            }
         }
         else
         {
-            OFNOTIFYA ofnNotify;
-            ofnNotify.hdr.hwndFrom=hwndParentDlg;
-            ofnNotify.hdr.idFrom=0;
-            ofnNotify.hdr.code = uCode;
-            ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
-            ofnNotify.pszFile = NULL;
-            hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+            if(uCode == CDN_INCLUDEITEM)
+            {
+                OFNOTIFYEXA ofnNotify;
+                ofnNotify.psf = fodInfos->Shell.FOIShellFolder;
+                ofnNotify.pidl = (LPITEMIDLIST)pidl;
+                ofnNotify.hdr.hwndFrom = hwndParentDlg;
+                ofnNotify.hdr.idFrom = 0;
+                ofnNotify.hdr.code = uCode;
+                ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
+
+                hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+            }
+            else
+            {
+                OFNOTIFYA ofnNotify;
+                ofnNotify.pszFile = NULL;
+                ofnNotify.hdr.hwndFrom = hwndParentDlg;
+                ofnNotify.hdr.idFrom = 0;
+                ofnNotify.hdr.code = uCode;
+                ofnNotify.lpOFN = (LPOPENFILENAMEA)fodInfos->ofnInfos;
+
+                hook_result = SendMessageA(fodInfos->DlgInfos.hwndCustomDlg,WM_NOTIFY,0,(LPARAM)&ofnNotify);
+            }
         }
-	TRACE("RET NOTIFY\n");
     }
     TRACE("Retval: 0x%08lx\n", hook_result);
     return hook_result;
@@ -1008,9 +1038,9 @@ INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
          FILEDLG95_ResizeControls(hwnd, wParam, lParam);
       	 FILEDLG95_FillControls(hwnd, wParam, lParam);
 
-         SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE);
-         SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
-         SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE);
+         SendCustomDlgNotificationMessage(hwnd,CDN_INITDONE,NULL);
+         SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE,NULL);
+         SendCustomDlgNotificationMessage(hwnd,CDN_SELCHANGE,NULL);
          return 0;
        }
     case WM_COMMAND:
@@ -1597,7 +1627,7 @@ static BOOL FILEDLG95_SendFileOK( HWND hwnd, FileOpenDlgInfos *fodInfos )
 
         TRACE("---\n");
         /* First send CDN_FILEOK as MSDN doc says */
-        retval = SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK);
+        retval = SendCustomDlgNotificationMessage(hwnd,CDN_FILEOK,NULL);
         if (GetWindowLongPtrW(fodInfos->DlgInfos.hwndCustomDlg, DWLP_MSGRESULT))
         {
             TRACE("canceled\n");
@@ -1994,7 +2024,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
 	  {
             if (SUCCEEDED(IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidlCurrent, SBSP_ABSOLUTE)))
             {
-              SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
+              SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE, NULL);
             }
 	  }
 	  else if( nOpenAction == ONOPEN_SEARCH )
@@ -2295,7 +2325,7 @@ static BOOL FILEDLG95_SHELL_UpFolder(HWND hwnd)
                                           NULL,
                                           SBSP_PARENT)))
   {
-    SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
+    SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE, NULL);
     return TRUE;
   }
   return FALSE;
@@ -2317,7 +2347,7 @@ static BOOL FILEDLG95_SHELL_BrowseToDesktop(HWND hwnd)
 
   SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,&pidl);
   hres = IShellBrowser_BrowseObject(fodInfos->Shell.FOIShellBrowser, pidl, SBSP_ABSOLUTE);
-  SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
+  SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE, NULL);
   COMDLG32_SHFree(pidl);
   return SUCCEEDED(hres);
 }
@@ -2495,7 +2525,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
           len = lstrlenW(lpstrFilter)+1;
           fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) );
           lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
-          SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
+          SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE,NULL);
       }
 
       /* Refresh the actual view to display the included items*/
@@ -2797,7 +2827,7 @@ static BOOL FILEDLG95_LOOKIN_OnCommand(HWND hwnd, WORD wNotifyCode)
                                               tmpFolder->pidlItem,
                                               SBSP_ABSOLUTE)))
       {
-        SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE);
+        SendCustomDlgNotificationMessage(hwnd, CDN_FOLDERCHANGE, NULL);
         return TRUE;
       }
       break;
@@ -3471,7 +3501,7 @@ static BOOL BrowseSelectedFolder(HWND hwnd)
                MessageBoxW( hwnd, notexist, fodInfos->title, MB_OK | MB_ICONEXCLAMATION );
           }
           bBrowseSelFolder = TRUE;
-          SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE);
+          SendCustomDlgNotificationMessage(hwnd,CDN_FOLDERCHANGE,NULL);
       }
       COMDLG32_SHFree( pidlSelection );
   }
diff --git a/dlls/comdlg32/filedlgbrowser.c b/dlls/comdlg32/filedlgbrowser.c
index 704fb98..d3c23dc 100644
--- a/dlls/comdlg32/filedlgbrowser.c
+++ b/dlls/comdlg32/filedlgbrowser.c
@@ -785,7 +785,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(ICommDl
 	if (ulAttr & (SFGAO_FOLDER | SFGAO_HASSUBFOLDER) )
 	{
           hRes = IShellBrowser_BrowseObject((IShellBrowser *)This,pidl,SBSP_RELATIVE);
-          SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE);
+          SendCustomDlgNotificationMessage(This->hwndOwner, CDN_FOLDERCHANGE, NULL);
 	}
         else
 	{
@@ -875,6 +875,11 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBr
     if(ulAttr & (SFGAO_FOLDER | SFGAO_LINK))
         return S_OK;
 
+    /* if the application takes care of including the item we are done */
+    if(fodInfos->ofnInfos->Flags & OFN_ENABLEINCLUDENOTIFY &&
+    SendCustomDlgNotificationMessage(This->hwndOwner, CDN_INCLUDEITEM, pidl))
+        return S_OK;
+
     /* Check if there is a mask to apply if not */
     if(!fodInfos->ShellInfos.lpstrCurrentFilter || !lstrlenW(fodInfos->ShellInfos.lpstrCurrentFilter))
         return S_OK;
@@ -884,7 +889,7 @@ static HRESULT WINAPI IShellBrowserImpl_ICommDlgBrowser_IncludeObject(ICommDlgBr
       if (COMDLG32_StrRetToStrNW(szPathW, MAX_PATH, &str, pidl))
       {
 	  if (PathMatchSpecW(szPathW, fodInfos->ShellInfos.lpstrCurrentFilter))
-          return S_OK;
+              return S_OK;
       }
     }
     return S_FALSE;
@@ -914,7 +919,7 @@ static HRESULT IShellBrowserImpl_ICommDlgBrowser_OnSelChange(ICommDlgBrowser *if
 
     FILEDLG95_FILENAME_FillFromSelection(This->hwndOwner);
 
-    SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE);
+    SendCustomDlgNotificationMessage(This->hwndOwner, CDN_SELCHANGE, NULL);
     return S_OK;
 }
 
diff --git a/dlls/comdlg32/filedlgbrowser.h b/dlls/comdlg32/filedlgbrowser.h
index f8da75e..76dfcf2 100644
--- a/dlls/comdlg32/filedlgbrowser.h
+++ b/dlls/comdlg32/filedlgbrowser.h
@@ -161,6 +161,6 @@ extern IShellFolder*    GetShellFolderFromPidl(LPITEMIDLIST pidlAbs);
 extern LPITEMIDLIST     GetParentPidl(LPITEMIDLIST pidl);
 
 extern int     FILEDLG95_LOOKIN_SelectItem(HWND hwnd,LPITEMIDLIST pidl);
-extern LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode);
+extern LRESULT SendCustomDlgNotificationMessage(HWND hwndParentDlg, UINT uCode, LPCITEMIDLIST pidl);
 
 #endif /*SHBROWSER_H*/
-- 
1.5.6.3


More information about the wine-patches mailing list