Index: trunk/src/user32/new/gen_object.cpp
===================================================================
--- trunk/src/user32/new/gen_object.cpp	(revision 722)
+++ trunk/src/user32/new/gen_object.cpp	(revision 724)
@@ -1,5 +1,9 @@
-/* $Id: gen_object.cpp,v 1.3 1999-08-24 09:20:30 sandervl Exp $ */
+/* $Id: gen_object.cpp,v 1.4 1999-08-28 14:09:29 sandervl Exp $ */
 /*
  * Generic Object Class for OS/2
+ *
+ * Allocated in shared memory, so other processes can access the objects
+ * 
+ * NOTE: Requires safety precautions to use objects in multiple threads or processes
  *
  * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
Index: trunk/src/user32/new/gen_object.h
===================================================================
--- trunk/src/user32/new/gen_object.h	(revision 722)
+++ trunk/src/user32/new/gen_object.h	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: gen_object.h,v 1.2 1999-08-24 09:20:30 sandervl Exp $ */
+/* $Id: gen_object.h,v 1.3 1999-08-28 14:09:29 sandervl Exp $ */
 /*
  * Generic Object Class for OS/2
@@ -8,4 +8,6 @@
 #ifndef __GEN_OBJECT_H__
 #define __GEN_OBJECT_H__
+
+#include "heapshared.h"
 
 #define OBJTYPE_WINDOW 		0
@@ -38,4 +40,24 @@
 static	 void  leaveMutex(DWORD objType);
 
+#ifdef __DEBUG_ALLOC__
+	void *operator new(size_t size, const char *filename, size_t lineno)
+	{
+		return _umalloc(sharedHeap, size);
+	}
+	void operator delete(void *location, const char *filename, size_t lineno)
+	{
+		free(location);
+	}
+#else
+	void *operator new(size_t size)
+	{
+		return _umalloc(sharedHeap, size);
+	}
+	void operator delete(void *location)
+	{
+		free(location);
+	}
+#endif
+
 private:
 
Index: trunk/src/user32/new/heapshared.cpp
===================================================================
--- trunk/src/user32/new/heapshared.cpp	(revision 724)
+++ trunk/src/user32/new/heapshared.cpp	(revision 724)
@@ -0,0 +1,92 @@
+/* $Id: heapshared.cpp,v 1.1 1999-08-28 14:09:57 sandervl Exp $ */
+/*
+ * Shared heap functions for OS/2
+ *
+ * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
+ *
+ */
+#define INCL_BASE
+#define INCL_DOSMEMMGR
+#include <os2wrap.h>
+#include <misc.h>
+#include "heapshared.h"
+
+#define INITIAL_HEAPSIZE	(64*1024)
+
+Heap_t  sharedHeap = 0;
+PVOID   pSharedMem = NULL;
+
+void * _LNK_CONV getmoreShared(Heap_t pHeap, size_t *size, int *clean);
+void _LNK_CONV releaseShared(Heap_t pHeap, void *block, size_t size);
+
+//******************************************************************************
+//******************************************************************************
+BOOL InitializeSharedHeap()
+{
+ APIRET rc;
+
+  dprintf(("USER32: InitializeSharedHeap"));
+  rc = DosAllocSharedMem(&pSharedMem, NULL, INITIAL_HEAPSIZE, PAG_READ|PAG_WRITE|PAG_COMMIT|OBJ_GIVEABLE);
+  if(rc != 0) {
+	dprintf(("InitializeSharedHeap: DosAllocSharedMem failed with %d", rc));
+	return FALSE;
+  }
+  sharedHeap = _ucreate(pSharedMem, INITIAL_HEAPSIZE, _BLOCK_CLEAN, 
+                        _HEAP_REGULAR|_HEAP_SHARED,
+                        getmoreShared, releaseShared);
+
+  if(sharedHeap == NULL) {
+	dprintf(("InitializeSharedHeap: _ucreate failed!"));
+	return FALSE;
+  }
+  return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
+void DestroySharedHeap()
+{
+  dprintf(("USER32: DestroySharedHeap"));
+  if(sharedHeap) {
+	_uclose(sharedHeap);
+	_udestroy(sharedHeap, _FORCE);
+	sharedHeap = NULL;
+  }
+  if(pSharedMem) {
+	DosFreeMem(pSharedMem);
+	pSharedMem = NULL;
+  }
+}
+//******************************************************************************
+//******************************************************************************
+void  *_smalloc(size_t size)
+{
+  return _umalloc(sharedHeap, size);
+}
+//******************************************************************************
+//******************************************************************************
+void * _LNK_CONV getmoreShared(Heap_t pHeap, size_t *size, int *clean)
+{
+ APIRET rc;
+ ULONG newsize;
+ PVOID newblock;
+
+  /* round the size up to a multiple of 64K */
+  *size = (*size / 65536) * 65536 + 65536;
+
+  rc = DosAllocSharedMem(&newblock, NULL, *size, PAG_READ|PAG_WRITE|PAG_COMMIT|OBJ_GIVEABLE);
+  if(rc != 0) {
+	dprintf(("getmoreShared: DosAllocSharedMem failed with %d", rc));
+	return NULL;
+  }
+  *clean = _BLOCK_CLEAN;
+
+  return newblock;
+}
+//******************************************************************************
+//******************************************************************************
+void _LNK_CONV releaseShared(Heap_t pHeap, void *block, size_t size)
+{
+  DosFreeMem(block);
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/user32/new/heapshared.h
===================================================================
--- trunk/src/user32/new/heapshared.h	(revision 724)
+++ trunk/src/user32/new/heapshared.h	(revision 724)
@@ -0,0 +1,22 @@
+/* $Id: heapshared.h,v 1.1 1999-08-28 14:09:58 sandervl Exp $ */
+/*
+ * Shared heap functions for OS/2
+ *
+ * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
+ *
+ */
+#ifndef __HEAPSHARED_H__
+#define __HEAPSHARED_H__
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <umalloc.h>
+
+extern Heap_t sharedHeap;
+
+BOOL   InitializeSharedHeap();
+void   DestroySharedHeap();
+
+void  *_smalloc(size_t size);
+
+#endif
Index: trunk/src/user32/new/initterm.cpp
===================================================================
--- trunk/src/user32/new/initterm.cpp	(revision 722)
+++ trunk/src/user32/new/initterm.cpp	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: initterm.cpp,v 1.5 1999-08-16 16:55:33 sandervl Exp $ */
+/* $Id: initterm.cpp,v 1.6 1999-08-28 14:09:29 sandervl Exp $ */
 
 /*
@@ -36,4 +36,5 @@
 #include <spy.h>
 #include "pmwindow.h"
+#include "heapshared.h"
 
 /*-------------------------------------------------------------------*/
@@ -93,4 +94,7 @@
          InitSpyQueue();
 
+	 if(InitializeSharedHeap() == FALSE) 
+		return 0UL;
+
          //SvL: Init win32 PM classes
          if(InitPM() == FALSE) {
@@ -125,4 +129,5 @@
    dprintf(("user32 exit\n"));
    UnregisterSystemClasses();
+   DestroySharedHeap();
    _ctordtorTerm();
    dprintf(("user32 exit done\n"));
Index: trunk/src/user32/new/makefile
===================================================================
--- trunk/src/user32/new/makefile	(revision 722)
+++ trunk/src/user32/new/makefile	(revision 724)
@@ -1,3 +1,3 @@
-# $Id: makefile,v 1.33 1999-08-25 15:08:50 dengert Exp $
+# $Id: makefile,v 1.34 1999-08-28 14:09:29 sandervl Exp $
 
 #
@@ -22,5 +22,5 @@
 
 OBJS =  user32.obj dialog.obj loadres.obj \
-        dde.obj \
+        dde.obj heapshared.obj\
         icon.obj hook.obj hooks.obj winmenu.obj \
         usrcall.obj defwndproc.obj syscolor.obj char.obj initterm.obj \
@@ -69,5 +69,5 @@
 defwndproc.obj: defwndproc.cpp syscolor.h
 hooks.obj: hooks.cpp hooks.h
-initterm.obj: initterm.cpp $(PDWIN32_INCLUDE)\spy.h pmwindow.h
+initterm.obj: initterm.cpp $(PDWIN32_INCLUDE)\spy.h pmwindow.h heapshared.h
 uitools.obj: uitools.cpp
 unknown.obj: unknown.cpp
@@ -100,9 +100,9 @@
 
 pmwindow.obj:   pmwindow.cpp win32class.h win32wnd.h win32dlg.h pmwindow.h win32wndchild.h $(PDWIN32_INCLUDE)\wprocess.h oslibgdi.h oslibwin.h
-win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
-win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h  $(PDWIN32_INCLUDE)\winres.h oslibres.h
-win32dlg.obj:   win32dlg.cpp win32class.h win32wnd.h win32dlg.h gen_object.h oslibwin.h win32wndchild.h
+win32class.obj: win32class.cpp win32class.h win32wnd.h win32dlg.h gen_object.h heapshared.h oslibwin.h win32wndchild.h
+win32wnd.obj:   win32wnd.cpp win32class.h win32wnd.h win32dlg.h gen_object.h heapshared.h oslibwin.h win32wndchild.h  $(PDWIN32_INCLUDE)\winres.h oslibres.h
+win32dlg.obj:   win32dlg.cpp win32class.h win32wnd.h win32dlg.h gen_object.h heapshared.h oslibwin.h win32wndchild.h
 win32wndchild.obj: win32wndchild.cpp win32wndchild.h
-gen_object.obj: gen_object.cpp gen_object.h
+gen_object.obj: gen_object.cpp gen_object.h heapshared.h
 oslibwin.obj:   oslibwin.cpp oslibwin.h oslibutil.h oslibgdi.h $(PDWIN32_INCLUDE)\winconst.h
 oslibutil.obj:  oslibutil.cpp oslibutil.h $(PDWIN32_INCLUDE)\wprocess.h oslibmsg.h
@@ -114,4 +114,6 @@
 dib.obj:        dib.cpp dib.h
 
+heapshared.obj: heapshared.cpp heapshared.h
+
 clean:
         $(RM) *.obj *.lib *.dll *~ *.map *.pch
Index: trunk/src/user32/new/oslibwin.cpp
===================================================================
--- trunk/src/user32/new/oslibwin.cpp	(revision 722)
+++ trunk/src/user32/new/oslibwin.cpp	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.cpp,v 1.25 1999-08-27 17:50:56 dengert Exp $ */
+/* $Id: oslibwin.cpp,v 1.26 1999-08-28 14:09:29 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -675,3 +675,33 @@
 //******************************************************************************
 //******************************************************************************
-
+HWND OSLibWinBeginEnumWindows(HWND hwnd)
+{
+   if(hwnd == OSLIB_HWND_DESKTOP)	hwnd = HWND_DESKTOP;
+
+   return WinBeginEnumWindows(hwnd);
+}
+//******************************************************************************
+//******************************************************************************
+HWND OSLibWinGetNextWindow(HWND hwndEnum)
+{
+   return WinGetNextWindow(hwndEnum);
+}
+//******************************************************************************
+//******************************************************************************
+HWND OSLibWinQueryClientWindow(HWND hwndFrame)
+{
+ HWND hwndClient = 0;
+
+   if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
+          hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
+
+   return hwndClient;
+}
+//******************************************************************************
+//******************************************************************************
+BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
+{
+   return WinEndEnumWindows(hwndEnum);
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/user32/new/oslibwin.h
===================================================================
--- trunk/src/user32/new/oslibwin.h	(revision 722)
+++ trunk/src/user32/new/oslibwin.h	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.h,v 1.22 1999-08-27 17:50:56 dengert Exp $ */
+/* $Id: oslibwin.h,v 1.23 1999-08-28 14:09:29 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -237,3 +237,8 @@
 void  OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame);
 
+HWND  OSLibWinBeginEnumWindows(HWND hwnd);
+HWND  OSLibWinGetNextWindow(HWND hwndEnum);
+HWND  OSLibWinQueryClientWindow(HWND hwndFrame);
+BOOL  OSLibWinEndEnumWindows(HWND hwndEnum);
+
 #endif //__OSLIBWIN_H__
Index: trunk/src/user32/new/win32class.cpp
===================================================================
--- trunk/src/user32/new/win32class.cpp	(revision 722)
+++ trunk/src/user32/new/win32class.cpp	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: win32class.cpp,v 1.7 1999-08-24 09:20:30 sandervl Exp $ */
+/* $Id: win32class.cpp,v 1.8 1999-08-28 14:09:30 sandervl Exp $ */
 /*
  * Win32 Window Class Managment Code for OS/2
@@ -28,12 +28,12 @@
                 INT len = lstrlenW((LPWSTR)wndclass->lpszClassName)+1;
 
-                classNameA = (PCHAR)malloc(len);
-                classNameW = (WCHAR *)malloc(len*sizeof(WCHAR));
+                classNameA = (PCHAR)_smalloc(len);
+                classNameW = (WCHAR *)_smalloc(len*sizeof(WCHAR));
         }
         else {
                 INT len = strlen(wndclass->lpszClassName)+1;
 
-                classNameA = (PCHAR)malloc(len);
-                classNameW = (WCHAR *)malloc(len*sizeof(WCHAR));
+                classNameA = (PCHAR)_smalloc(len);
+                classNameW = (WCHAR *)_smalloc(len*sizeof(WCHAR));
         }
         if(classNameA == NULL || classNameW == NULL) {
@@ -90,5 +90,5 @@
   //User data class words/longs
   if(nrExtraClassWords) {
-        userClassLong = (ULONG *)malloc(nrExtraClassWords);
+        userClassLong = (ULONG *)_smalloc(nrExtraClassWords);
         if(userClassLong == NULL) {
                 dprintf(("Win32Class ctr: userClassLong == NULL!"));
@@ -115,4 +115,16 @@
         free(menuNameW);
   }
+}
+//******************************************************************************
+//******************************************************************************
+BOOL Win32WndClass::hasClassName(LPSTR classname, BOOL fUnicode)
+{
+  if(HIWORD(classname) == 0) {
+	return classAtom == (DWORD)classname;
+  }
+  if(fUnicode) {
+	return (lstrcmpW(classNameW, (LPWSTR)classname) == 0);
+  }
+  else	return (strcmp(classNameA, classname) == 0);
 }
 //******************************************************************************
@@ -238,10 +250,10 @@
   if(HIWORD(newMenuName)) {
         if(isUnicode) {
-                menuNameA = (PCHAR)malloc(lstrlenW((LPWSTR)newMenuName)+1);
-                menuNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR));
-        }
-        else {
-                menuNameA = (PCHAR)malloc(strlen(newMenuName)+1);
-                menuNameW = (WCHAR *)malloc((strlen(newMenuName)+1)*sizeof(WCHAR));
+                menuNameA = (PCHAR)_smalloc(lstrlenW((LPWSTR)newMenuName)+1);
+                menuNameW = (WCHAR *)_smalloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR));
+        }
+        else {
+                menuNameA = (PCHAR)_smalloc(strlen(newMenuName)+1);
+                menuNameW = (WCHAR *)_smalloc((strlen(newMenuName)+1)*sizeof(WCHAR));
         }
         if(menuNameA == NULL || menuNameW == NULL) {
Index: trunk/src/user32/new/win32class.h
===================================================================
--- trunk/src/user32/new/win32class.h	(revision 722)
+++ trunk/src/user32/new/win32class.h	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: win32class.h,v 1.4 1999-08-22 08:30:52 sandervl Exp $ */
+/* $Id: win32class.h,v 1.5 1999-08-28 14:09:30 sandervl Exp $ */
 /*
  * Win32 Window Class Managment Code for OS/2
@@ -52,4 +52,6 @@
 	  void  DecreaseWindowCount()   { cWindows--; };
 	  DWORD GetWindowCount()        { return cWindows; };
+
+          BOOL  hasClassName(LPSTR classname, BOOL fUnicode = 0);
 	  
  static  void	UnregisterClassA(HINSTANCE hinst, LPSTR id);
Index: trunk/src/user32/new/win32wnd.cpp
===================================================================
--- trunk/src/user32/new/win32wnd.cpp	(revision 722)
+++ trunk/src/user32/new/win32wnd.cpp	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: win32wnd.cpp,v 1.31 1999-08-27 17:50:56 dengert Exp $ */
+/* $Id: win32wnd.cpp,v 1.32 1999-08-28 14:09:30 sandervl Exp $ */
 /*
  * Win32 Window Code for OS/2
@@ -11,4 +11,5 @@
  * Copyright 1993, 1994 Alexandre Julliard
  *
+ * TODO: Not thread/process safe
  *
  * Project Odin Software License can be found in LICENSE.TXT
@@ -23,4 +24,5 @@
 #include <misc.h>
 #include <handlemanager.h>
+#include <heapstring.h>
 #include <win32wnd.h>
 #include <spy.h>
@@ -71,6 +73,6 @@
   fFirstShow       = TRUE;
 
-  memset(windowNameA, 0, MAX_WINDOW_NAMELENGTH);
-  memset(windowNameW, 0, MAX_WINDOW_NAMELENGTH*sizeof(WCHAR));
+  windowNameA      = NULL;
+  windowNameW      = NULL;
   wndNameLength    = 0;
 
@@ -125,4 +127,12 @@
   if(userWindowLong)
         free(userWindowLong);
+  if(windowNameA) {
+        free(windowNameA);
+        windowNameA = NULL;
+  }
+  if(windowNameW) {
+        free(windowNameW);
+        windowNameW = NULL;
+  }
 }
 //******************************************************************************
@@ -249,5 +259,5 @@
   nrUserWindowLong = windowClass->getExtraWndWords();
   if(nrUserWindowLong) {
-        userWindowLong = (ULONG *)malloc(nrUserWindowLong);
+        userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
         memset(userWindowLong, 0, nrUserWindowLong);
   }
@@ -371,6 +381,9 @@
 #endif
 
+  if(cs->lpszName)
+        SetWindowText((LPSTR)cs->lpszName);
+
   OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
-                                 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
+                                 dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
                                  (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
                                  (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
@@ -985,8 +998,8 @@
 {
     if(isUnicode) {
-        SendInternalMessageW(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameW);
+        SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW);
     }
     else {
-        SendInternalMessageA(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameA);
+        SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
     }
     return windowNameA;
@@ -1656,5 +1669,81 @@
 }
 //******************************************************************************
-//TODO: not complete nor correct (distinction between top-level, top-most & child windows)
+//TODO:
+//We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
+//the current process owns them.
+//******************************************************************************
+HWND Win32Window::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
+                               BOOL fUnicode)
+{
+ Win32Window *parent = GetWindowFromHandle(hwndParent);
+ Win32Window *child  = GetWindowFromHandle(hwndChildAfter);
+
+    if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
+       (hwndChildAfter != 0 && !child) ||
+       (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
+    {
+        dprintf(("Win32Window::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
+        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+        return 0;
+    }
+    if(hwndParent != OSLIB_HWND_DESKTOP)
+    {//if the current process owns the window, just do a quick search
+        child = (Win32Window *)parent->GetFirstChild();
+        if(hwndChildAfter != 0)
+        {
+            while(child)
+            {
+                if(child->getWindowHandle() == hwndChildAfter)
+                {
+                    child = (Win32Window *)child->GetNextChild();
+                    break;
+                }
+                child = (Win32Window *)child->GetNextChild();
+            }
+        }
+        while(child)
+        {
+            if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
+               (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
+            {
+                dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
+                return child->getWindowHandle();
+            }
+            child = (Win32Window *)child->GetNextChild();
+        }
+    }
+    else {
+        Win32Window *wnd;
+        HWND henum, hwnd;
+
+        henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
+        hwnd = OSLibWinGetNextWindow(henum);
+
+        while(hwnd)
+        {
+            HWND hwndClient;
+
+            wnd = GetWindowFromOS2Handle(hwnd);
+            if(wnd == NULL) {
+                hwndClient = OSLibWinQueryClientWindow(hwnd);
+                if(hwndClient)  wnd = GetWindowFromOS2Handle(hwndClient);
+            }
+
+            if(wnd && wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
+               (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
+            {
+                OSLibWinEndEnumWindows(henum);
+                dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
+                return wnd->getWindowHandle();
+            }
+            hwnd = OSLibWinGetNextWindow(henum);
+        }
+        OSLibWinEndEnumWindows(henum);
+    }
+    SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
+    return 0;
+}
+//******************************************************************************
+//TODO: not complete nor correct (distinction be    tween top-level, top-most & child windows)
 //******************************************************************************
 HWND Win32Window::GetWindow(UINT uCmd)
@@ -1770,4 +1859,13 @@
 //******************************************************************************
 //******************************************************************************
+BOOL Win32Window::hasWindowName(LPSTR wndname, BOOL fUnicode)
+{
+    if(fUnicode) {
+            return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
+    }
+    else    return (strcmp(windowNameA, wndname) == 0);
+}
+//******************************************************************************
+//******************************************************************************
 int Win32Window::GetWindowTextLengthA()
 {
@@ -1782,7 +1880,27 @@
 //******************************************************************************
 //******************************************************************************
-BOOL Win32Window::SetWindowTextA(LPCSTR lpsz)
-{
-  return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)lpsz);
+BOOL Win32Window::SetWindowText(LPSTR lpsz)
+{
+    if(lpsz == NULL)
+        return FALSE;
+
+    if(isUnicode == FALSE) {
+        windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
+        strcpy(windowNameA, lpsz);
+        windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
+        lstrcpyAtoW(windowNameW, windowNameA);
+    }
+    else {
+        windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
+        lstrcpyW(windowNameW, (LPWSTR)lpsz);
+        windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
+        lstrcpyWtoA(windowNameA, windowNameW);
+    }
+    wndNameLength = strlen(windowNameA)+1; //including 0 terminator
+
+    if(OS2Hwnd)
+        return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)windowNameA);
+
+    return TRUE;
 }
 //******************************************************************************
@@ -1810,5 +1928,5 @@
                 return oldval;
         case GWL_HWNDPARENT:
-        return SetParent((HWND)value);
+                return SetParent((HWND)value);
 
         case GWL_ID:
@@ -1895,9 +2013,9 @@
 
    if(HIWORD(hwnd) != 0x6800) {
-    return NULL;
+        return NULL;
    }
 
    if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) {
-    return window;
+        return window;
    }
    else return NULL;
@@ -1914,5 +2032,5 @@
 
   if(win32wnd && CheckMagicDword(magic)) {
-    return win32wnd;
+        return win32wnd;
   }
   return 0;
Index: trunk/src/user32/new/win32wnd.h
===================================================================
--- trunk/src/user32/new/win32wnd.h	(revision 722)
+++ trunk/src/user32/new/win32wnd.h	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: win32wnd.h,v 1.26 1999-08-27 17:50:57 dengert Exp $ */
+/* $Id: win32wnd.h,v 1.27 1999-08-28 14:09:30 sandervl Exp $ */
 /*
  * Win32 Window Code for OS/2
@@ -45,7 +45,5 @@
 #define WM_WIN32_POSTMESSAGEW   0x4001
 
-#define MAX_WINDOW_NAMELENGTH   256
-
-class Win32Window : private GenericObject, private ChildWindow
+class Win32Window : public GenericObject, private ChildWindow
 {
 public:
@@ -91,4 +89,6 @@
          HWND   getOS2WindowHandle()            { return OS2Hwnd; };
          HWND   getOS2FrameWindowHandle()       { return OS2HwndFrame; };
+ Win32WndClass *getWindowClass()                { return windowClass; };
+
          BOOL   isFrameWindow()                 { return OS2Hwnd != OS2HwndFrame; };
    Win32Window *getParent()                     { return (Win32Window *)ChildWindow::GetParent(); };
@@ -146,5 +146,6 @@
          int    GetWindowTextLengthA();
          int    GetWindowTextA(LPSTR lpsz, int cch);
-         BOOL   SetWindowTextA(LPCSTR lpsz);
+         BOOL   SetWindowText(LPSTR lpsz);
+          BOOL  hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
 
        LRESULT  SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
@@ -158,4 +159,7 @@
 
 Win32WndClass  *getClass()  { return windowClass; };
+
+    static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
+                             BOOL fUnicode = 0);
 
 static   HWND  Win32ToOS2Handle(HWND hwnd)
@@ -219,7 +223,7 @@
  Win32Resource *iconResource;
 
-        char    windowNameA[MAX_WINDOW_NAMELENGTH];
-        WCHAR   windowNameW[MAX_WINDOW_NAMELENGTH];
-        ULONG   wndNameLength;
+        char   *windowNameA;
+        WCHAR  *windowNameW;
+        ULONG   wndNameLength; //including 0 terminator
 
         ULONG  *userWindowLong;
Index: trunk/src/user32/new/win32wndchild.cpp
===================================================================
--- trunk/src/user32/new/win32wndchild.cpp	(revision 722)
+++ trunk/src/user32/new/win32wndchild.cpp	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: win32wndchild.cpp,v 1.1 1999-07-16 11:32:09 sandervl Exp $ */
+/* $Id: win32wndchild.cpp,v 1.2 1999-08-28 14:09:30 sandervl Exp $ */
 /*
  * Win32 Child/Parent window class for OS/2
@@ -35,12 +35,23 @@
 }
 //******************************************************************************
-//LIFO insertion
+//FIFO insertion
 //******************************************************************************
 BOOL ChildWindow::AddChild(ChildWindow *child)
 {
+ ChildWindow *curchild;
+
    mutex.enter();
 
-   child->SetNextChild(children);
-   children = child;
+   curchild = children;
+   if(curchild == NULL) {
+   	children = child;
+   }
+   else {
+	while(curchild->GetNextChild()) {
+		curchild = curchild->GetNextChild();
+	}
+	curchild->SetNextChild(this);
+   }
+   child->SetNextChild(NULL);
 
    mutex.leave();
Index: trunk/src/user32/new/win32wndchild.h
===================================================================
--- trunk/src/user32/new/win32wndchild.h	(revision 722)
+++ trunk/src/user32/new/win32wndchild.h	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: win32wndchild.h,v 1.1 1999-07-16 11:32:09 sandervl Exp $ */
+/* $Id: win32wndchild.h,v 1.2 1999-08-28 14:09:30 sandervl Exp $ */
 /*
  * Win32 Child/Parent window class for OS/2
@@ -36,4 +36,6 @@
 	BOOL   AddChild(ChildWindow *child);
 	BOOL   RemoveChild(ChildWindow *child);
+
+ChildWindow   *GetFirstChild()                  { return children; };
 ChildWindow   *GetNextChild()   		{ return nextchild; };
         void   SetNextChild(ChildWindow *child)	{ nextchild = child; };
Index: trunk/src/user32/new/window.cpp
===================================================================
--- trunk/src/user32/new/window.cpp	(revision 722)
+++ trunk/src/user32/new/window.cpp	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.16 1999-08-27 16:52:09 sandervl Exp $ */
+/* $Id: window.cpp,v 1.17 1999-08-28 14:09:30 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -568,5 +568,5 @@
     }
     dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
-    return window->SetWindowTextA(lpsz);
+    return window->SetWindowText((LPSTR)lpsz);
 }
 //******************************************************************************
@@ -645,18 +645,29 @@
 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 O32_FindWindow(lpszClass, lpszWindow);
-}
-//******************************************************************************
-//******************************************************************************
-HWND WIN32API FindWindowExA(HWND hwnd1, HWND hwnd2, LPCSTR lpszClass, LPCSTR lpszWindow)
-{
-#ifdef DEBUG
-    WriteLog("USER32:  FindWindowExA, not completely implemented\n");
-#endif
-    return FindWindowA(lpszClass, lpszWindow);
+
+    return Win32Window::FindWindowEx(OSLIB_HWND_DESKTOP, 0, (LPSTR)lpszClass, (LPSTR)lpszWindow);
+}
+//******************************************************************************
+//******************************************************************************
+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 Win32Window::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
 }
 /*****************************************************************************
@@ -686,11 +697,11 @@
                                LPCWSTR lpszWindow)
 {
-  dprintf(("USER32:FindWindowExW (%08xh,%08xh,%s,%s) not implemented.\n",
-         hwndParent,
-         hwndChildAfter,
-         lpszClass,
-         lpszWindow));
-
-  return (NULL);
+    if(!lpszClass) {
+	SetLastError(ERROR_INVALID_PARAMETER);
+	return 0;
+    }
+    dprintf(("USER32:  FindWindowExW (%x,%x) %x %s\n", hwndParent, hwndChildAfter, lpszClass, lpszWindow));
+
+    return Win32Window::FindWindowEx(hwndParent, hwndChildAfter, (LPSTR)lpszClass, (LPSTR)lpszWindow);
 }
 //******************************************************************************
Index: trunk/src/user32/new/wingdi.cpp
===================================================================
--- trunk/src/user32/new/wingdi.cpp	(revision 722)
+++ trunk/src/user32/new/wingdi.cpp	(revision 724)
@@ -1,3 +1,3 @@
-/* $Id: wingdi.cpp,v 1.9 1999-08-23 15:34:47 dengert Exp $ */
+/* $Id: wingdi.cpp,v 1.10 1999-08-28 14:09:31 sandervl Exp $ */
 /*
  * Win32 Window graphics apis for OS/2
@@ -32,4 +32,5 @@
 	return 0;
     }
+    window->MsgEraseBackGround(hdc);
 #ifdef OPEN32_GDI
     hdc = O32_BeginPaint(window->getOS2WindowHandle(),lps);
