Release 960902

Sun Sep  1 19:22:46 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [misc/commdlg.c] [if1632/commdlg.spec]
	Fixed some SEGPTR problems.

	* [windows/winproc.c]
	Added message translation for WM_COMPAREITEM, WM_DELETEITEM
	and WM_MEASUREITEM
	Fixed 16-to-32 translation for WM_HSCROLL/WM_VSCROLL.

Fri Aug 30 13:39:00 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
	* [files/drive.c]
	GetDriveType16 should report CDROMs as DRIVE_REMOTE (ACME setup).

	* [multimedia/audio.c]
	The minimum audiobuffer size shrunk somewhere in linux 1.3.xx
	below 4096 bytes.

	* [multimedia/mcistring.c]
	Segptr string handling fixed & enhanced.

	* [if1632/crtdll.spec][misc/crtdll.c]
	malloc,free,_strupr,_stricmp,_strcmpi added.

	* [if1632/wsock32.spec][misc/winsock.c]
	More direct thunks into unix libc and WsControl-stub added.

Thu Aug 29 23:54:25 1996  Huw D. M. Davies <h.davies1@physics.oxford.ac.uk>

	* [objects/metafile.c]
	Bug fixes to both recording and playback of ExtTextOut().

Tue Aug 27 15:43:21 1996  Slaven Rezic  <eserte@cs.tu-berlin.de>

	* [multimedia/audio.c] [multimedia/mcianim.c]
	  [multimedia/mcicda.c] [multimedia/midi.c]
	Made cdaudio, audio and midi work for FreeBSD.

Sun Aug 25 20:18:56 1996  Jukka Iivonen <iivonen@cc.helsinki.fi>

	* [misc/crtdll.c] [if1632/crtdll.spec]
	Added a lot of functions.

	* [misc/ole2nls.c]
	Added ID values for all languages in GetUserDefaultLCID().
	
Fri Aug 24 21:02:28 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [windows/event.c] [windows/message.c]
	First attempt at hook WH_JOURNALPLAYBACK.
