Release 0.4.10

Mon Nov 22 13:58:56 1993  David Metcalfe <david@prism.demon.co.uk>

        * [windows/scroll.c]
	Preliminary implementations of ScrollWindow, ScrollDC and
        ScrollWindowEx.

Nov 21, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/listbox.c]
	Optimization of redraw during 'Add' or 'Insert'.

	* [controls/scroll.c]
	Optimization of WM_PAINT during 'thumbtracking'.

	* [controls/button.c]
	Add of beta implement of 'BS_OWNERDRAW'

	* [controls/static.c]
	Style 'SS_ICON' new supported.

	* [misc/message.c]
	Begin of implemantation of MB_XXX styles.

	* [loader/resource.c]
	Function LoadIcon() : now prepare transparency Bitmap mask.
	Function LoadCursor() : now prepare a 'X pixmapcursor'.
	New function SetCursor() : not finished.
	New function ShowCursor() : not finished.
	New function AccessResource() : stub.

	* [obj/dib.c]
	Function DrawIcon(): deugging phase of icon transparency mask.

	* [loader/library.c]
	new file for news functions LoadLibrary() & FreeLibrary().

	* [sysres.dll]
	Resources only 16bits DLL for System Resources, icons, etc...

Sun Nov 14 14:39:06 1993  julliard@di.epfl.ch (Alexandre Julliard)

	* [include/dialog.h] [windows/dialog.c]
	Simplified dialog template parsing.
	Implemented DialogBoxIndirect().

	* [windows/win.c]
	Fixed bug in CreateWindow() when aborting window creation.
	Modified UpdateWindow() to only update visible windows.
	Implemented IsWindow().

Nov 14, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/listbox.c]
	Listbox control window : new messages.

	* [controls/combo.c]
	Combo box control window : new messages.

	* [misc/message.c]
	Moved stub MessageBox() to this new file.
	Implemented of a callback, now MessageBox show a window.

	* [loader/resource.c]
	New function DestroyIcon()
	New function DestroyCursor()
	Filled stub LoadIcon()
	Filled stub LoadCursor()
	Bug fixed in FindResourceByName() : missing lseek().

	* [obj/dib.c]
	New function DrawIcon()

	* [windows/win.c]
	New function CloseWindow()
	New function OpenIcon()
	New function IsIconic()
	New Function FindWindow()

Sun Nov 14 08:27:19 1993  Karl Guenter Wuensch (hz225wu@unidui.uni-duisburg.de)

	* [loader/selector.c]
	Wrote AllocCStoDSAlias() and AllocDStoCSAlias()

Sun Nov 14 08:27:19 1993  Bob Amstadt  (bob at amscons)

	* [loader/selector.c]
	Wrote AllocSelector() and PrestoChangoSelector().  YUK!

Sat Nov 13 13:56:42 1993  Bob Amstadt  (bob at amscons)

	* [loader/resource.c]
	Wrote FindResource(), LoadResource(), LockResource(),
	and FreeResource()

	* [include/segmem.h] [loader/selector.c] [loader/signal.h]
	Changed selector allocation method.

Sun Nov 10 08:27:19 1993  Karl Guenter Wuensch (hz225wu@unidui.uni-duisburg.de)

	* [if1632/callback.c if1632/call.S if1632/user.spec] 
	added Catch (KERNEL.55) and Throw (KERNEL.56)
	
Nov 7, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/scroll.c]
	Scroll bar control window
		Bug resolved : Painting message before scroll visible.

	* [controls/listbox.c]
	Listbox control window
		Destroy cleanup.

	* [controls/combo.c]
	Combo box control window
		Destroy cleanup.

	* [controls/button.c]
		GetCheck Message now return is state.

	* [windows/win.c]
	New function IsWindowVisible()
diff --git a/windows/dialog.c b/windows/dialog.c
index e60b62d..108c964 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -6,10 +6,9 @@
 
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
 
-#include <stdlib.h>
-
 #include "windows.h"
 #include "dialog.h"
+#include "prototypes.h"
 #include "win.h"
 
 
