[COMDLG32] Sync with Wine 3.0. CORE-14225
authorAmine Khaldi <amine.khaldi@reactos.org>
Thu, 18 Jan 2018 22:52:46 +0000 (23:52 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Thu, 18 Jan 2018 22:52:46 +0000 (23:52 +0100)
dll/win32/comdlg32/filedlg.c
dll/win32/comdlg32/fontdlg.c
media/doc/README.WINE

index b3b40e6..457ee9b 100644 (file)
@@ -442,23 +442,6 @@ static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
         ret = FALSE;
     }
 
-    /* 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);
-        }
-    }
-
     if (current_dir)
     {
         SetCurrentDirectoryW(current_dir);
@@ -2677,6 +2660,23 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
               fodInfos->ofnInfos->nFileExtension = (*lpszTemp) ? (lpszTemp - tempFileA) + 1 : 0;
           }
 
+          /* set the lpstrFileTitle */
+          if(fodInfos->ofnInfos->lpstrFileTitle)
+         {
+            LPWSTR lpstrFileTitle = PathFindFileNameW(lpstrPathAndFile);
+            if(fodInfos->unicode)
+            {
+              LPOPENFILENAMEW ofn = fodInfos->ofnInfos;
+             lstrcpynW(ofn->lpstrFileTitle, lpstrFileTitle, ofn->nMaxFileTitle);
+            }
+            else
+            {
+              LPOPENFILENAMEA ofn = (LPOPENFILENAMEA)fodInfos->ofnInfos;
+              WideCharToMultiByte(CP_ACP, 0, lpstrFileTitle, -1,
+                    ofn->lpstrFileTitle, ofn->nMaxFileTitle, NULL, NULL);
+            }
+         }
+
           /* copy currently selected filter to lpstrCustomFilter */
           if (fodInfos->ofnInfos->lpstrCustomFilter)
           {
index 6cc8c89..d4c90df 100644 (file)
@@ -923,14 +923,37 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO
     int i;
     long l;
     HDC hdc;
+    BOOL cmb_selected_by_edit = FALSE;
 
     if (!lpcf) return FALSE;
 
+    if(HIWORD(wParam) == CBN_EDITCHANGE)
+    {
+        int idx;
+        WCHAR str_edit[256], str_cmb[256];
+        int cmb = LOWORD(wParam);
+
+        GetDlgItemTextW(hDlg, cmb, str_edit, sizeof(str_edit) / sizeof(str_edit[0]));
+        idx = SendDlgItemMessageW(hDlg, cmb, CB_FINDSTRING, -1, (LPARAM)str_edit);
+        if(idx != -1)
+        {
+            SendDlgItemMessageW(hDlg, cmb, CB_GETLBTEXT, idx, (LPARAM)str_cmb);
+
+            /* Select listbox entry only if we have an exact match */
+            if(lstrcmpiW(str_edit, str_cmb) == 0)
+            {
+                 SendDlgItemMessageW(hDlg, cmb, CB_SETCURSEL, idx, 0);
+                 SendDlgItemMessageW(hDlg, cmb, CB_SETEDITSEL, 0, -1); /* Remove edit field selection */
+                 cmb_selected_by_edit = TRUE;
+            }
+        }
+    }
+
     TRACE("WM_COMMAND wParam=%08X lParam=%08lX\n", (LONG)wParam, lParam);
     switch (LOWORD(wParam))
     {
     case cmb1:
-        if (HIWORD(wParam)==CBN_SELCHANGE)
+        if (HIWORD(wParam) == CBN_SELCHANGE || cmb_selected_by_edit)
         {
             INT pointsize; /* save current pointsize */
             LONG pstyle;  /* save current style */
@@ -981,7 +1004,7 @@ static LRESULT CFn_WMCommand(HWND hDlg, WPARAM wParam, LPARAM lParam, LPCHOOSEFO
     case cmb2:
     case cmb3:
     case cmb5:
-        if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
+        if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == BN_CLICKED || cmb_selected_by_edit)
         {
             WCHAR str[256];
             WINDOWINFO wininfo;
index 270a296..2de694b 100644 (file)
@@ -55,7 +55,7 @@ reactos/dll/win32/cabinet             # Synced to WineStaging-2.9
 reactos/dll/win32/clusapi             # Synced to WineStaging-2.9
 reactos/dll/win32/comcat              # Synced to WineStaging-2.9
 reactos/dll/win32/comctl32            # Synced to Wine-3.0
-reactos/dll/win32/comdlg32            # Synced to WineStaging-2.16
+reactos/dll/win32/comdlg32            # Synced to Wine-3.0
 reactos/dll/win32/compstui            # Synced to WineStaging-2.9
 reactos/dll/win32/credui              # Synced to WineStaging-2.9
 reactos/dll/win32/crypt32             # Synced to WineStaging-2.16