Index: trunk/src/user32/defwndproc.cpp
===================================================================
--- trunk/src/user32/defwndproc.cpp	(revision 131)
+++ trunk/src/user32/defwndproc.cpp	(revision 134)
@@ -1,3 +1,3 @@
-/* $Id: defwndproc.cpp,v 1.2 1999-06-06 12:25:49 cbratschi Exp $ */
+/* $Id: defwndproc.cpp,v 1.3 1999-06-20 16:47:39 sandervl Exp $ */
 
 /*
@@ -44,4 +44,7 @@
                 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_DefWindowProc(hwnd, Msg, wParam, lParam);
@@ -79,4 +82,8 @@
                 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_DefWindowProc(hwnd, Msg, wParam, lParam);
@@ -113,4 +120,8 @@
                 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_DefDlgProc(hwnd, Msg, wParam, lParam);
@@ -147,4 +158,8 @@
                 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:
@@ -190,4 +205,8 @@
                 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);
@@ -233,4 +252,8 @@
                 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);
@@ -267,4 +290,8 @@
                 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);
@@ -302,4 +329,8 @@
                 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);
Index: trunk/src/user32/initterm.cpp
===================================================================
--- trunk/src/user32/initterm.cpp	(revision 131)
+++ trunk/src/user32/initterm.cpp	(revision 134)
@@ -1,3 +1,3 @@
-/* $Id: initterm.cpp,v 1.3 1999-06-19 10:54:47 sandervl Exp $ */
+/* $Id: initterm.cpp,v 1.4 1999-06-20 16:47:39 sandervl Exp $ */
 
 /*
@@ -124,4 +124,5 @@
 {
    dprintf(("user32 exit\n"));
+   UnregisterSystemClasses();
    _ctordtorTerm();
    CRT_term();
Index: trunk/src/user32/user32.cpp
===================================================================
--- trunk/src/user32/user32.cpp	(revision 131)
+++ trunk/src/user32/user32.cpp	(revision 134)
@@ -1,3 +1,3 @@
-/* $Id: user32.cpp,v 1.8 1999-06-20 14:02:13 sandervl Exp $ */
+/* $Id: user32.cpp,v 1.9 1999-06-20 16:47:39 sandervl Exp $ */
 
 /*
@@ -625,11 +625,5 @@
     }
     if(window) {
-        window->SetWindowHandle(hwnd);
-    }
-    //SvL: Taken from Wine
-    if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
-    {
-	/* Notify the parent window only */
-	SendMessageA(parent, WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, 0), (LPARAM)hwnd );
+       	window->SetWindowHandle(hwnd);
     }
 
@@ -955,17 +949,14 @@
  LONG rc;
 
-#ifdef DEBUG
-    WriteLog("USER32:  GetWindowLong %X %d\n", hwnd, nIndex);
-#endif
     if(nIndex == GWL_WNDPROC || nIndex == DWL_DLGPROC) {
-     Win32WindowProc *window = Win32WindowProc::FindProc(hwnd);
-     if(window && !(nIndex == DWL_DLGPROC && window->IsWindow() == TRUE)) {
-        return (LONG)window->GetWin32Callback();
-     }
+#ifdef DEBUG
+	WriteLog("USER32:  GetWindowLong %X %d\n", hwnd, nIndex);
+#endif
+     	Win32WindowProc *window = Win32WindowProc::FindProc(hwnd);
+     	if(window && !(nIndex == DWL_DLGPROC && window->IsWindow() == TRUE)) {
+        	return (LONG)window->GetWin32Callback();
+     	}
     }
     rc = O32_GetWindowLong(hwnd, nIndex);
-#ifdef DEBUG
-    WriteLog("USER32:  GetWindowLong returned %X\n", rc);
-#endif
     return(rc);
 }