@@ -29,7 +28,7 @@
     
       /* Calculate the dialog base units */
 
-    if (!(hdc = GetDC( 0 ))) return FALSE;
+    if (!(hdc = GetDC(GetDesktopWindow()))) return FALSE;
     GetTextMetrics( hdc, &tm );
     ReleaseDC( 0, hdc );
     xBaseUnit = tm.tmAveCharWidth;
@@ -79,15 +78,17 @@
 /***********************************************************************
  *           DIALOG_ParseTemplate
  *
- * Fill a DLGTEMPLATE structure from the dialog template.
+ * Fill a DLGTEMPLATE structure from the dialog template, and return
+ * a pointer to the first control.
  */
-static void DIALOG_ParseTemplate( LPCSTR template, DLGTEMPLATE * result )
+static DLGCONTROLHEADER * DIALOG_ParseTemplate( LPCSTR template,
+					        DLGTEMPLATE * result )
 {
-    int i;
     unsigned char * p = (unsigned char *)template;
  
     result->header = (DLGTEMPLATEHEADER *)p;
     p += 13;
+
     result->menuName = p;
     if (*p == 0xff) p += 3;
     else p += strlen(p) + 1;
@@ -104,18 +105,8 @@
 	result->pointSize = *(WORD *)p;	p += sizeof(WORD);
 	result->faceName = p;           p += strlen(p) + 1;
     }
-    result->controls = NULL;
-    if (!result->header->nbItems) return;
-    result->controls = (DLGCONTROL *) malloc( result->header->nbItems * sizeof(DLGCONTROL) );
-    if (!result->controls) return;
 
-    for (i = 0; i < result->header->nbItems; i++)
-    {
-	result->controls[i].header = (DLGCONTROLHEADER *)p;
-	p = (char *)DIALOG_GetControl( result->controls[i].header,
-				      &result->controls[i].class,
-				      &result->controls[i].text );	
-    }
+    return (DLGCONTROLHEADER *)p;
 }
 
 
@@ -125,9 +116,6 @@
 #ifdef DEBUG_DIALOG
 static void DIALOG_DisplayTemplate( DLGTEMPLATE * result )
 {
-    int i;
-    DLGCONTROL * ctrl = result->controls;
-    
     printf( "DIALOG %d, %d, %d, %d\n", result->header->x, result->header->y,
 	    result->header->cx, result->header->cy );
     printf( " STYLE %08x\n", result->header->style );
@@ -138,18 +126,6 @@
     else printf( " MENU '%s'\n", result->menuName );
     if (result->header->style & DS_SETFONT)
 	printf( " FONT %d,'%s'\n", result->pointSize, result->faceName );
-
-    printf( " BEGIN\n" );
-
-    for (i = 0; i < result->header->nbItems; i++, ctrl++)
-    {
-	printf( "   %s '%s' %d, %d, %d, %d, %d, %08x\n",
-	        ctrl->class, ctrl->text, ctrl->header->id,
-	        ctrl->header->x, ctrl->header->y, ctrl->header->cx,
-	        ctrl->header->cy, ctrl->header->style );
-    }
-    
-    printf( " END\n" );
 }
 #endif  /* DEBUG_DIALOG */
 
@@ -187,7 +163,7 @@
     else hwnd = CreateDialogIndirectParam(hInst, data, owner, dlgProc, param);
     FreeResource( hmem );
 #else
-    hmem = RSC_LoadResource( hInst, dlgTemplate, 0x8005, &size );
+    hmem = RSC_LoadResource( hInst, dlgTemplate, NE_RSCTYPE_DIALOG, &size );
     data = (LPCSTR) GlobalLock( hmem );
     hwnd = CreateDialogIndirectParam( hInst, data, owner, dlgProc, param );
     GlobalFree( hmem );
