Index: trunk/src/user32/oslibmsgtranslate.cpp
===================================================================
--- trunk/src/user32/oslibmsgtranslate.cpp	(revision 2955)
+++ trunk/src/user32/oslibmsgtranslate.cpp	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsgtranslate.cpp,v 1.18 2000-02-24 19:19:08 sandervl Exp $ */
+/* $Id: oslibmsgtranslate.cpp,v 1.19 2000-03-01 13:30:04 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -31,6 +31,7 @@
 #include "pmwindow.h"
 #include "oslibwin.h"
-
-#define DBG_LOCALLOG	DBG_oslibmsgtranslate
+#include "winmouse.h"
+
+#define DBG_LOCALLOG    DBG_oslibmsgtranslate
 #include "dbglocal.h"
 
@@ -326,13 +327,13 @@
         if (!win32wnd->CanReceiveSizeMsgs())    goto dummymessage;
 
-	ULONG windowStyle = WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE);
-	win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MAXIMIZE_W|WS_MINIMIZE_W));
-	if (windowStyle & WS_MINIMIZED) {
-		win32wnd->setStyle(win32wnd->getStyle() | WS_MINIMIZE_W);
-	}
-	else
-	if (windowStyle & WS_MAXIMIZED) {
-		win32wnd->setStyle(win32wnd->getStyle() | WS_MAXIMIZE_W);
-	}
+        ULONG windowStyle = WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE);
+        win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MAXIMIZE_W|WS_MINIMIZE_W));
+        if (windowStyle & WS_MINIMIZED) {
+            win32wnd->setStyle(win32wnd->getStyle() | WS_MINIMIZE_W);
+        }
+        else
+        if (windowStyle & WS_MAXIMIZED) {
+            win32wnd->setStyle(win32wnd->getStyle() | WS_MAXIMIZE_W);
+        }
 
         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
@@ -436,4 +437,9 @@
             winMsg->lParam  = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
         }
+        if(ISMOUSE_CAPTURED())
+        {
+            if(DInputMouseHandler(win32wnd->getWindowHandle(), MOUSEMSG_BUTTON, winMsg->pt.x, winMsg->pt.y))
+                goto dummymessage;
+        }
 
         break;
@@ -467,4 +473,9 @@
           winMsg->lParam  = MAKELONG(SHORT1FROMMP(os2Msg->mp1),mapY(win32wnd,SHORT2FROMMP(os2Msg->mp1)));
         }
+        if(ISMOUSE_CAPTURED())
+        {
+            if(DInputMouseHandler(win32wnd->getWindowHandle(), MOUSEMSG_MOVE, winMsg->pt.x, winMsg->pt.y))
+                goto dummymessage;
+        }
         //OS/2 Window coordinates -> Win32 Window coordinates
         break;
@@ -622,5 +633,8 @@
             }
         }
-
+        if(ISKDB_CAPTURED())
+        {
+            DInputKeyBoardHandler(winMsg);
+        }
         break;
     }
Index: trunk/src/user32/pmframe.cpp
===================================================================
--- trunk/src/user32/pmframe.cpp	(revision 2955)
+++ trunk/src/user32/pmframe.cpp	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: pmframe.cpp,v 1.43 2000-02-20 18:28:32 cbratschi Exp $ */
+/* $Id: pmframe.cpp,v 1.44 2000-03-01 13:30:05 sandervl Exp $ */
 /*
  * Win32 Frame Managment Code for OS/2
@@ -434,4 +434,7 @@
 
         dprintf(("PMFRAME: WM_ACTIVATE %x %x", hwnd, mp2));
+        if(win32wnd->IsWindowCreated())
+          win32wnd->DispatchMsgA(pWinMsg);
+
         if (win32wnd->IsWindowCreated())
         {
@@ -451,7 +454,4 @@
           WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
         }
-        if(win32wnd->IsWindowCreated())
-          win32wnd->DispatchMsgA(pWinMsg);
-
         RestoreOS2TIB();
         return 0;
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 2955)
+++ trunk/src/user32/win32wbase.cpp	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.170 2000-02-29 19:16:12 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.171 2000-03-01 13:30:05 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -45,5 +45,4 @@
 #include "controls.h"
 #include <wprocess.h>
-#include "winmouse.h"
 #include <win\hook.h>
 #include <menu.h>
@@ -864,4 +863,6 @@
 {
     switch(virtualkey) {
+    case VK_LEFT:
+    case VK_RIGHT:
     case VK_DOWN:
     case VK_UP:
@@ -939,10 +940,4 @@
     }
 
-    if(ISMOUSE_CAPTURED())
-    {
-        if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y))
-            return 0;
-    }
-
     if(fClick)
     {
@@ -965,5 +960,6 @@
                    && (hwndTop != GetForegroundWindow()) )
                 {
-                      ::SetActiveWindow(hwndTop);
+                    //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems
+                    OSLibWinSetFocus(getOS2FrameWindowHandle());
                 }
         }
@@ -1007,9 +1003,4 @@
 ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
 {
-    if(ISMOUSE_CAPTURED()) {
-        if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y))
-            return 0;
-    }
-
     //TODO: hiword should be 0 if window enters menu mode (SDK docs)
     SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
@@ -1022,8 +1013,4 @@
 ULONG Win32BaseWindow::MsgChar(MSG *msg)
 {
-    if(ISKDB_CAPTURED())
-    {
-        DInputKeyBoardHandler(msg);
-    }
     return DispatchMsgA(msg);
 }
@@ -2417,13 +2404,13 @@
 //the current process owns them.
 //******************************************************************************
-HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
-                                   BOOL fUnicode)
+HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow)
 {
  Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
  Win32BaseWindow *child  = GetWindowFromHandle(hwndChildAfter);
 
-    if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
+    dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow));
+    if((hwndParent != 0 && !parent) ||
        (hwndChildAfter != 0 && !child) ||
-       (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
+       (hwndParent == 0 && hwndChildAfter != 0))
     {
         dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
@@ -2431,5 +2418,6 @@
         return 0;
     }
-    if(hwndParent != OSLIB_HWND_DESKTOP)
+    SetLastError(0);
+    if(hwndParent != 0)
     {//if the current process owns the window, just do a quick search
         child = (Win32BaseWindow *)parent->getFirstChild();
@@ -2448,6 +2436,7 @@
         while(child)
         {
-            if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
-               (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
+            //According to Wine, the class doesn't need to be specified
+            if((!atom || child->getWindowClass()->getAtom() == atom) &&
+               (!lpszWindow || child->hasWindowName(lpszWindow)))
             {
                 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
@@ -2474,6 +2463,7 @@
 
             if(wnd) {
-                if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
-                   (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
+                //According to Wine, the class doesn't need to be specified
+                if((!atom || wnd->getWindowClass()->getAtom() == atom) &&
+                   (!lpszWindow || wnd->hasWindowName(lpszWindow)))
                 {
                     OSLibWinEndEnumWindows(henum);
@@ -2572,5 +2562,5 @@
     dprintf(("SetActiveWindow %x", getWindowHandle()));
     if(OSLibWinSetActiveWindow(OS2HwndFrame) == FALSE) {
-	dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2HwndFrame));
+        dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2HwndFrame));
     }
     hwndActive = GetActiveWindow();
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 2955)
+++ trunk/src/user32/win32wbase.h	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.86 2000-02-24 19:19:10 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.87 2000-03-01 13:30:06 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -270,6 +270,5 @@
 Win32BaseWindow *FindWindowById(int id);
 
-    static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
-                             BOOL fUnicode = 0);
+    static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow);
 
            BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
Index: trunk/src/user32/win32wbasenonclient.cpp
===================================================================
--- trunk/src/user32/win32wbasenonclient.cpp	(revision 2955)
+++ trunk/src/user32/win32wbasenonclient.cpp	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasenonclient.cpp,v 1.15 2000-02-23 17:05:19 cbratschi Exp $ */
+/* $Id: win32wbasenonclient.cpp,v 1.16 2000-03-01 13:30:06 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (non-client methods)
@@ -260,10 +260,13 @@
       Win32BaseWindow *topparent = GetTopParent();
 
-      if (GetActiveWindow() != topparent->getWindowHandle())
-        topparent->SetActiveWindow();
-
-      if (GetActiveWindow() == topparent->getWindowHandle())
-        SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
-      break;
+        if (GetActiveWindow() != topparent->getWindowHandle())
+        {
+            //SvL: Calling topparent->SetActiveWindow() causes focus problems
+            OSLibWinSetFocus(topparent->getOS2FrameWindowHandle());
+        }
+
+        if (GetActiveWindow() == topparent->getWindowHandle())
+            SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
+        break;
     }
 
Index: trunk/src/user32/window.cpp
===================================================================
--- trunk/src/user32/window.cpp	(revision 2955)
+++ trunk/src/user32/window.cpp	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.57 2000-02-24 19:19:10 sandervl Exp $ */
+/* $Id: window.cpp,v 1.58 2000-03-01 13:30:07 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -31,4 +31,5 @@
 #include "winicon.h"
 #include <win\winpos.h>
+#include <heapstring.h>
 
 #define DBG_LOCALLOG    DBG_window
@@ -187,5 +188,5 @@
     }
     if(HIWORD(className)) {
-         dprintf(("CreateWindowExW: class %s parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle));
+         dprintf(("CreateWindowExW: class %ls parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle));
     }
     else dprintf(("CreateWindowExW: class %d parent %x (%d,%d) (%d,%d), %x %x", className, parent, x, y, width, height, style, exStyle));
@@ -287,5 +288,5 @@
     if(!window) {
         dprintf(("CreateMDIWindowW, window %x not found", hwndParent));
-    SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+    	SetLastError(ERROR_INVALID_WINDOW_HANDLE);
         return 0;
     }
@@ -952,14 +953,5 @@
 HWND WIN32API FindWindowA(LPCSTR lpszClass, LPCSTR lpszWindow)
 {
-    if(!lpszClass) {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return 0;
-    }
-    if(HIWORD(lpszClass)) {
-         dprintf(("USER32:  FindWindow %s %s\n", lpszClass, lpszWindow));
-    }
-    else dprintf(("USER32:  FindWindow %x %s\n", lpszClass, lpszWindow));
-
-    return Win32BaseWindow::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
+    return FindWindowExA( NULL, NULL, lpszClass, lpszWindow );
 }
 //******************************************************************************
@@ -967,12 +959,5 @@
 HWND WIN32API FindWindowW( LPCWSTR lpClassName, LPCWSTR lpWindowName)
 {
- char *astring1 = UnicodeToAsciiString((LPWSTR)lpClassName);
- char *astring2 = UnicodeToAsciiString((LPWSTR)lpWindowName);
- HWND rc;
-
-    rc = FindWindowA(astring1, astring2);
-    FreeAsciiString(astring1);
-    FreeAsciiString(astring2);
-    return rc;
+    return FindWindowExW( NULL, NULL, lpClassName, lpWindowName );
 }
 //******************************************************************************
@@ -980,14 +965,17 @@
 HWND WIN32API FindWindowExA(HWND hwndParent, HWND hwndChildAfter, LPCSTR lpszClass, LPCSTR lpszWindow)
 {
-    if(!lpszClass) {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return 0;
-    }
-    if(HIWORD(lpszClass)) {
-         dprintf(("USER32:  FindWindowExA (%x,%x) %s %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
-    }
-    else dprintf(("USER32:  FindWindowExA (%x,%x)%x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
-
-    return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
+    ATOM atom = 0;
+
+    if (lpszClass)
+    {
+        /* If the atom doesn't exist, then no class */
+        /* with this name exists either. */
+        if (!(atom = GlobalFindAtomA( lpszClass ))) 
+        {
+            SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
+            return 0;
+        }
+    }
+    return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, (LPSTR)lpszWindow);
 }
 /*****************************************************************************
@@ -1007,21 +995,30 @@
  *               error information, call GetLastError.
  * Remark    :
- * Status    : UNTESTED STUB
  *
- * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
  *****************************************************************************/
 
 HWND WIN32API FindWindowExW(HWND    hwndParent,
-                               HWND    hwndChildAfter,
-                               LPCWSTR lpszClass,
-                               LPCWSTR lpszWindow)
-{
-    if(!lpszClass) {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return 0;
-    }
-    dprintf(("USER32:  FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
-
-    return Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
+                            HWND    hwndChildAfter,
+                            LPCWSTR lpszClass,
+                            LPCWSTR lpszWindow)
+{
+    ATOM atom = 0;
+    char *buffer;
+    HWND hwnd;
+
+    if (lpszClass)
+    {
+        /* If the atom doesn't exist, then no class */
+        /* with this name exists either. */
+        if (!(atom = GlobalFindAtomW( lpszClass )))
+        {
+            SetLastError(ERROR_CANNOT_FIND_WND_CLASS);
+            return 0;
+        }
+    }
+    buffer = HEAP_strdupWtoA( GetProcessHeap(), 0, lpszWindow );
+    hwnd = Win32BaseWindow::FindWindowEx(hwndParent, hwndChildAfter, atom, buffer);
+    HeapFree( GetProcessHeap(), 0, buffer );
+    return hwnd;
 }
 //******************************************************************************
Index: trunk/src/user32/winmouse.cpp
===================================================================
--- trunk/src/user32/winmouse.cpp	(revision 2955)
+++ trunk/src/user32/winmouse.cpp	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: winmouse.cpp,v 1.5 2000-02-16 14:28:28 sandervl Exp $ */
+/* $Id: winmouse.cpp,v 1.6 2000-03-01 13:30:07 sandervl Exp $ */
 /*
  * Mouse handler for DINPUT
@@ -12,4 +12,5 @@
 #include <misc.h>
 #include "win32wbase.h"
+#include <win\mouse.h>
 #include "winmouse.h"
 #include "oslibmsg.h"
Index: trunk/src/user32/winmouse.h
===================================================================
--- trunk/src/user32/winmouse.h	(revision 2955)
+++ trunk/src/user32/winmouse.h	(revision 2956)
@@ -1,3 +1,3 @@
-/* $Id: winmouse.h,v 1.4 2000-01-18 20:08:18 sandervl Exp $ */
+/* $Id: winmouse.h,v 1.5 2000-03-01 13:30:07 sandervl Exp $ */
 /*
  * Mouse handler for DINPUT
@@ -11,6 +11,4 @@
 #ifndef __WINMOUSE_H__
 #define __WINMOUSE_H__
-
-#include <win\mouse.h>
 
 extern LPMOUSE_EVENT_PROC mouseHandler;