@@ -2639,5 +2630,5 @@
 BOOL WIN32API PtInRect( const RECT * arg1, POINT  arg2)
 {
-#ifdef DEBUG
+#ifdef DEBUG1
     WriteLog("USER32:  PtInRect\n");
 #endif
Index: trunk/src/user32/wndclass.cpp
===================================================================
--- trunk/src/user32/wndclass.cpp	(revision 131)
+++ trunk/src/user32/wndclass.cpp	(revision 134)
@@ -1,3 +1,3 @@
-/* $Id: wndclass.cpp,v 1.4 1999-06-20 14:02:13 sandervl Exp $ */
+/* $Id: wndclass.cpp,v 1.5 1999-06-20 16:47:38 sandervl Exp $ */
 
 /*
@@ -43,8 +43,34 @@
 WNDPROC_O32 ScrollbarHandler = 0;
 WNDPROC_O32 StaticHandler = 0;
+
+HWND hwndButton = 0;
+HWND hwndListbox = 0;
+HWND hwndEdit = 0;
+HWND hwndCombobox = 0;
+HWND hwndScrollbar = 0;
+HWND hwndMdiClient = 0;
+HWND hwndStatic = 0;
+
+Win32WindowClass *ButtonClass = 0;
+Win32WindowClass *ListboxClass = 0;
+Win32WindowClass *EditClass = 0;
+Win32WindowClass *ComboboxClass = 0;
+Win32WindowClass *MdiClientClass = 0;
+Win32WindowClass *ScrollbarClass = 0;
+Win32WindowClass *StaticClass = 0;
 //******************************************************************************
 //******************************************************************************
 LRESULT WIN32API ButtonCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 {
+  switch(Msg)
+  {
+	case WM_CREATE:
+	case WM_DESTROY:
+	case WM_LBUTTONDOWN:
+	case WM_MBUTTONDOWN:
+	case WM_RBUTTONDOWN:
+		NotifyParent(hwnd, Msg, wParam, lParam);
+		break;
+  }
   return ButtonHandler(hwnd, Msg, wParam, lParam);
 }
@@ -91,34 +117,105 @@
 {
  WNDCLASSA wndclass;
+ HWND hwnd;
 
    if(O32_GetClassInfo(NULL, "BUTTON", &wndclass)) {
-	new Win32WindowClass(ButtonCallback, "BUTTON", hModule);
+	dprintf(("Create BUTTON System class"));
+	ButtonClass = new Win32WindowClass(ButtonCallback, "BUTTON", hModule);
 	ButtonHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
+	hwndButton = O32_CreateWindow("BUTTON", "BUTTON", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+	if(hwndButton == 0) {
+		dprintf(("RegisterSystemClasses failed!!"));
+	}
+	O32_SetClassLong(hwndButton, GCL_WNDPROC, (LONG)ButtonCallback);
    }
    if(O32_GetClassInfo(NULL, "LISTBOX", &wndclass)) {
-	new Win32WindowClass(ListboxCallback, "LISTBOX", hModule);
+	dprintf(("Create LISTBOX System class"));
+	ListboxClass = new Win32WindowClass(ListboxCallback, "LISTBOX", hModule);
 	ListboxHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
+	hwndListbox = O32_CreateWindow("LISTBOX", "LISTBOX", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+	if(hwndListbox == 0) {
+		dprintf(("RegisterSystemClasses failed!!"));
+	}
+	O32_SetClassLong(hwndListbox, GCL_WNDPROC, (LONG)ListboxCallback);
    }
    if(O32_GetClassInfo(NULL, "COMBOBOX", &wndclass)) {
-	new Win32WindowClass(ComboboxCallback, "COMBOBOX", hModule);
+	dprintf(("Create COMBOBOX System class"));
+	ComboboxClass = new Win32WindowClass(ComboboxCallback, "COMBOBOX", hModule);
 	ComboboxHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
+	hwndCombobox = O32_CreateWindow("COMBOBOX", "COMBOBOX", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+	if(hwndCombobox == 0) {
+		dprintf(("RegisterSystemClasses failed!!"));
+	}
+	O32_SetClassLong(hwndCombobox, GCL_WNDPROC, (LONG)ComboboxCallback);
    }
    if(O32_GetClassInfo(NULL, "EDIT", &wndclass)) {
-	new Win32WindowClass(EditCallback, "EDIT", hModule);
+	dprintf(("Create EDIT System class"));
+	EditClass = new Win32WindowClass(EditCallback, "EDIT", hModule);
 	EditHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
+	hwndEdit = O32_CreateWindow("EDIT", "EDIT", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+	if(hwndEdit == 0) {
+		dprintf(("RegisterSystemClasses failed!!"));
+	}
+	O32_SetClassLong(hwndEdit, GCL_WNDPROC, (LONG)EditCallback);
    }
+   //TODO: This doens't work yet!! (need to create a normal window as parent)
    if(O32_GetClassInfo(NULL, "MDICLIENT", &wndclass)) {
-	new Win32WindowClass(MdiClientCallback, "MDICLIENT", hModule);
+	dprintf(("Create MDICLIENT System class"));
+	MdiClientClass = new Win32WindowClass(MdiClientCallback, "MDICLIENT", hModule);
 	MdiClientHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
+	hwndMdiClient = O32_CreateWindow("MDICLIENT", "MDICLIENT", WS_CHILD, 0, 0, 0, 0, hwndListbox, 0, 0, 0);
+	if(hwndMdiClient == 0) {
+		dprintf(("RegisterSystemClasses failed!!"));
+	}
+	O32_SetClassLong(hwndMdiClient, GCL_WNDPROC, (LONG)MdiClientCallback);
    }
    if(O32_GetClassInfo(NULL, "SCROLLBAR", &wndclass)) {
-	new Win32WindowClass(ScrollbarCallback, "SCROLLBAR", hModule);
+	dprintf(("Create SCROLLBAR System class"));
+	ScrollbarClass = new Win32WindowClass(ScrollbarCallback, "SCROLLBAR", hModule);
 	ScrollbarHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
+	hwndScrollbar = O32_CreateWindow("SCROLLBAR", "SCROLLBAR", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+	if(hwndScrollbar == 0) {
+		dprintf(("RegisterSystemClasses failed!!"));
+	}
+	O32_SetClassLong(hwndScrollbar, GCL_WNDPROC, (LONG)ScrollbarCallback);
    }
    if(O32_GetClassInfo(NULL, "STATIC", &wndclass)) {
-	new Win32WindowClass(StaticCallback, "STATIC", hModule);
+	dprintf(("Create STATIC System class"));
+	StaticClass = new Win32WindowClass(StaticCallback, "STATIC", hModule);
 	StaticHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
+	hwndStatic = O32_CreateWindow("STATIC", "STATIC", 0, 0, 0, 0, 0, 0, 0, 0, 0);
+	if(hwndStatic == 0) {
+		dprintf(("RegisterSystemClasses failed!!"));
+	}
+	O32_SetClassLong(hwndStatic, GCL_WNDPROC, (LONG)StaticCallback);
    }
 //TODO: More standard classes in win95/NT4?
+}
+//******************************************************************************
+//******************************************************************************
+void UnregisterSystemClasses()
+{
+   dprintf(("KERNEL32: UnregisterSystemClasses"));
+   if(hwndButton)    O32_DestroyWindow(hwndButton);
+   if(hwndListbox)   O32_DestroyWindow(hwndListbox);
+   if(hwndCombobox)  O32_DestroyWindow(hwndCombobox);
+   if(hwndMdiClient) O32_DestroyWindow(hwndMdiClient);
+   if(hwndEdit)      O32_DestroyWindow(hwndEdit);
+   if(hwndScrollbar) O32_DestroyWindow(hwndScrollbar);
+   if(hwndStatic)    O32_DestroyWindow(hwndStatic);
+   if(ButtonClass)    delete ButtonClass;
+   if(ListboxClass)   delete ListboxClass;
+   if(EditClass)      delete EditClass;
+   if(ComboboxClass)  delete ComboboxClass;
+   if(MdiClientClass) delete MdiClientClass;
+   if(ScrollbarClass) delete ScrollbarClass;
+   if(StaticClass)    delete StaticClass;
+   ButtonClass    = NULL;
+   EditClass      = NULL;
+   ListboxClass   = NULL;
+   ComboboxClass  = NULL;
+   MdiClientClass = NULL;
+   ScrollbarClass = NULL;
+   StaticClass    = NULL;
 }
 //******************************************************************************
@@ -218,15 +315,5 @@
     //These are not supported by Open32
     wc.style &= ~(CS_PARENTDC | CS_CLASSDC);
-  
-//SvL: 18-7-'98 Breaks apps (solitaire, rasmol..)  
-#if 0
-    /* @@@PH 98/06/21 experimental fix for WInhlp32 */
-#ifndef CS_SYNCPAINT
-  #define CS_SYNCPAINT 0x02000000L
-#endif
-  
-    wc.style |= CS_SYNCPAINT;
-#endif  
-  
+   
     wc.lpfnWndProc = (WNDPROC)Win32WindowClass::GetOS2ClassCallback();
 
@@ -708,4 +795,8 @@
  char                  szClass[128];
  Win32WindowClass     *wclass;
+ LRESULT               rc;
+ DWORD                 dwStyle, dwExStyle;
+ HWND                  parentHwnd;
+ Win32WindowProc      *window;
 
 #ifdef DEBUG
@@ -720,23 +811,45 @@
         wclass = Win32WindowClass::FindClass(szClass);
         if(wclass) {
-                //SvL: Correct Open32 key mapping bug
-                if(Msg == WM_KEYDOWN || Msg == WM_KEYUP || Msg == WM_CHAR) {
-//                        dprintf(("WM_KEYDOWN %X %08X\n", wParam, lParam));
-                        lParam = MapOEMToRealKey(wParam, lParam);
-                }
-
-                if(Msg == WM_CREATE) {//Open32 isn't sending WM_NCCREATE messages!!
+		switch(Msg) 
+		{
+		case WM_CREATE://Open32 isn't sending WM_NCCREATE messages!!
+		      	window = Win32WindowProc::FindProc(hwnd, GetCurrentThreadId());
+			if(window) {
+				dprintf(("OS2ToWinCallback (class): New window object!"));
+				window->SetWindowHandle(hwnd);
+    			}
+		
                         if(wclass->GetWinCallback()(hwnd, WM_NCCREATE, 0, lParam) == 0) {
                                 dprintf(("WM_NCCREATE returned FALSE\n"));
                                 return(-1); //don't create window
                         }
-                }
-                if(Msg == WM_ACTIVATE && LOWORD(wParam) != WA_INACTIVE)
-                {//SvL: Bugfix, Open32 is NOT sending this to the window (messes up Solitaire)
-                  HDC hdc = GetDC(hwnd);
-
-                        wclass->GetWinCallback()(hwnd, WM_ERASEBKGND, hdc, 0);
-                        ReleaseDC(hwnd, hdc);
-                }
+			//Send WM_CREATE message before notifying parent
+			rc = wclass->GetWinCallback()(hwnd, Msg, wParam, lParam);
+
+			NotifyParent(hwnd, WM_CREATE, wParam, lParam);
+			return(rc);
+
+		case WM_DESTROY: //nofity parent
+		case WM_LBUTTONDOWN:
+		case WM_MBUTTONDOWN:
+		case WM_RBUTTONDOWN:
+			NotifyParent(hwnd, Msg, wParam, lParam);
+			break;
+
+		case WM_KEYDOWN:
+		case WM_KEYUP:
+		case WM_CHAR:	//SvL: Correct Open32 key mapping bug
+                        lParam = MapOEMToRealKey(wParam, lParam);
+			break;
+		case WM_ACTIVATE:
+                	if(LOWORD(wParam) != WA_INACTIVE)
+                	{//SvL: Bugfix, Open32 is NOT sending this to the window (messes up Solitaire)
+                  	 HDC hdc = GetDC(hwnd);
+
+                        	wclass->GetWinCallback()(hwnd, WM_ERASEBKGND, hdc, 0);
+                        	ReleaseDC(hwnd, hdc);
+                	}
+			break;
+		}
 		return wclass->GetWinCallback()(hwnd, Msg, wParam, lParam);
 	}
Index: trunk/src/user32/wndproc.cpp
===================================================================
--- trunk/src/user32/wndproc.cpp	(revision 131)
+++ trunk/src/user32/wndproc.cpp	(revision 134)
@@ -1,3 +1,3 @@
-/* $Id: wndproc.cpp,v 1.5 1999-06-20 14:02:13 sandervl Exp $ */
+/* $Id: wndproc.cpp,v 1.6 1999-06-20 16:47:39 sandervl Exp $ */
 
 /*
@@ -28,4 +28,34 @@
 #endif
 
+
+void NotifyParent(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+ DWORD   dwStyle, dwExStyle;
+ HWND    hwndParent = GetParent(hwnd);;
+
+   while(hwndParent) {
+	dwStyle   = GetWindowLongA(hwnd, GWL_STYLE);
+	dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
+	//SvL: Taken from Wine
+	if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
+	{
+		hwndParent = GetParent(hwnd);
+		dprintf(("%s Send WM_PARENTNOTIFY from child %x to parent %x", GetMsgText(Msg), hwnd, hwndParent));
+		/* Notify the parent window only */
+		Win32WindowProc *parentwnd = Win32WindowProc::FindProc(hwndParent);
+		if(parentwnd) {
+			if(Msg == WM_CREATE || Msg == WM_DESTROY) {
+				//Todo: Set IdChild!!
+				parentwnd->GetWin32Callback()(hwndParent, WM_PARENTNOTIFY, MAKEWPARAM(Msg, 0), (LPARAM)hwnd );
+			}
+			else	parentwnd->GetWin32Callback()(hwndParent, WM_PARENTNOTIFY, MAKEWPARAM(Msg, 0), lParam );
+		}
+	}
+	if(hwnd == hwndParent) {
+		break;
+	}
+	hwnd = hwndParent;
+   }
+}
 //******************************************************************************
 //******************************************************************************
