From: rklazes@casema.net (Rein Klazes)
Newsgroups: local.list.wine.patches
Subject: 16 bits dialog patch.
Date: 16 Nov 1999 19:31:16 +0100
Organization: -++-
Lines: 232
Message-ID: <199911161137.EAA11876@ursula.gmcl.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="--=_6UExOKVVL1eFPpiMs=Y5SwSVvDwS.MFSBCHJLHS"
X-Resent-Date: Tue, 16 Nov 1999 04:37:34 -0700
X-To: wine-patches@winehq.com
X-Mailer: Forte Agent 1.6/32.525
X-Resent-Message-ID: <ELvLED.A.u5C.-HUM4@ursula.gmcl.com>
X-Resent-From: wine-patches@winehq.com
X-Reply-To: wine-devel@winehq.com
X-Mailing-List: <wine-patches@winehq.com> archive/latest/2131
X-Loop: wine-patches@winehq.com
X-Precedence: list
X-Resent-Sender: wine-patches-request@winehq.com


----=_6UExOKVVL1eFPpiMs=Y5SwSVvDwS.MFSBCHJLHS
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I have an application here that has stopped working since the
introduction of 32 bit message queues.

The application breaks when it posts a WM_COMMAND message using
PostMessage16. 

The message is received by a  GetMessage and dispatched by
DispatchMessageA in DIALOG_DoDialogBox(). However these are win32
functions and when calling the 16 bit dialogproc, a message
translation 32->16 bits is done which messes up the parameters.

The patch corrects this in a trivial way by adding a parameter to
DIALOG_DoDialogBox() that flags whether 16 bits functions should be
used. 

If there is a better way do fix this problem then let me know.

Files:
./include/dialog.h
./windows/dialog.c
./dlls/commdlg/colordlg.c
./dlls/commdlg/filedlg.c
./dlls/commdlg/fontdlg.c
./dlls/commdlg/printdlg.c

Changelog:
Correct handling of 16 bits messages in DIALOG_DoDialogBox()

Rein.
-- 
Rein Klazes
rklazes@casema.net

----=_6UExOKVVL1eFPpiMs=Y5SwSVvDwS.MFSBCHJLHS
Content-Type: text/plain; charset=us-ascii; name=dlg16.diff
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=dlg16.diff

Index: include/dialog.h
--- ./wine/./include/dialog.h	Sun Apr 25 14:36:53 1999
+++ ./mywine/./include/dialog.h	Tue Nov 16 11:49:40 1999
@@ -43,6 +43,6 @@
                                      BOOL win32Template, HWND owner,
                                      DLGPROC16 dlgProc, LPARAM param,
                                      WINDOWPROCTYPE procType );
-extern INT DIALOG_DoDialogBox( HWND hwnd, HWND owner );
+extern INT DIALOG_DoDialogBox( HWND hwnd, HWND owner, BOOL iswin16);
 
 #endif  /* __WINE_DIALOG_H */
Index: windows/dialog.c
--- ./wine/./windows/dialog.c	Sun Nov  7 22:02:17 1999
+++ ./mywine/./windows/dialog.c	Tue Nov 16 11:50:43 1999
@@ -22,6 +22,7 @@
 #include "winproc.h"
 #include "message.h"
 #include "debugtools.h"
+#include "struct32.h"
 
 DEFAULT_DEBUG_CHANNEL(dialog)
 
@@ -929,7 +930,7 @@
 /***********************************************************************
  *           DIALOG_DoDialogBox
  */
-INT DIALOG_DoDialogBox( HWND hwnd, HWND owner )
+INT DIALOG_DoDialogBox( HWND hwnd, HWND owner, BOOL iswin16 )
 {
     WND * wndPtr;
     DIALOGINFO * dlgInfo;
@@ -948,11 +949,24 @@
         while (MSG_InternalGetMessage(&msg, hwnd, owner, MSGF_DIALOGBOX, 
                                       PM_REMOVE, !(wndPtr->dwStyle & DS_NOIDLEMSG), NULL ))
         {
-            if (!IsDialogMessageA( hwnd, &msg))
+            if(iswin16)
             {
-                TranslateMessage( &msg );
-                DispatchMessageA( &msg );
+                MSG16 msg16;
+                
+                STRUCT32_MSG32to16( &msg, &msg16 );
+
+                if (!IsDialogMessage16( hwnd, &msg16))
+                {
+                    TranslateMessage16( &msg16 );
+                    DispatchMessage16( &msg16 );
+                }
             }
+            else
+                if (!IsDialogMessageA( hwnd, &msg))
+                {
+                    TranslateMessage( &msg );
+                    DispatchMessageA( &msg );
+                }
             if (dlgInfo->flags & DF_END) break;
         }
         EnableWindow( owner, TRUE );
@@ -981,7 +995,7 @@
                                HWND16 owner, DLGPROC16 dlgProc, LPARAM param )
 {
     HWND16 hwnd = CreateDialogParam16( hInst, template, owner, dlgProc, param);
-    if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
+    if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner, TRUE );
     return -1;
 }
 
@@ -993,7 +1007,7 @@
                                 HWND owner, DLGPROC dlgProc, LPARAM param )
 {
     HWND hwnd = CreateDialogParamA( hInst, name, owner, dlgProc, param );
-    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
+    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner , FALSE);
     return -1;
 }
 