diff --git a/windows/defwnd.c b/windows/defwnd.c
index f67c44c..b79fa4b 100644
--- a/windows/defwnd.c
+++ b/windows/defwnd.c
@@ -186,7 +186,7 @@
 	    {
 		 if( wndPtr->flags & WIN_NCACTIVATED )
 		 {
-		   FillWindow( GetParent(wndPtr->hwndSelf), wndPtr->hwndSelf,
+		   FillWindow( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf,
                                (HDC)wParam, sysColorObjects.hbrushActiveCaption );
 		   return 1;
 		 }
@@ -199,11 +199,11 @@
             {
                 HBRUSH hbrush = CreateSolidBrush( 
 			        GetSysColor(((DWORD)wndPtr->class->hbrBackground)-1));
-                 FillWindow( GetParent(wndPtr->hwndSelf), wndPtr->hwndSelf,
+                 FillWindow( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf,
                              (HDC)wParam, hbrush);
                  DeleteObject (hbrush);
             }
-            else FillWindow( GetParent(wndPtr->hwndSelf), wndPtr->hwndSelf,
+            else FillWindow( GetParent16(wndPtr->hwndSelf), wndPtr->hwndSelf,
                                   (HDC)wParam, wndPtr->class->hbrBackground );
 	    return 1;
 	}
diff --git a/windows/event.c b/windows/event.c
index c59b378..fb32363 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -174,15 +174,18 @@
     {
     case KeyPress:
     case KeyRelease:
-	EVENT_key( (XKeyEvent*)event );
+        if (!HOOK_GetHook(WH_JOURNALPLAYBACK, 0) )
+            EVENT_key( (XKeyEvent*)event );
 	break;
 	
     case ButtonPress:
-	EVENT_ButtonPress( (XButtonEvent*)event );
+        if (!HOOK_GetHook(WH_JOURNALPLAYBACK, 0) )
+            EVENT_ButtonPress( (XButtonEvent*)event );
 	break;
 
     case ButtonRelease:
-	EVENT_ButtonRelease( (XButtonEvent*)event );
+        if (!HOOK_GetHook(WH_JOURNALPLAYBACK, 0) )
+            EVENT_ButtonRelease( (XButtonEvent*)event );
 	break;
 
     case MotionNotify:
@@ -194,9 +197,12 @@
 	   problems if the event order is important. I'm not yet seen
 	   of any problems. Jon 7/6/96.
 	 */
-        while (XCheckTypedWindowEvent(display, ((XAnyEvent *)event)->window,
-			  MotionNotify, event));    
-	EVENT_MotionNotify( (XMotionEvent*)event );
+	if (!HOOK_GetHook(WH_JOURNALPLAYBACK, 0) )
+	{
+            while (XCheckTypedWindowEvent(display,((XAnyEvent *)event)->window,
+                                          MotionNotify, event));    
+            EVENT_MotionNotify( (XMotionEvent*)event );
+	}
 	break;
 
     case FocusIn:
diff --git a/windows/mdi.c b/windows/mdi.c
index 96307bf..9dc0890 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -227,7 +227,7 @@
 
     if (!fRefresh) 
        {
-	HWND hwndFrame = GetParent(hwnd);
+	HWND hwndFrame = GetParent16(hwnd);
 	HMENU oldFrameMenu = GetMenu(hwndFrame);
         
 	if( ci->hwndChildMaximized && hmenuFrame && hmenuFrame!=oldFrameMenu )
@@ -504,7 +504,7 @@
 
         if (flagDestroy)
 	   {
-	     MDI_PostUpdate(GetParent(child), ci, SB_BOTH+1);
+	     MDI_PostUpdate(GetParent16(child), ci, SB_BOTH+1);
             DestroyWindow(child);
 	   }
     }
@@ -1329,7 +1329,7 @@
     MDICLIENTINFO       *ci;
     WND                 *clientWnd;
 
-    clientWnd  = WIN_FindWndPtr(GetParent(hwnd));
+    clientWnd  = WIN_FindWndPtr(GetParent16(hwnd));
     ci         = (MDICLIENTINFO *) clientWnd->wExtra;
 
     switch (message)
@@ -1471,7 +1471,7 @@
     MDICLIENTINFO       *ci;
     WND                 *clientWnd;
 
-    clientWnd  = WIN_FindWndPtr(GetParent(hwnd));
+    clientWnd  = WIN_FindWndPtr(GetParent16(hwnd));
     ci         = (MDICLIENTINFO *) clientWnd->wExtra;
 
     switch (message)
@@ -1523,7 +1523,7 @@
     MDICLIENTINFO       *ci;
     WND                 *clientWnd;
 
-    clientWnd  = WIN_FindWndPtr(GetParent(hwnd));
+    clientWnd  = WIN_FindWndPtr(GetParent16(hwnd));
     ci         = (MDICLIENTINFO *) clientWnd->wExtra;
 
     switch (message)
diff --git a/windows/message.c b/windows/message.c
index 4624478..b61ecb3 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -6,6 +6,7 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include <sys/time.h>
 #include <sys/types.h>
 
@@ -31,8 +32,13 @@
 #define HWND_BROADCAST16  ((HWND16)0xffff)
 #define HWND_BROADCAST32  ((HWND32)0xffffffff)
 
-extern BYTE* 	KeyStateTable;				 /* event.c */
+#define ASCII_CHAR_HACK 0x0800 
+
 extern WPARAM	lastEventChar;				 /* event.c */
+extern BOOL MouseButtonsStates[3];
+extern BOOL AsyncMouseButtonsStates[3];
+extern BYTE KeyStateTable[256];
+extern BYTE AsyncKeyStateTable[256];
 
 DWORD MSG_WineStartTicks; /* Ticks at Wine startup */
 
@@ -263,8 +269,8 @@
         HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0,
                         (LPARAM)SEGPTR_GET(event) );
     }
-    else if ((msg->message >= WM_NCMOUSEMOVE) &&
-             (msg->message <= WM_NCMBUTTONDBLCLK))
+    else if ((msg->message >= WM_NCMOUSEFIRST) &&
+             (msg->message <= WM_NCMOUSELAST))
     {
         event->paramL = LOWORD(msg->lParam);       /* X pos */
         event->paramH = HIWORD(msg->lParam);       /* Y pos */ 
@@ -275,6 +281,108 @@
     SEGPTR_FREE(event);
 }
 
+/*****************************************************************
+ *              MSG_JournalPlayBackIsAscii
+ */
+static BOOL MSG_JournalPlayBackIsAscii(WPARAM wParam)
+{
+ return ((wParam>VK_HELP && wParam<VK_F1) || 
+          wParam == VK_SPACE  ||
+          wParam == VK_ESCAPE ||
+          wParam == VK_RETURN ||
+          wParam == VK_TAB    ||
+          wParam == VK_BACK);   
+}
+
+
+/***********************************************************************
+ *          MSG_JournalPlayBackMsg
+ *
+ * Get an EVENTMSG struct via call JOURNALPAYBACK hook function 
+ */
+static int MSG_JournalPlayBackMsg(void)
+{
+ EVENTMSG16 *tmpMsg;
+ long wtime,lParam;
+ WORD keyDown,i,wParam,result=0;
+
+ if ( HOOK_GetHook(WH_JOURNALPLAYBACK, 0) )
+ {
+  tmpMsg = SEGPTR_NEW(EVENTMSG16);
+  wtime=HOOK_CallHooks( WH_JOURNALPLAYBACK, HC_GETNEXT, 0, (LPARAM)SEGPTR_GET(tmpMsg));
+  /*  dprintf_msg(stddeb,"Playback wait time =%ld\n",wtime); */
+  if (wtime<=0)
+  {
+   wtime=0;
+   if ((tmpMsg->message>= WM_KEYFIRST) && (tmpMsg->message <= WM_KEYLAST))
+   {
+     wParam=tmpMsg->paramL & 0xFF;
+     lParam=MAKELONG(tmpMsg->paramH&0x7ffff,tmpMsg->paramL>>8);
+     if (tmpMsg->message == WM_KEYDOWN || tmpMsg->message == WM_SYSKEYDOWN)
+     {
+       for (keyDown=i=0; i<256 && !keyDown; i++)
+          if (KeyStateTable[i] & 0x80)
+            keyDown++;
+       if (!keyDown)
+         lParam |= 0x40000000;       
+       AsyncKeyStateTable[wParam]=KeyStateTable[wParam] |= 0x80;
+       if (MSG_JournalPlayBackIsAscii(wParam))
+       {
+         lastEventChar= wParam;         /* control TranslateMessage() */
+         lParam |= (LONG)((LONG)ASCII_CHAR_HACK*0x10000L);
+
+         if (!(KeyStateTable[VK_SHIFT] & 0x80) &&
+             !(KeyStateTable[VK_CAPITAL] & 0x80))
+           lastEventChar= tolower(lastEventChar);
+         if (KeyStateTable[VK_CONTROL] & 0x80)
+           lastEventChar&=0x1f;
+       }  
+     }  
+     else                                       /* WM_KEYUP, WM_SYSKEYUP */
+     {
+       lParam |= 0xC0000000;      
+       AsyncKeyStateTable[wParam]=KeyStateTable[wParam] &= ~0x80;
+     }
+     if (KeyStateTable[VK_MENU] & 0x80)
+       lParam |= 0x20000000;     
+     if (tmpMsg->paramH & 0x8000)              /*special_key bit*/
+       lParam |= 0x01000000;
+     hardware_event( tmpMsg->message, wParam, lParam,0, 0, tmpMsg->time, 0 );     
+   }
+   else
+   {
+    if ((tmpMsg->message>= WM_MOUSEFIRST) && (tmpMsg->message <= WM_MOUSELAST))
+    {
+     switch (tmpMsg->message)
+     {
+      case WM_LBUTTONDOWN:MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=1;break;
+      case WM_LBUTTONUP:  MouseButtonsStates[0]=AsyncMouseButtonsStates[0]=0;break;
+      case WM_MBUTTONDOWN:MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=1;break;
+      case WM_MBUTTONUP:  MouseButtonsStates[1]=AsyncMouseButtonsStates[1]=0;break;
+      case WM_RBUTTONDOWN:MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=1;break;
+      case WM_RBUTTONUP:  MouseButtonsStates[2]=AsyncMouseButtonsStates[2]=0;break;      
+     }
+     AsyncKeyStateTable[VK_LBUTTON]= KeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] << 8;
+     AsyncKeyStateTable[VK_MBUTTON]= KeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] << 8;
+     AsyncKeyStateTable[VK_RBUTTON]= KeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] << 8;
+     SetCursorPos(tmpMsg->paramL,tmpMsg->paramH);
+     lParam=MAKELONG(tmpMsg->paramL,tmpMsg->paramH);
+     wParam=0;             
+     if (MouseButtonsStates[0]) wParam |= MK_LBUTTON;
+     if (MouseButtonsStates[1]) wParam |= MK_MBUTTON;
+     if (MouseButtonsStates[2]) wParam |= MK_RBUTTON;
+     hardware_event( tmpMsg->message, wParam, lParam,  
+                     tmpMsg->paramL, tmpMsg->paramH, tmpMsg->time, 0 );
+    }
+   }
+   HOOK_CallHooks( WH_JOURNALPLAYBACK, HC_SKIP, 0, (LPARAM)SEGPTR_GET(tmpMsg));
+  }
+  else
+    result= QS_MOUSE | QS_KEY;
+  SEGPTR_FREE(tmpMsg);
+ }
+ return result;
+} 
 
 /***********************************************************************
  *           MSG_PeekHardwareMsg
@@ -490,6 +598,8 @@
             break;
         }
 
+        msgQueue->changeBits |= MSG_JournalPlayBackMsg();
+
         /* Now find a hardware event */
 
         if (((msgQueue->wakeBits & mask) & (QS_MOUSE | QS_KEY)) &&
@@ -909,7 +1019,6 @@
  * This should call ToAscii but it is currently broken
  */
 
-#define ASCII_CHAR_HACK 0x0800
 
 BOOL TranslateMessage( LPMSG16 msg )
 {
diff --git a/windows/painting.c b/windows/painting.c
index 40f5dff..c1b3d09 100644
--- a/windows/painting.c
+++ b/windows/painting.c
@@ -219,7 +219,7 @@
  */
 HBRUSH GetControlBrush( HWND hwnd, HDC hdc, WORD control )
 {
-    return (HBRUSH)SendMessage32A( GetParent(hwnd), WM_CTLCOLOR+control,
+    return (HBRUSH)SendMessage32A( GetParent32(hwnd), WM_CTLCOLOR+control,
                                    (WPARAM)hdc, (LPARAM)hwnd );
 }
 
diff --git a/windows/syscolor.c b/windows/syscolor.c
index 3c3ddee..11f1ccd 100644
--- a/windows/syscolor.c
+++ b/windows/syscolor.c
@@ -145,10 +145,10 @@
 
 
 /*************************************************************************
- *             GetSysColor           (USER.180)
+ *             GetSysColor   (USER.180) (USER32.288)
  */
 
-COLORREF GetSysColor(short nIndex)
+COLORREF GetSysColor( INT32 nIndex )
 {
     dprintf_syscolor(stddeb,"System Color %d = %8lx\n", 
 		    nIndex, SysColors[nIndex]);
diff --git a/windows/win.c b/windows/win.c
index cbca5aa..626b35f 100644
--- a/windows/win.c
+++ b/windows/win.c
@@ -1473,9 +1473,18 @@
 
 
 /*****************************************************************
- *         GetParent              (USER.46)
+ *         GetParent16   (USER.46)
  */
-HWND GetParent(HWND hwnd)
+HWND16 GetParent16( HWND16 hwnd )
+{
+    return (HWND16)GetParent32( hwnd );
+}
+
+
+/*****************************************************************
+ *         GetParent32   (USER32.277)
+ */
+HWND32 GetParent32( HWND32 hwnd )
 {
     WND *wndPtr = WIN_FindWndPtr(hwnd);
     if (!wndPtr) return 0;
diff --git a/windows/winpos.c b/windows/winpos.c
index cfbb72e..ba64e4e 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -1832,7 +1832,7 @@
         }
 
         if ((winpos->hwnd == GetFocus()) || IsChild(winpos->hwnd, GetFocus()))
-            SetFocus( GetParent(winpos->hwnd) );  /* Revert focus to parent */
+            SetFocus( GetParent32(winpos->hwnd) ); /* Revert focus to parent */
 
 	if (winpos->hwnd == hwndActive)
 	{
diff --git a/windows/winproc.c b/windows/winproc.c
index d1c89d7..8f2cc95 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -390,11 +390,8 @@
         }
         return 1;
     case WM_ASKCBFORMATNAME:
-    case WM_COMPAREITEM:
-    case WM_DELETEITEM:
     case WM_DEVMODECHANGE:
     case WM_MDIACTIVATE:
-    case WM_MEASUREITEM:
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
     case WM_WININICHANGE:
@@ -497,11 +494,8 @@
         }
         return 1;
     case WM_ASKCBFORMATNAME:
-    case WM_COMPAREITEM:
-    case WM_DELETEITEM:
     case WM_DEVMODECHANGE:
     case WM_MDIACTIVATE:
-    case WM_MEASUREITEM:
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
     case WM_WININICHANGE:
@@ -570,17 +564,67 @@
     case WM_ACTIVATE:
     case WM_CHARTOITEM:
     case WM_COMMAND:
-    case WM_HSCROLL:
     case WM_VKEYTOITEM:
-    case WM_VSCROLL:
         *pwparam32 = MAKEWPARAM( wParam16, HIWORD(*plparam) );
         *plparam   = (LPARAM)(HWND32)LOWORD(*plparam);
         return 0;
+    case WM_HSCROLL:
+    case WM_VSCROLL:
+        *pwparam32 = MAKEWPARAM( wParam16, LOWORD(*plparam) );
+        *plparam   = (LPARAM)(HWND32)HIWORD(*plparam);
+        return 0;
     case WM_CTLCOLOR:
         *pmsg32    = WM_CTLCOLORMSGBOX + HIWORD(*plparam);
         *pwparam32 = (WPARAM32)(HDC32)wParam16;
         *plparam   = (LPARAM)(HWND32)LOWORD(*plparam);
         return 0;
+    case WM_COMPAREITEM:
+        {
+            COMPAREITEMSTRUCT16* cis16 = (COMPAREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
+            COMPAREITEMSTRUCT32 *cis = (COMPAREITEMSTRUCT32 *)
+                                        HeapAlloc(SystemHeap, 0, sizeof(*cis));
+            if (!cis) return -1;
+            cis->CtlType    = cis16->CtlType;
+            cis->CtlID      = cis16->CtlID;
+            cis->hwndItem   = cis16->hwndItem;
+            cis->itemID1    = cis16->itemID1;
+            cis->itemData1  = cis16->itemData1;
+            cis->itemID2    = cis16->itemID2;
+            cis->itemData2  = cis16->itemData2;
+            cis->dwLocaleId = 0;  /* FIXME */
+            *plparam = (LPARAM)cis;
+        }
+        return 1;
+    case WM_DELETEITEM:
+        {
+            DELETEITEMSTRUCT16* dis16 = (DELETEITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
+            DELETEITEMSTRUCT32 *dis = (DELETEITEMSTRUCT32 *)
+                                        HeapAlloc(SystemHeap, 0, sizeof(*dis));
+            if (!dis) return -1;
+            dis->CtlType  = dis16->CtlType;
+            dis->CtlID    = dis16->CtlID;
+            dis->hwndItem = dis16->hwndItem;
+            dis->itemData = dis16->itemData;
+            *plparam = (LPARAM)dis;
+        }
+        return 1;
+    case WM_MEASUREITEM:
+        {
+            MEASUREITEMSTRUCT16* mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
+            MEASUREITEMSTRUCT32 *mis = (MEASUREITEMSTRUCT32 *)
+                                        HeapAlloc(SystemHeap, 0,
+                                                sizeof(*mis) + sizeof(LPARAM));
+            if (!mis) return -1;
+            mis->CtlType    = mis16->CtlType;
+            mis->CtlID      = mis16->CtlID;
+            mis->itemID     = mis16->itemID;
+            mis->itemWidth  = mis16->itemWidth;
+            mis->itemHeight = mis16->itemHeight;
+            mis->itemData   = mis16->itemData;
+            *(LPARAM *)(mis + 1) = *plparam;  /* Store the previous lParam */
+            *plparam = (LPARAM)mis;
+        }
+        return 1;
     case WM_DRAWITEM:
         {
             DRAWITEMSTRUCT16* dis16 = (DRAWITEMSTRUCT16 *)PTR_SEG_TO_LIN(*plparam);
@@ -696,11 +740,8 @@
         }
         return 1;
     case WM_ASKCBFORMATNAME:
-    case WM_COMPAREITEM:
-    case WM_DELETEITEM:
     case WM_DEVMODECHANGE:
     case WM_MDIACTIVATE:
-    case WM_MEASUREITEM:
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
     case WM_WININICHANGE:
@@ -723,9 +764,22 @@
 {
     switch(msg)
     {
+    case WM_COMPAREITEM:
+    case WM_DELETEITEM:
     case WM_DRAWITEM:
         HeapFree( SystemHeap, 0, (LPVOID)lParam );
         break;
+    case WM_MEASUREITEM:
+        {
+            MEASUREITEMSTRUCT16 *mis16;
+            MEASUREITEMSTRUCT32 *mis = (MEASUREITEMSTRUCT32 *)lParam;
+            lParam = *(LPARAM *)(mis + 1);
+            mis16 = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(lParam);
+            mis16->itemWidth  = (UINT16)mis->itemWidth;
+            mis16->itemHeight = (UINT16)mis->itemHeight;
+            HeapFree( SystemHeap, 0, mis );
+        }
+        break;
     case WM_GETMINMAXINFO:
         {
             MINMAXINFO32 *mmi = (MINMAXINFO32 *)lParam;
@@ -931,6 +985,34 @@
         *plparam = MAKELPARAM( (HWND16)*plparam,
                                (WORD)msg32 - WM_CTLCOLORMSGBOX );
         return 0;
+    case WM_COMPAREITEM:
+        {
+            COMPAREITEMSTRUCT32 *cis32 = (COMPAREITEMSTRUCT32 *)*plparam;
+            COMPAREITEMSTRUCT16 *cis = SEGPTR_NEW(COMPAREITEMSTRUCT16);
+            if (!cis) return -1;
+            cis->CtlType    = (UINT16)cis32->CtlType;
+            cis->CtlID      = (UINT16)cis32->CtlID;
+            cis->hwndItem   = (HWND16)cis32->hwndItem;
+            cis->itemID1    = (UINT16)cis32->itemID1;
+            cis->itemData1  = cis32->itemData1;
+            cis->itemID2    = (UINT16)cis32->itemID2;
+            cis->itemData2  = cis32->itemData2;
+            *plparam = (LPARAM)SEGPTR_GET(cis);
+        }
+        return 1;
+    case WM_DELETEITEM:
+        {
+            DELETEITEMSTRUCT32 *dis32 = (DELETEITEMSTRUCT32 *)*plparam;
+            DELETEITEMSTRUCT16 *dis = SEGPTR_NEW(DELETEITEMSTRUCT16);
+            if (!dis) return -1;
+            dis->CtlType  = (UINT16)dis32->CtlType;
+            dis->CtlID    = (UINT16)dis32->CtlID;
+            dis->itemID   = (UINT16)dis32->itemID;
+            dis->hwndItem = (HWND16)dis32->hwndItem;
+            dis->itemData = dis32->itemData;
+            *plparam = (LPARAM)SEGPTR_GET(dis);
+        }
+        return 1;
     case WM_DRAWITEM:
         {
             DRAWITEMSTRUCT32 *dis32 = (DRAWITEMSTRUCT32 *)*plparam;
@@ -948,6 +1030,22 @@
             *plparam = (LPARAM)SEGPTR_GET(dis);
         }
         return 1;
+    case WM_MEASUREITEM:
+        {
+            MEASUREITEMSTRUCT32 *mis32 = (MEASUREITEMSTRUCT32 *)*plparam;
+            MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)
+                                     SEGPTR_ALLOC(sizeof(*mis)+sizeof(LPARAM));
+            if (!mis) return -1;
+            mis->CtlType    = (UINT16)mis32->CtlType;
+            mis->CtlID      = (UINT16)mis32->CtlID;
+            mis->itemID     = (UINT16)mis32->itemID;
+            mis->itemWidth  = (UINT16)mis32->itemWidth;
+            mis->itemHeight = (UINT16)mis32->itemHeight;
+            mis->itemData   = mis32->itemData;
+            *(LPARAM *)(mis + 1) = *plparam;  /* Store the previous lParam */
+            *plparam = (LPARAM)SEGPTR_GET(mis);
+        }
+        return 1;
     case WM_GETMINMAXINFO:
         {
             MINMAXINFO16 *mmi = (MINMAXINFO16 *)SEGPTR_ALLOC( sizeof(*mmi) +
@@ -1055,11 +1153,8 @@
         }
         return 1;
     case WM_ASKCBFORMATNAME:
-    case WM_COMPAREITEM:
-    case WM_DELETEITEM:
     case WM_DEVMODECHANGE:
     case WM_MDIACTIVATE:
-    case WM_MEASUREITEM:
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
     case WM_WININICHANGE:
@@ -1082,9 +1177,20 @@
 {
     switch(msg)
     {
+    case WM_COMPAREITEM:
+    case WM_DELETEITEM:
     case WM_DRAWITEM:
         SEGPTR_FREE( PTR_SEG_TO_LIN(lParam) );
         break;
+    case WM_MEASUREITEM:
+        {
+            MEASUREITEMSTRUCT16 *mis = (MEASUREITEMSTRUCT16 *)PTR_SEG_TO_LIN(lParam);
+            MEASUREITEMSTRUCT32 *mis32 = *(MEASUREITEMSTRUCT32 **)(mis + 1);
+            mis32->itemWidth  = mis->itemWidth;
+            mis32->itemHeight = mis->itemHeight;
+            SEGPTR_FREE(mis);
+        }
+        break;
     case WM_GETMINMAXINFO:
         {
             MINMAXINFO16 *mmi = (MINMAXINFO16 *)PTR_SEG_TO_LIN(lParam);