Release 960606

Wed Jun  5 20:13:54 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [controls/button.c] [controls/listbox.c]
	Fixed wParam of WM_DRAWITEM message.

	* [if1632/Makefile.in] [loader/builtin.c]
	Remove WPROCS32 DLL, as the relay code can call Wine routines
	directly.

	* [loader/module.c] [loader/ne_image.c]
	Fixed initial stack layout for self-loading modules.

	* [tools/build.c]
	Fixed data segment building for Win16 modules.

	* [windows/defdlg.c]
	Implemented Win32 versions of DefDlgProc().

	* [windows/dialog.c]
	Merged Win16 and Win32 dialog code.
	Added support for control extra data in dialog item template.

	* [windows/win.c]
	Unified Win16 and Win32 versions of CreateWindow().
	Implemented Win32 version of GetWindowLong().

	* [windows/winproc.c]
	Changed the implementation of window procedures, so that 16-bit
	winprocs are valid segmented pointers.

Sun Jun  2 16:39:46 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [misc/registry.c]
	Fixed another bug in the w95 loader. Quietened some debug output.

Sun Jun  2 10:00:22 1996  Ulrich Schmid  <uschmid@mail.hh.provi.de>

	* [windows/winproc.c]
	Bug fix: WM_PARENTNOTIFY: don't fall through to WM_SETTEXT.

Sat Jun  1 12:37:22 1996  Tristan Tarrant <tst@sthinc.demon.co.uk>

	* [resources/TODO] [resources/sysres_It.rc]
	Updated font dialog box.

Thu May 30 21:05:19 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [include/commdlg.h] [misc/commdlg.c]
	ChooseFont() and ChooseColor(): 
	Bugfixes and added more support for some CF_* and CC_* flags: 
	dialog templates and font size control.
	Bugfix in structure definition of CHOOSECOLOR definition.

	* [ipc/dde_proc.c] [windows/event.c]
	Replaced SendMessage with SendMessage16 and added inclusion of
 	dde_proc.h for error-free compilation of ipc module.

Thu May 30 19:00:00 1996  Alex Korobka <alex@phm30.pharm.sunysb.edu>

	* [windows/scroll.c]
	Made ScrollDC to save/restore current clipping region.

	* [misc/clipboard.c] [windows/event.c]
	Implemented most of the previously missing features (not tested), 
	improved text pasting from/to X. 

	* [if1632/user.spec] [if1632/gdi.spec] [objects/dc.c]
	  [objects/gdiobj.c] [objects/clipping.c] [windows/dce.c]
	  [windows/winpos.c] [windows/painting.c]
	Updated DCE code, implemented dynamic invalidation of owned DCs.
	This fixes a lot of problems with scrolling in WinWord. Not
	sure about the effect on -desktop.

Wed May 29 23:35:44 1996  Jukka Iivonen <iivonen@cc.helsinki.fi>

	* [win32/time.c] [if1632/kernel32.spec]
	Added SetSystemTime and SetTimeZoneInformation.

	* [if1632/kernel32.spec]
	Added lstrcat, lstrcatA, lstrcmp, lstrcmpA, lstrcpy, lstrlen.

	* [include/windows.h]
	Added SYSTEM_POWER_STATUS structure and prototypes for
	GetSystemPowerStatus, SetSystemPowerState, SetSystemTime.

	* [include/kernel32.h]
	Added a prototype for SetTimeZoneInformation.

	* [win32/environment.c] [if1632/kernel32.spec]
	Added GetSystemPowerStatus and SetSystemPowerState stubs.
diff --git a/windows/defdlg.c b/windows/defdlg.c
index 39e77e0..9379e07 100644
--- a/windows/defdlg.c
+++ b/windows/defdlg.c
@@ -1,16 +1,15 @@
 /*
  * Default dialog procedure
  *
- * Copyright 1993 Alexandre Julliard
+ * Copyright 1993, 1996 Alexandre Julliard
  *
  */
 
 #include "windows.h"
 #include "dialog.h"
 #include "win.h"
