Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 1916)
+++ trunk/src/user32/win32wbase.cpp	(revision 1917)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.98 1999-11-27 14:16:35 cbratschi Exp $ */
+/* $Id: win32wbase.cpp,v 1.99 1999-12-01 10:49:45 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -1496,6 +1496,10 @@
 //******************************************************************************
 //******************************************************************************
-LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
-{
+LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam, BOOL fReentered)
+{
+    //Lotus Notes v5.0.1 calls SetWindowTextA for unicode static window -> calls DefWindowProcA
+    if(IsUnicode() && !fReentered) {
+        return DefWindowProcW(Msg, wParam, lParam);
+    }
     switch(Msg)
     {
@@ -1527,5 +1531,6 @@
           windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
           lstrcpyAtoW(windowNameW, windowNameA);
-        } else
+        }
+        else
         {
           windowNameA = NULL;
@@ -1533,5 +1538,5 @@
           wndNameLength = 0;
         }
-        dprintf(("WM_SETTEXT of %d to %s\n", Win32Hwnd, lParam));
+        dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
 
         if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
@@ -1789,5 +1794,6 @@
           windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
           lstrcpyW(windowNameW,lpsz);
-        } else
+        }
+        else
         {
           windowNameA = NULL;
@@ -1803,5 +1809,5 @@
 
     default:
-        return DefWindowProcA(Msg, wParam, lParam);
+        return DefWindowProcA(Msg, wParam, lParam, TRUE);
     }
 }
@@ -2344,5 +2350,9 @@
        if (isChild())
        {
-           hParent = getParent()->getOS2WindowHandle();
+         	Win32BaseWindow *windowParent = getParent();
+           	if(windowParent) {
+           		hParent = getParent()->getOS2WindowHandle();
+		}
+		else  	dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
        }
        OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
@@ -2734,29 +2744,9 @@
 HWND Win32BaseWindow::SetActiveWindow()
 {
-  return OSLibWinSetActiveWindow(OS2HwndFrame);
-}
-//******************************************************************************
-//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
-//******************************************************************************
-BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
-{
-  return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
-}
-//******************************************************************************
-//******************************************************************************
-BOOL Win32BaseWindow::CloseWindow()
-{
-  return OSLibWinMinimizeWindow(OS2HwndFrame);
-}
-//******************************************************************************
-//******************************************************************************
-HWND Win32BaseWindow::GetActiveWindow()
-{
- HWND          hwndActive;
+ HWND hwndActive;
  Win32BaseWindow  *win32wnd;
  ULONG         magic;
 
-  hwndActive = OSLibWinQueryActiveWindow();
-
+  hwndActive = OSLibWinSetActiveWindow(OS2HwndFrame);
   win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
   magic    = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
@@ -2765,5 +2755,37 @@
         return win32wnd->getWindowHandle();
   }
-  return hwndActive;
+  return 0;
+}
+//******************************************************************************
+//WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
+//******************************************************************************
+BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
+{
+  return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
+}
+//******************************************************************************
+//******************************************************************************
+BOOL Win32BaseWindow::CloseWindow()
+{
+  return OSLibWinMinimizeWindow(OS2HwndFrame);
+}
+//******************************************************************************
+//******************************************************************************
+HWND Win32BaseWindow::GetActiveWindow()
+{
+ HWND          hwndActive;
+ Win32BaseWindow  *win32wnd;
+ ULONG         magic;
+
+  hwndActive = OSLibWinQueryActiveWindow();
+
+  win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
+  magic    = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
+  if(CheckMagicDword(magic) && win32wnd)
+  {
+        return win32wnd->getWindowHandle();
+  }
+  return 0;
+//  return hwndActive;
 }
 //******************************************************************************
@@ -2823,4 +2845,11 @@
 BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
 {
+    //hmm. Notes v5.0.1 creates static window with CreateWindowExW and calls this...
+    if(IsUnicode() && lpsz) {
+        LPWSTR lpWindowNameW = (LPWSTR)alloca((strlen(lpsz)+1)*sizeof(WCHAR));
+        lstrcpyAtoW(lpWindowNameW, lpsz);
+
+        return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpWindowNameW);
+    }
     return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
 }
@@ -2934,36 +2963,36 @@
 
     switch(index) {
-        case GWL_EXSTYLE:
-                value = dwExStyle;
+    case GWL_EXSTYLE:
+        value = dwExStyle;
         break;
-        case GWL_STYLE:
-                value = dwStyle;
+    case GWL_STYLE:
+        value = dwStyle;
         break;
-        case GWL_WNDPROC:
-                value = (ULONG)getWindowProc();
+    case GWL_WNDPROC:
+        value = (ULONG)getWindowProc();
         break;
-        case GWL_HINSTANCE:
-                value = hInstance;
+    case GWL_HINSTANCE:
+        value = hInstance;
         break;
-        case GWL_HWNDPARENT:
-                if(getParent()) {
-                        value = getParent()->getWindowHandle();
-                }
-                else    value = 0;
+    case GWL_HWNDPARENT:
+        if(getParent()) {
+            value = getParent()->getWindowHandle();
+        }
+        else value = 0;
         break;
-        case GWL_ID:
-                value = getWindowId();
+    case GWL_ID:
+        value = getWindowId();
         break;
-        case GWL_USERDATA:
-                value = userData;
+    case GWL_USERDATA:
+        value = userData;
         break;
-        default:
-                if(index >= 0 && index/4 < nrUserWindowLong)
-                {
-                        value = userWindowLong[index/4];
+    default:
+        if(index >= 0 && index/4 < nrUserWindowLong)
+        {
+            value = userWindowLong[index/4];
             break;
-                }
-                SetLastError(ERROR_INVALID_PARAMETER);
-                return 0;
+        }
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return 0;
     }
     dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
@@ -3013,5 +3042,6 @@
          return window;
     }
-    else return NULL;
+//    dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
+    return NULL;
 }
 //******************************************************************************
@@ -3033,4 +3063,5 @@
         return win32wnd;
   }
+//  dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
   return 0;
 }
@@ -3050,5 +3081,6 @@
             return window->getOS2WindowHandle();
     }
-    else    return hwnd;
+//    dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
+    return hwnd;
 }
 //******************************************************************************
@@ -3061,5 +3093,6 @@
             return window->getOS2FrameWindowHandle();
     }
-    else    return hwnd;
+//    dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
+    return hwnd;
 }
 //******************************************************************************
@@ -3076,5 +3109,6 @@
             return window->getWindowHandle();
     }
-    else    return 0;
+//    dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
+    return 0;
 //    else    return hwnd;    //OS/2 window handle
 }