@@ -212,31 +188,39 @@
 HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate,
 			        HWND owner, FARPROC dlgProc, LPARAM param )
 {
-    HMENU hMenu = 0;
+    HMENU hMenu;
     HFONT hFont = 0;
     HWND hwnd;
     WND * wndPtr;
+    int i;
     DLGTEMPLATE template;
+    DLGCONTROLHEADER * header;
     DIALOGINFO * dlgInfo;
     WORD xUnit = xBaseUnit;
     WORD yUnit = yBaseUnit;
-    
-    if (!dlgTemplate) return 0;
-    DIALOG_ParseTemplate( dlgTemplate, &template );
 
+      /* Parse dialog template */
+
+    if (!dlgTemplate) return 0;
+    header = DIALOG_ParseTemplate( dlgTemplate, &template );
 #ifdef DEBUG_DIALOG
     DIALOG_DisplayTemplate( &template );
 #endif    
 
       /* Load menu */
 
-    if (template.menuName[0])
+    switch (template.menuName[0])
     {
-	if (template.menuName[0] != 0xff) 
-	    hMenu = LoadMenu( hInst, template.menuName );
-	else
-	    hMenu = LoadMenu( hInst, MAKEINTRESOURCE( template.menuName[1] +
+      case 0x00:
+	  hMenu = 0;
+	  break;
+      case 0xff:
+	  hMenu = LoadMenu( hInst, MAKEINTRESOURCE( template.menuName[1] +
 						   256*template.menuName[2] ));
+	  break;
+      default:
+	  hMenu = LoadMenu( hInst, template.menuName );
+	  break;
     }
 
       /* Create custom font if needed */
@@ -252,7 +236,7 @@
 	    HFONT oldFont;
 	    HDC hdc;
 
-	    hdc = GetDC( 0 );
+	    hdc = GetDC(GetDesktopWindow());
 	    oldFont = SelectObject( hdc, hFont );
 	    GetTextMetrics( hdc, &tm );
 	    SelectObject( hdc, oldFont );
@@ -261,11 +245,11 @@
 	    yUnit = tm.tmHeight;
 	}
     }
-
+    
       /* Create dialog main window */
 
     hwnd = CreateWindow( template.className, template.caption,
-			 template.header->style & ~WS_VISIBLE,
+			 template.header->style,
 			 template.header->x * xUnit / 4,
 			 template.header->y * yUnit / 8,
 			 template.header->cx * xUnit / 4,
@@ -276,27 +260,42 @@
     {
 	if (hFont) DeleteObject( hFont );
 	if (hMenu) DestroyMenu( hMenu );
-	if (template.controls) free( template.controls );
 	return 0;
     }
 
       /* Create control windows */
 
-    if (hwnd && template.header->nbItems)
+#ifdef DEBUG_DIALOG
+    printf( " BEGIN\n" );
+#endif	
+
+    for (i = 0; i < template.header->nbItems; i++)
     {
-	int i;
-	DLGCONTROL * ctrl = template.controls;
-	for (i = 0; i < template.header->nbItems; i++, ctrl++)
-	{
-	    CreateWindowEx( WS_EX_NOPARENTNOTIFY, 
-			    ctrl->class, ctrl->text, ctrl->header->style,
-			    ctrl->header->x * xUnit / 4,
-			    ctrl->header->y * yUnit / 8,
-			    ctrl->header->cx * xUnit / 4,
-			    ctrl->header->cy * yUnit / 8,
-			    hwnd, ctrl->header->id, hInst, NULL );
-	}
-    }
+	DLGCONTROLHEADER * next_header;
+	LPSTR class, text;
+	next_header = DIALOG_GetControl( header, &class, &text );
+
+#ifdef DEBUG_DIALOG
+	printf( "   %s '%s' %d, %d, %d, %d, %d, %08x\n",
+	        class, text, header->id, header->x, header->y, header->cx,
+	        header->cy, header->style );
+#endif
+	if ((strcmp(class, "STATIC") == 0) & ((header->style & SS_ICON) == SS_ICON)) {
+	    header->cx = 32;
+	    header->cy = 32;
+	    }
+	header->style |= WS_CHILD;
+	CreateWindowEx( WS_EX_NOPARENTNOTIFY, 
+		        class, text, header->style,
+		        header->x * xUnit / 4, header->y * yUnit / 8,
+		        header->cx * xUnit / 4, header->cy * yUnit / 8,
+		        hwnd, header->id, hInst, NULL );
+	header = next_header;
+    }    
+
+#ifdef DEBUG_DIALOG
+    printf( " END\n" );
+#endif	
     
       /* Initialise dialog extra data */
 
@@ -318,35 +317,24 @@
     if (SendMessage( hwnd, WM_INITDIALOG, dlgInfo->hwndFocus, param ))
 	SetFocus( dlgInfo->hwndFocus );
 
-      /* Display dialog */
-
-    if (template.header->style & WS_VISIBLE) ShowWindow( hwnd, SW_SHOW );
-    
-    if (template.controls) free( template.controls );
     return hwnd;
 }
 
 
 /***********************************************************************
- *           DialogBox   (USER.87)
+ *           DIALOG_DoDialogBox
  */