-#include "stddebug.h"
-/* #define DEBUG_DIALOG */
-#include "debug.h"
+#include "winproc.h"
+
 
 /***********************************************************************
  *           DEFDLG_SetFocus
@@ -110,37 +109,22 @@
 
 
 /***********************************************************************
- *           DefDlgProc   (USER.308)
+ *           DEFDLG_Proc
+ *
+ * Implementation of DefDlgProc(). Only handle messages that need special
+ * handling for dialogs.
  */
-LRESULT DefDlgProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
+static LRESULT DEFDLG_Proc( HWND32 hwnd, UINT32 msg, WPARAM32 wParam,
+                            LPARAM lParam, DIALOGINFO *dlgInfo )
 {
-    DIALOGINFO * dlgInfo;
-    BOOL result = FALSE;
-    WND * wndPtr = WIN_FindWndPtr( hwnd );
-    
-    if (!wndPtr) return 0;
-    dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
-
-    dlgInfo->msgResult = 0;
-    if (dlgInfo->dlgProc)
-    {
-	  /* Call dialog procedure */
-	result = (BOOL)CallWindowProc16( dlgInfo->dlgProc, hwnd, 
-                                         msg, wParam, lParam );
-
-	  /* Check if window destroyed by dialog procedure */
-	wndPtr = WIN_FindWndPtr( hwnd );
-	if (!wndPtr) return result;
-    }
-    
-    if (!result) switch(msg)
+    switch(msg)
     {
 	case WM_INITDIALOG:
-	    break;
+	    return 0;
 
         case WM_ERASEBKGND:
 	    FillWindow( hwnd, hwnd, (HDC)wParam, (HBRUSH)CTLCOLOR_DLG );
-	    return TRUE;
+	    return 1;
 
 	case WM_NCDESTROY:
 
@@ -166,28 +150,34 @@
 		dlgInfo->hMenu = 0;
 	    }
 
+            /* Delete window procedure */
+            if (dlgInfo->dlgProc)
+            {
+                WINPROC_FreeWinProc( dlgInfo->dlgProc );
+                dlgInfo->dlgProc = 0;
+            }
+
 	      /* Window clean-up */
-	    DefWindowProc16( hwnd, msg, wParam, lParam );
-	    break;
+	    return DefWindowProc32A( hwnd, msg, wParam, lParam );
 
 	case WM_SHOWWINDOW:
 	    if (!wParam) DEFDLG_SaveFocus( hwnd, dlgInfo );
-	    return DefWindowProc16( hwnd, msg, wParam, lParam );
+	    return DefWindowProc32A( hwnd, msg, wParam, lParam );
 
 	case WM_ACTIVATE:
 	    if (wParam) DEFDLG_RestoreFocus( hwnd, dlgInfo );
 	    else DEFDLG_SaveFocus( hwnd, dlgInfo );
-	    break;
+	    return 0;
 
 	case WM_SETFOCUS:
 	    DEFDLG_RestoreFocus( hwnd, dlgInfo );
-	    break;
+	    return 0;
 
         case DM_SETDEFID:
-            if (dlgInfo->fEnd) return TRUE;
+            if (dlgInfo->fEnd) return 1;
             DEFDLG_SetDefButton( hwnd, dlgInfo,
                                  wParam ? GetDlgItem( hwnd, wParam ) : 0 );
-            return TRUE;
+            return 1;
 
         case DM_GETDEFID:
             if (dlgInfo->fEnd || !dlgInfo->msgResult) return 0;
@@ -207,16 +197,142 @@
                 if (hwndDest) DEFDLG_SetFocus( hwnd, hwndDest );
                 DEFDLG_SetDefButton( hwnd, dlgInfo, hwndDest );
             }
-            break;
+            return 0;
 
         case WM_CLOSE:
             EndDialog( hwnd, TRUE );
             DestroyWindow( hwnd );
             return 0;