@@ -67,6 +97,9 @@
 {
  WNDCLASSA wc;
-
-  assert(GetClassInfoA(hinst, lpszClassName, &wc) == TRUE);
+ BOOL rc;
+
+  rc = GetClassInfoA(hinst, lpszClassName, &wc);
+  assert(rc == TRUE);
+
 //  pCallback = Win32WindowClass::GetClassCallback(hinst, (LPSTR)wc.lpszClassName);
   pCallback = Win32WindowClass::GetClassCallback((LPSTR)wc.lpszClassName);
@@ -152,4 +185,20 @@
   }
   dprintf(("Win32WindowProc::FindProc, can't find window %X!\n", hwnd));
+  return(NULL);
+}
+//******************************************************************************
+//Find newly created window
+//******************************************************************************
+Win32WindowProc *Win32WindowProc::FindProc(HWND hwnd, DWORD threadid)
+{
+  Win32WindowProc *window = Win32WindowProc::windows;
+
+  while(window != NULL) {
+        if(window->hwnd == 0 && window->threadid == threadid) {
+                return(window);
+        }
+        window = window->next;
+  }
+  dprintf(("Win32WindowProc::FindProc, can't find window %X %d!\n", hwnd, threadid));
   return(NULL);
 }
@@ -225,5 +274,5 @@
 LRESULT EXPENTRY_O32 WndCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 {
- Win32WindowProc *curwnd = Win32WindowProc::windows;
+ Win32WindowProc *curwnd;
  LRESULT rc;
 
@@ -231,94 +280,63 @@
         return(0);
   }