-int DialogBox( HINSTANCE hInst, LPCSTR dlgTemplate,
-	       HWND owner, FARPROC dlgProc )
+static int DIALOG_DoDialogBox( HWND hwnd )
 {
-    HWND hwnd;
     WND * wndPtr;
     DIALOGINFO * dlgInfo;
     MSG msg;
     int retval;
 
-#ifdef DEBUG_DIALOG
-    printf( "DialogBox: %d,'%s',%d,%p\n", hInst, dlgTemplate, owner, dlgProc );
-#endif
-
-    hwnd = CreateDialog( hInst, dlgTemplate, owner, dlgProc );
-    if (!hwnd) return -1;
-    wndPtr = WIN_FindWndPtr( hwnd );
+    if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return -1;
     dlgInfo = (DIALOGINFO *)wndPtr->wExtra;
+    ShowWindow( hwnd, SW_SHOW );
+
     while (GetMessage (&msg, 0, 0, 0))
     {
 	if (!IsDialogMessage( hwnd, &msg))
@@ -363,6 +351,61 @@
 
 
 /***********************************************************************
+ *           DialogBox   (USER.87)
+ */
+int DialogBox( HINSTANCE hInst, LPCSTR dlgTemplate,
+	       HWND owner, FARPROC dlgProc )
+{
+    return DialogBoxParam( hInst, dlgTemplate, owner, dlgProc, 0 );
+}
+
+
+/***********************************************************************
+ *           DialogBoxParam   (USER.239)
+ */
+int DialogBoxParam( HINSTANCE hInst, LPCSTR dlgTemplate,
+		    HWND owner, FARPROC dlgProc, LPARAM param )
+{
+    HWND hwnd;
+    
+#ifdef DEBUG_DIALOG
+    printf( "DialogBoxParam: %d,'%s',%d,%p,%d\n",
+	    hInst, dlgTemplate, owner, dlgProc, param );
+#endif
+    hwnd = CreateDialogParam( hInst, dlgTemplate, owner, dlgProc, param );
+    if (hwnd) return DIALOG_DoDialogBox( hwnd );
+    return -1;
+}
+
+
+/***********************************************************************
+ *           DialogBoxIndirect   (USER.218)
+ */
+int DialogBoxIndirect( HINSTANCE hInst, HANDLE dlgTemplate,
+		       HWND owner, FARPROC dlgProc )
+{
+    return DialogBoxIndirectParam( hInst, dlgTemplate, owner, dlgProc, 0 );
+}
+
+
+/***********************************************************************
+ *           DialogBoxIndirectParam   (USER.240)
+ */
+int DialogBoxIndirectParam( HINSTANCE hInst, HANDLE dlgTemplate,
+			    HWND owner, FARPROC dlgProc, LPARAM param )
+{
+    HWND hwnd;
+    LPCSTR ptr;
+
+    if (!(ptr = GlobalLock( dlgTemplate ))) return -1;
+    hwnd = CreateDialogIndirectParam( hInst, ptr, owner, dlgProc, param );
+    GlobalUnlock( dlgTemplate );
+    if (hwnd) return DIALOG_DoDialogBox( hwnd );
+    return -1;
+}
+
+
+/***********************************************************************
  *           EndDialog   (USER.88)
  */
 void EndDialog( HWND hwnd, short retval )