+    }
+    return 0;
+}
+
+
+/***********************************************************************
+ *           DefDlgProc16   (USER.308)
+ */
+LRESULT DefDlgProc16( HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam )
+{
+    DIALOGINFO * dlgInfo;
+    BOOL16 result = FALSE;
+    WND * wndPtr = WIN_FindWndPtr( hwnd );
+    
+    if (!wndPtr) return 0;
+    dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
+
+    dlgInfo->msgResult = 0;
+    if (dlgInfo->dlgProc)
+    {
+	  /* Call dialog procedure */
+	result = (BOOL16)CallWindowProc16( (WNDPROC16)dlgInfo->dlgProc, hwnd, 
+                                           msg, wParam, lParam );
+
+        /* Check if window was destroyed by dialog procedure */
+        if (result || !IsWindow( hwnd )) return result;
+    }
+    
+    switch(msg)
+    {
+	case WM_INITDIALOG:
+        case WM_ERASEBKGND:
+	case WM_NCDESTROY:
+	case WM_SHOWWINDOW:
+	case WM_ACTIVATE:
+	case WM_SETFOCUS:
+        case DM_SETDEFID:
+        case DM_GETDEFID:
+	case WM_NEXTDLGCTL:
+        case WM_CLOSE:
+            return DEFDLG_Proc( (HWND32)hwnd, msg, (WPARAM32)wParam,
+                                lParam, dlgInfo );
 
 	default:
 	    return DefWindowProc16( hwnd, msg, wParam, lParam );
     }
-        
-    return result;
+}
+
+
+/***********************************************************************
+ *           DefDlgProc32A   (USER32.119)
+ */
+LRESULT DefDlgProc32A( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam)
+{
+    DIALOGINFO * dlgInfo;
+    BOOL16 result = FALSE;
+    WND * wndPtr = WIN_FindWndPtr( hwnd );
+    
+    if (!wndPtr) return 0;
+    dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
+
+    dlgInfo->msgResult = 0;
+    if (dlgInfo->dlgProc)
+    {
+	  /* Call dialog procedure */
+	result = (BOOL16)CallWindowProc32A( (WNDPROC32)dlgInfo->dlgProc, hwnd, 
+                                            msg, wParam, lParam );
+
+        /* Check if window was destroyed by dialog procedure */
+        if (result || !IsWindow( hwnd )) return result;
+    }
+    
+    switch(msg)
+    {
+	case WM_INITDIALOG:
+        case WM_ERASEBKGND:
+	case WM_NCDESTROY:
+	case WM_SHOWWINDOW:
+	case WM_ACTIVATE:
+	case WM_SETFOCUS:
+        case DM_SETDEFID:
+        case DM_GETDEFID:
+	case WM_NEXTDLGCTL:
+        case WM_CLOSE:
+            return DEFDLG_Proc( hwnd, msg, wParam, lParam, dlgInfo );
+
+	default:
+	    return DefWindowProc32A( hwnd, msg, wParam, lParam );
+    }
+}
+
+
+/***********************************************************************
+ *           DefDlgProc32W   (USER32.120)
+ */
+LRESULT DefDlgProc32W( HWND32 hwnd, UINT32 msg, WPARAM32 wParam, LPARAM lParam)
+{
+    DIALOGINFO * dlgInfo;
+    BOOL16 result = FALSE;
+    WND * wndPtr = WIN_FindWndPtr( hwnd );
+    
+    if (!wndPtr) return 0;
+    dlgInfo = (DIALOGINFO *)&wndPtr->wExtra;
+
+    dlgInfo->msgResult = 0;
+    if (dlgInfo->dlgProc)
+    {
+	  /* Call dialog procedure */
+	result = (BOOL16)CallWindowProc32W( (WNDPROC32)dlgInfo->dlgProc, hwnd, 
+                                            msg, wParam, lParam );
+
+        /* Check if window was destroyed by dialog procedure */
+        if (result || !IsWindow( hwnd )) return result;
+    }
+    
+    switch(msg)
+    {
+	case WM_INITDIALOG:
+        case WM_ERASEBKGND:
+	case WM_NCDESTROY:
+	case WM_SHOWWINDOW:
+	case WM_ACTIVATE:
+	case WM_SETFOCUS:
+        case DM_SETDEFID:
+        case DM_GETDEFID:
+	case WM_NEXTDLGCTL:
+        case WM_CLOSE:
+            return DEFDLG_Proc( hwnd, msg, wParam, lParam, dlgInfo );
+
+	default:
+	    return DefWindowProc32W( hwnd, msg, wParam, lParam );
+    }
 }