Index: trunk/src/user32/new/defwndproc.cpp
===================================================================
--- trunk/src/user32/new/defwndproc.cpp	(revision 738)
+++ trunk/src/user32/new/defwndproc.cpp	(revision 740)
@@ -1,3 +1,3 @@
-/* $Id: defwndproc.cpp,v 1.4 1999-07-25 15:51:55 sandervl Exp $ */
+/* $Id: defwndproc.cpp,v 1.5 1999-08-29 20:05:07 sandervl Exp $ */
 
 /*
@@ -6,4 +6,6 @@
  * Copyright 1998 Sander van Leeuwen
  *
+ *
+ * TODO: Incomplete default window handlers + incorrect handler (defframe)
  *
  * Project Odin Software License can be found in LICENSE.TXT
@@ -116,36 +118,64 @@
 }
 //******************************************************************************
+//TODO: Should be handled differently than the normal wnd proc
 //******************************************************************************
 LRESULT WIN32API DefFrameProcA(HWND hwndFrame, HWND hwndClient, UINT Msg, WPARAM wParam, LPARAM lParam)
 {
-#ifdef DEBUG
-////    WriteLog("*DFP*");
-#endif
-    switch(Msg) {
-        case WM_SETREDRAW: //Open32 does not set the visible flag
-                if(wParam)
-                  SetWindowLongA (hwndClient, GWL_STYLE, GetWindowLongA (hwndClient, GWL_STYLE) | WS_VISIBLE);
-                else
-                  SetWindowLongA (hwndClient, GWL_STYLE, GetWindowLongA (hwndClient, GWL_STYLE) & ~WS_VISIBLE);
-                return O32_DefFrameProc(hwndFrame, hwndClient, Msg, wParam, lParam);
-        case WM_NCCREATE://SvL: YAOFM (yet another open32 feature missing)
-                return(TRUE);
-        case WM_CTLCOLORMSGBOX:
-        case WM_CTLCOLOREDIT:
-        case WM_CTLCOLORLISTBOX:
-        case WM_CTLCOLORBTN:
-        case WM_CTLCOLORDLG:
-        case WM_CTLCOLORSTATIC:
-        case WM_CTLCOLORSCROLLBAR:
-                SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
-                SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
-                return GetSysColorBrush(COLOR_BTNFACE);
-
-    case WM_PARENTNOTIFY: //Open32 doesn't like receiving those!!
-        dprintf(("DefWndProc: WM_PARENTNOTIFY for %x", hwndFrame));
-        return 0;
-
-        default:
-                return O32_DefFrameProc(hwndFrame, hwndClient, Msg, wParam, lParam);
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwndFrame);
+    if(!window) {
+        dprintf(("DefFrameProcA, window %x not found", hwndFrame));
+        return 0;
+    }
+    return window->DefWindowProcA(Msg, wParam, lParam);
+}
+//******************************************************************************
+//TODO: Should be handled differently than the normal wnd proc
+//******************************************************************************
+LRESULT WIN32API DefFrameProcW(HWND hwndFrame, HWND hwndClient, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+  Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwndFrame);
+    if(!window) {
+        dprintf(("DefFrameProcW, window %x not found", hwndFrame));
+        return 0;
+    }
+    return window->DefWindowProcW(Msg, wParam, lParam);
+}
+//******************************************************************************
+//******************************************************************************
+LRESULT WIN32API DefMDIChildProcA(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+#ifdef DEBUG
+////    WriteLog("*DMP*");
+#endif
+    switch(Msg) {
+        case WM_SETREDRAW: //Open32 does not set the visible flag
+                if(wParam)
+                  SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) | WS_VISIBLE);
+                else
+                  SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) & ~WS_VISIBLE);
+                return O32_DefMDIChildProc(hwnd, Msg, wParam, lParam);
+        case WM_NCCREATE://SvL: YAOFM (yet another open32 feature missing)
+                return(TRUE);
+        case WM_CTLCOLORMSGBOX:
+        case WM_CTLCOLOREDIT:
+        case WM_CTLCOLORLISTBOX:
+        case WM_CTLCOLORBTN:
+        case WM_CTLCOLORDLG:
+        case WM_CTLCOLORSTATIC:
+        case WM_CTLCOLORSCROLLBAR:
+                SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
+                SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
+                return GetSysColorBrush(COLOR_BTNFACE);
+
+    case WM_PARENTNOTIFY: //Open32 doesn't like receiving those!!
+        dprintf(("DefWndProc: WM_PARENTNOTIFY for %x", hwnd));
+        return 0;
+
+        default:
+                return O32_DefMDIChildProc(hwnd, Msg, wParam, lParam);
     }
 }
@@ -153,75 +183,4 @@
 //NOTE: Unicode msg translation!
 //******************************************************************************
-LRESULT WIN32API DefFrameProcW(HWND hwndFrame, HWND hwndClient, UINT Msg, WPARAM wParam, LPARAM lParam)
-{
-#ifdef DEBUG
-////    WriteLog("*DFPW*");
-#endif
-    switch(Msg) {
-        case WM_SETREDRAW: //Open32 does not set the visible flag
-                if(wParam)
-                  SetWindowLongA (hwndClient, GWL_STYLE, GetWindowLongA (hwndClient, GWL_STYLE) | WS_VISIBLE);
-                else
-                  SetWindowLongA (hwndClient, GWL_STYLE, GetWindowLongA (hwndClient, GWL_STYLE) & ~WS_VISIBLE);
-                return O32_DefFrameProc(hwndFrame, hwndClient, Msg, wParam, lParam);
-        case WM_NCCREATE://SvL: YAOFM (yet another open32 feature missing)
-                return(TRUE);
-        case WM_CTLCOLORMSGBOX:
-        case WM_CTLCOLOREDIT:
-        case WM_CTLCOLORLISTBOX:
-        case WM_CTLCOLORBTN:
-        case WM_CTLCOLORDLG:
-        case WM_CTLCOLORSTATIC:
-        case WM_CTLCOLORSCROLLBAR:
-                SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
-                SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
-                return GetSysColorBrush(COLOR_BTNFACE);
-
-    case WM_PARENTNOTIFY: //Open32 doesn't like receiving those!!
-        dprintf(("DefWndProc: WM_PARENTNOTIFY for %x", hwndFrame));
-        return 0;
-
-        default:
-                return O32_DefFrameProc(hwndFrame, hwndClient, Msg, wParam, lParam);
-    }
-}
-//******************************************************************************
-//******************************************************************************
-LRESULT WIN32API DefMDIChildProcA(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
-{
-#ifdef DEBUG
-////    WriteLog("*DMP*");
-#endif
-    switch(Msg) {
-        case WM_SETREDRAW: //Open32 does not set the visible flag
-                if(wParam)
-                  SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) | WS_VISIBLE);
-                else
-                  SetWindowLongA (hwnd, GWL_STYLE, GetWindowLongA (hwnd, GWL_STYLE) & ~WS_VISIBLE);
-                return O32_DefMDIChildProc(hwnd, Msg, wParam, lParam);
-        case WM_NCCREATE://SvL: YAOFM (yet another open32 feature missing)
-                return(TRUE);
-        case WM_CTLCOLORMSGBOX:
-        case WM_CTLCOLOREDIT:
-        case WM_CTLCOLORLISTBOX:
-        case WM_CTLCOLORBTN:
-        case WM_CTLCOLORDLG:
-        case WM_CTLCOLORSTATIC:
-        case WM_CTLCOLORSCROLLBAR:
-                SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
-                SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
-                return GetSysColorBrush(COLOR_BTNFACE);
-
-    case WM_PARENTNOTIFY: //Open32 doesn't like receiving those!!
-        dprintf(("DefWndProc: WM_PARENTNOTIFY for %x", hwnd));
-        return 0;
-
-        default:
-                return O32_DefMDIChildProc(hwnd, Msg, wParam, lParam);
-    }
-}
-//******************************************************************************
-//NOTE: Unicode msg translation!
-//******************************************************************************
 LRESULT WIN32API DefMDIChildProcW(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 {
Index: trunk/src/user32/new/oslibmsg.cpp
===================================================================
--- trunk/src/user32/new/oslibmsg.cpp	(revision 738)
+++ trunk/src/user32/new/oslibmsg.cpp	(revision 740)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsg.cpp,v 1.2 1999-07-20 07:42:35 sandervl Exp $ */
+/* $Id: oslibmsg.cpp,v 1.3 1999-08-29 20:05:07 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -62,5 +62,5 @@
 void OSLibWinPostQuitMessage(ULONG nExitCode)
 {
-  WinPostQueueMsg(GetThreadMessageQueue(), WM_QUIT, (MPARAM)nExitCode, 0);
+  WinPostQueueMsg(NULLHANDLE, WM_QUIT, (MPARAM)nExitCode, 0);
 }
 //******************************************************************************
Index: trunk/src/user32/new/pmwindow.cpp
===================================================================
--- trunk/src/user32/new/pmwindow.cpp	(revision 738)
+++ trunk/src/user32/new/pmwindow.cpp	(revision 740)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.cpp,v 1.24 1999-08-28 19:32:46 sandervl Exp $ */
+/* $Id: pmwindow.cpp,v 1.25 1999-08-29 20:05:07 sandervl Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -434,4 +434,8 @@
     case WM_MOUSEMOVE:
     {
+	//Only send this message when the mouse isn't captured
+        if(WinQueryCapture(HWND_DESKTOP) != NULLHANDLE) {
+                goto RunDefWndProc;
+	}
         ULONG keystate = 0;
         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1))
@@ -589,7 +593,12 @@
 
     case WM_HITTEST:
-        if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
-                goto RunDefWndProc;
-        }
+	// Only send this message if the window is enabled
+        if (WinIsWindowEnabled(hwnd)) 
+	{
+	        if(win32wnd->MsgHitTest((*(POINTS *)&mp1).x, MapOS2ToWin32Y(OSLIB_HWND_DESKTOP, hwnd, (*(POINTS *)&mp1).y))) {
+        	        goto RunDefWndProc;
+		}
+        }
+        else    goto RunDefWndProc;
         break;
 
Index: trunk/src/user32/new/win32wnd.cpp
===================================================================
--- trunk/src/user32/new/win32wnd.cpp	(revision 738)
+++ trunk/src/user32/new/win32wnd.cpp	(revision 740)
@@ -1,3 +1,3 @@
-/* $Id: win32wnd.cpp,v 1.34 1999-08-28 19:32:47 sandervl Exp $ */
+/* $Id: win32wnd.cpp,v 1.35 1999-08-29 20:05:07 sandervl Exp $ */
 /*
  * Win32 Window Code for OS/2
@@ -880,8 +880,8 @@
 {
     if(hwnd == 0) {
-        //other app lost focus
-        SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
-    }
-    return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
+            //other app lost focus
+            SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
+    }
+    return  SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
 }
 //******************************************************************************
@@ -890,8 +890,8 @@
 {
     if(hwnd == 0) {
-        //other app lost focus
-        SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
-    }
-    return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
+            //other app lost focus
+            SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
+    }
+    return  SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
 }
 //******************************************************************************
@@ -949,6 +949,11 @@
         }
     }
-    SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
-    return SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly));
+    SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, win32ncmsg));
+
+    //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
+    if(lastHitTestVal != HTCLIENT) {
+            SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
+    }
+    return  SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly));
 }
 //******************************************************************************
@@ -957,4 +962,5 @@
 {
  ULONG winstate = 0;
+ ULONG setcursormsg = WM_MOUSEMOVE;
 
     if(keystate & WMMOVE_LBUTTON)
@@ -969,5 +975,15 @@
         winstate |= MK_CONTROL;
 
-    return SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y));
+    if(lastHitTestVal != HTCLIENT) {
+        setcursormsg = WM_NCMOUSEMOVE;
+    }
+    //TODO: hiword should be 0 if window enters menu mode (SDK docs)
+    SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, setcursormsg));
+
+    //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
+    if(lastHitTestVal != HTCLIENT) {
+            SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y));
+    }
+    return  SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y));
 }
 //******************************************************************************
@@ -1147,6 +1163,6 @@
         return 0;           //TODO: Send WM_SYSCOMMAND if required
 
-    case WM_NCHITTEST: //TODO:
-        return 0;
+    case WM_NCHITTEST: //TODO: Calculate position of
+        return HTCLIENT;
 
     default:
Index: trunk/src/user32/new/window.cpp
===================================================================
--- trunk/src/user32/new/window.cpp	(revision 738)
+++ trunk/src/user32/new/window.cpp	(revision 740)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.17 1999-08-28 14:09:30 sandervl Exp $ */
+/* $Id: window.cpp,v 1.18 1999-08-29 20:05:08 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -82,42 +82,4 @@
 //******************************************************************************
 //******************************************************************************
-HWND WIN32API CreateMDIWindowA(LPCSTR arg1, LPCSTR arg2, DWORD arg3,
-                               int arg4, int arg5, int arg6, int arg7,
-                               HWND arg8, HINSTANCE arg9, LPARAM  arg10)
-{
- HWND hwnd;
-
-    dprintf(("USER32:  CreateMDIWindowA\n"));
-
-    hwnd = O32_CreateMDIWindow((LPSTR)arg1, (LPSTR)arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
-
-    dprintf(("USER32:  CreateMDIWindowA returned %X\n", hwnd));
-    return hwnd;
-}
-//******************************************************************************
-//******************************************************************************
-HWND WIN32API CreateMDIWindowW(LPCWSTR arg1, LPCWSTR arg2, DWORD arg3, int arg4,
-                               int arg5, int arg6, int arg7, HWND arg8, HINSTANCE arg9,
-                               LPARAM arg10)
-{
- HWND hwnd;
- char *astring1 = NULL, *astring2 = NULL;
-
-    if((int)arg1 >> 16 != 0) {
-        astring1 = UnicodeToAsciiString((LPWSTR)arg1);
-    }
-    else    astring1 = (char *)arg2;
-
-    astring2 = UnicodeToAsciiString((LPWSTR)arg2);
-
-    hwnd = O32_CreateMDIWindow(astring1, astring2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
-
-    if(astring1)    FreeAsciiString(astring1);
-    FreeAsciiString(astring2);
-    dprintf(("USER32:  CreateMDIWindowW hwnd = %X\n", hwnd));
-    return(hwnd);
-}
-//******************************************************************************
-//******************************************************************************
 HWND WIN32API CreateWindowExW(DWORD exStyle, LPCWSTR className,
                               LPCWSTR windowName, DWORD style, INT x,
@@ -171,4 +133,64 @@
     }
     return window->getWindowHandle();
+}
+//******************************************************************************
+//******************************************************************************
+HWND WIN32API CreateMDIWindowA(LPCSTR lpszClassName, LPCSTR lpszWindowName, 
+                               DWORD dwStyle, int x, int y, int nWidth, 
+                               int nHeight, HWND hwndParent,
+                               HINSTANCE hInstance, LPARAM lParam )
+{
+ HWND hwnd;
+ MDICREATESTRUCTA cs;
+ Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwndParent);
+    if(!window) {
+        dprintf(("CreateMDIWindowA, window %x not found", hwndParent));
+        return 0;
+    }
+
+    dprintf(("USER32:  CreateMDIWindowA\n"));
+    cs.szClass        = lpszClassName;
+    cs.szTitle        = lpszWindowName;
+    cs.hOwner         = hInstance;
+    cs.x              = x;
+    cs.y              = y;
+    cs.cx             = nHeight;
+    cs.cy             = nWidth;
+    cs.style          = dwStyle;
+    cs.lParam         = lParam;
+
+    return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
+}
+//******************************************************************************
+//******************************************************************************
+HWND WIN32API CreateMDIWindowW(LPCWSTR lpszClassName, LPCWSTR lpszWindowName, 
+                               DWORD dwStyle, int x, int y, int nWidth, 
+                               int nHeight, HWND hwndParent,
+                               HINSTANCE hInstance, LPARAM lParam )
+{
+ HWND hwnd;
+ MDICREATESTRUCTW cs;
+ Win32Window *window;
+
+    window = Win32Window::GetWindowFromHandle(hwndParent);
+    if(!window) {
+        dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
+        return 0;
+    }
+
+    dprintf(("USER32:  CreateMDIWindowW\n"));
+    cs.szClass        = lpszClassName;
+    cs.szTitle        = lpszWindowName;
+    cs.hOwner         = hInstance;
+    cs.x              = x;
+    cs.y              = y;
+    cs.cx             = nHeight;
+    cs.cy             = nWidth;
+    cs.style          = dwStyle;
+    cs.lParam         = lParam;
+
+    return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
 }
 //******************************************************************************