-  while(curwnd != NULL) {
-        if(curwnd->hwnd == hwnd) {
-                //SvL: Correct Open32 key mapping bug
-                if(Msg == WM_KEYDOWN || Msg == WM_KEYUP || Msg == WM_CHAR) {
-//                        dprintf(("WM_KEYDOWN %X %08X\n", wParam, lParam));
-                        lParam = MapOEMToRealKey(wParam, lParam);
+  
+  curwnd = Win32WindowProc::FindProc(hwnd);
+  if(!curwnd) {
+	curwnd = Win32WindowProc::FindProc(0, GetCurrentThreadId());
+	if(curwnd)	curwnd->SetWindowHandle(hwnd);
+  }
+  if(curwnd != NULL) {
+#ifdef DEBUG
+        WriteLog("***************Message %s for window/dialog %X\n", GetMsgText(Msg), hwnd);
+#endif
+	switch(Msg) 
+	{
+	case WM_KEYDOWN:
+	case WM_KEYUP:
+	case WM_CHAR:
+	        //SvL: Correct Open32 key mapping bug
+                lParam = MapOEMToRealKey(wParam, lParam);
+		break;
+	case WM_CREATE:  //Open32 isn't sending WM_NCCREATE messages!!
+                if(curwnd->pCallback(hwnd, WM_NCCREATE, 0, lParam) == 0) {
+                       dprintf(("WM_NCCREATE returned FALSE\n"));
+                       return(-1); //don't create window
                 }
-#ifdef DEBUG
-                WriteLog("***************Message %s for window/dialog %X\n", GetMsgText(Msg), hwnd);
-#endif
-//              if(Msg == WM_CREATE || Msg == WM_INITDIALOG) {//Open32 isn't sending WM_NCCREATE messages!!
-                if(Msg == WM_CREATE) {//Open32 isn't sending WM_NCCREATE messages!!
-#ifdef DEBUG1
-                        WriteLog("WM_NCCREATE\n");
-#endif
-                        if(curwnd->pCallback(hwnd, WM_NCCREATE, 0, lParam) == 0) {
-                                dprintf(("WM_NCCREATE returned FALSE\n"));
-                                return(-1); //don't create window
-                        }
+	
+		NotifyParent(hwnd, WM_CREATE, wParam, lParam);
 //TODO
 #if 0
-                        if(curwnd->pCallback(hwnd, WM_NCCALCSIZE, 0, lParam) == 0) {
-#ifdef DEBUG1
-                                WriteLog("WM_NCCREATE returned FALSE\n");
-#endif
-                                return(-1); //don't create window
-                        }
-#endif
-#ifdef DEBUG1
-                        WriteLog("WM_NCCREATE, continue window creation\n");
-#endif
-                }
-#if 1
-                if(Msg == WM_ACTIVATE && LOWORD(wParam) != WA_INACTIVE)
-                {//SvL: Bugfix, Open32 is NOT sending this to the window (messes up Solitaire)
-                  HDC hdc = GetDC(hwnd);
-
-                        curwnd->pCallback(hwnd, WM_ERASEBKGND, hdc, 0);
-                        ReleaseDC(hwnd, hdc);
+                if(curwnd->pCallback(hwnd, WM_NCCALCSIZE, 0, lParam) == 0) {
+                        return(-1); //don't create window
                 }
 #endif
-                rc = curwnd->pCallback(hwnd, Msg, wParam, lParam);
-#ifdef DEBUG1
-                WriteLog("***************Message processed rc = %d\n", rc);
-#endif
-                if(Msg == WM_NCDESTROY) {
-                        dprintf(("WM_NCDESTROY received for window/dialog %X\n", curwnd->hwnd));
-                        Win32WindowSubProc::DeleteSubWindow(hwnd); //if present
-                        delete curwnd;
-                }
-                return rc;
+		break;
+
+	case WM_LBUTTONDOWN:
+	case WM_MBUTTONDOWN:
+	case WM_RBUTTONDOWN:
+	case WM_DESTROY: //nofity parent
+		NotifyParent(hwnd, Msg, wParam, lParam);	
+		break;
+
+	case WM_ACTIVATE:
+		if(LOWORD(wParam) != WA_INACTIVE)
+        	{//SvL: Bugfix, Open32 is NOT sending this to the window (messes up Solitaire)
+          	  HDC hdc = GetDC(hwnd);
+
+                 	curwnd->pCallback(hwnd, WM_ERASEBKGND, hdc, 0);
+                 	ReleaseDC(hwnd, hdc);
+        	}
+		break;
+	}
+        rc = curwnd->pCallback(hwnd, Msg, wParam, lParam);
+        if(Msg == WM_NCDESTROY) {
+                dprintf(("WM_NCDESTROY received for window/dialog %X\n", curwnd->hwnd));
+                Win32WindowSubProc::DeleteSubWindow(hwnd); //if present
+                delete curwnd;
         }
-        curwnd = curwnd->next;
-  }
-  //Message for window/dialog that's just been created
-  //TODO: This should be thread safe, right?
-  DWORD threadid = (DWORD)GetCurrentThreadId();
-  curwnd = (Win32WindowProc *)Win32WindowProc::windows;
-  while(curwnd != NULL) {
-        if(curwnd->hwnd == 0 && curwnd->threadid == threadid) {
-#ifdef DEBUG1
-                WriteLog("***************First message %s for window/dialog %X\n", GetMsgText(Msg), hwnd);
-#endif
-                curwnd->SetWindowHandle(hwnd);
-//              if(Msg == WM_CREATE || Msg == WM_INITDIALOG) {//Open32 isn't sending WM_NCCREATE messages!!
-                if(Msg == WM_CREATE) {//Open32 isn't sending WM_NCCREATE messages!!
-#ifdef DEBUG1
-                        WriteLog("WM_NCCREATE\n");
-#endif
-                        if(curwnd->pCallback(hwnd, WM_NCCREATE, 0, lParam) == 0) {
-                                dprintf(("WM_NCCREATE returned FALSE\n"));
-                                return(-1); //don't create window
-                        }
-#ifdef DEBUG1
-                        WriteLog("WM_NCCREATE, continue window creation\n");
-#endif
-                }
-                rc = curwnd->pCallback(hwnd, Msg, wParam, lParam);
-                if(Msg == WM_NCDESTROY) {
-                        dprintf(("WM_NCDESTROY received for window/dialog %X\n", curwnd->hwnd));
-                        Win32WindowSubProc::DeleteSubWindow(hwnd); //if present
-                        delete curwnd;
-                }
-                return rc;
-        }
-        curwnd = curwnd->next;
-  }
-#ifdef DEBUG1
-  WriteLog("Dialog control??\n");
-#endif
+        return rc;
+  }
+
   //Could be a dialog control using a registered class, so check this:
   char                  szClass[128];