@@ -1005,7 +1019,7 @@
                                 HWND owner, DLGPROC dlgProc, LPARAM param )
 {
     HWND hwnd = CreateDialogParamW( hInst, name, owner, dlgProc, param );
-    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
+    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner, FALSE);
     return -1;
 }
 
@@ -1033,7 +1047,7 @@
     if (!(ptr = GlobalLock16( dlgTemplate ))) return -1;
     hwnd = CreateDialogIndirectParam16( hInst, ptr, owner, dlgProc, param );
     GlobalUnlock16( dlgTemplate );
-    if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner );
+    if (hwnd) return (INT16)DIALOG_DoDialogBox( hwnd, owner, TRUE );
     return -1;
 }
 
@@ -1047,7 +1061,7 @@
 {
     HWND hwnd = CreateDialogIndirectParamA( hInstance, template,
                                                 owner, dlgProc, param );
-    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
+    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner, FALSE );
     return -1;
 }
 
@@ -1061,7 +1075,7 @@
 {
     HWND hwnd = CreateDialogIndirectParamW( hInstance, template,
                                                 owner, dlgProc, param );
-    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner );
+    if (hwnd) return DIALOG_DoDialogBox( hwnd, owner, FALSE );
     return -1;
 }
 
Index: dlls/commdlg/colordlg.c
--- ./wine/./dlls/commdlg/colordlg.c	Sat Jul 24 12:27:58 1999
+++ ./mywine/./dlls/commdlg/colordlg.c	Tue Nov 16 10:18:12 1999
@@ -108,7 +108,8 @@
                                         lpChCol->hwndOwner,
                                         (DLGPROC16)ColorDlgProc,
                                         (DWORD)lpChCol, WIN_PROC_32A );
-    if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpChCol->hwndOwner);
+    if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpChCol->hwndOwner,
+            TRUE);
     if (hDlgTmpl) FreeResource16( hDlgTmpl );
 
     return bRet;
Index: dlls/commdlg/filedlg.c
--- ./wine/./dlls/commdlg/filedlg.c	Wed Oct 13 15:51:57 1999
+++ ./mywine/./dlls/commdlg/filedlg.c	Tue Nov 16 10:21:52 1999
@@ -251,7 +251,7 @@
                                         lpofn->hwndOwner,
                                         (DLGPROC16)FileOpenDlgProc,
                                         ofn, WIN_PROC_32A );
-    if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
+    if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner, TRUE );
 
     if (str1)
       {
@@ -413,7 +413,7 @@
                                         lpofn->hwndOwner,
                                         (DLGPROC16)FileSaveDlgProc,
                                         ofn, WIN_PROC_32A );
-    if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
+    if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner, TRUE );
 
     if (str1)
       {
Index: dlls/commdlg/fontdlg.c
--- ./wine/./dlls/commdlg/fontdlg.c	Sat Jul 24 12:27:58 1999
+++ ./mywine/./dlls/commdlg/fontdlg.c	Tue Nov 16 10:23:04 1999
@@ -124,7 +124,7 @@
                                         lpChFont->hwndOwner,
                                         (DLGPROC16)FormatCharDlgProcA,
                                         (DWORD)lpChFont, WIN_PROC_32A );
-    if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
+    if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner, TRUE);
     if (hDlgTmpl) FreeResource16( hDlgTmpl );
     lpChFont->lpTemplateName=lpTemplateName;
     FONT_LogFont32ATo16(cf32a.lpLogFont, 
@@ -160,7 +160,7 @@
     CF_ENABLETEMPLATEHANDLE)) FIXME(": unimplemented flag (ignored)\n");
   hwndDialog = DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
             (DLGPROC16)FormatCharDlgProcA, (LPARAM)lpChFont, WIN_PROC_32A );
-  if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);  
+  if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner, TRUE);  
   return bRet;
 }
 
@@ -199,7 +199,7 @@
   lpChFont->lpTemplateName=(LPWSTR)&cf32a;
   hwndDialog=DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
             (DLGPROC16)FormatCharDlgProcW, (LPARAM)lpChFont, WIN_PROC_32W );
-  if (hwndDialog)bRet=DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);  
+  if (hwndDialog)bRet=DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner, TRUE);  
   HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
   lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
   memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONTA));
Index: dlls/commdlg/printdlg.c
--- ./wine/./dlls/commdlg/printdlg.c	Sun Nov 14 08:08:30 1999
+++ ./mywine/./dlls/commdlg/printdlg.c	Tue Nov 16 10:23:35 1999
@@ -288,7 +288,7 @@
             (DLGPROC16)PrintDlgProcA, (LPARAM)&PrintStructures, WIN_PROC_32A );
         }
     if (hwndDialog) 
-        bRet = DIALOG_DoDialogBox(hwndDialog, lppd->hwndOwner);  
+        bRet = DIALOG_DoDialogBox(hwndDialog, lppd->hwndOwner, TRUE);  
      
     /* free memory & resources
      */   

----=_6UExOKVVL1eFPpiMs=Y5SwSVvDwS.MFSBCHJLHS--

---
