Release 960928

Fri Sep 27 14:18:42 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [controls/button.c]
	Fixed focus rectangle size and clipping.

	* [controls/scroll.c]
	Converted to Win32 and added support for scroll page.
	Completed SetScrollInfo() and implemented other Win32 functions.

	* [files/file.c]
	Removed FILE_Read() (use _lread32 instead).

	* [objects/dce.c] [include/dce.h]
	Allocate DCE on the Win32 heap, and use pointers instead of
	handles.
	Implemented Win32 version of DC functions.

	* [windows/painting.c]
	Attempt to make CS_PARENTDC style work again.

Wed Sep 25 23:40:52 1996 Alex Korobka <alex@trantor.pharm.sunysb.edu>

	* [windows/dce.c] [windows/winpos.c]
	Override SaveUnder attribute when painting took place
	in a window below. Force X to raise activated window 
	in seamless mode.

	* [misc/clipboard.c] [windows/event.c]
	Translation between DOS and Unix text formats and several
	other fixes for the sudden selection loss.

	* [windows/message.c]
	Apply "first" and "last" when checking for WM_QUIT in 
        MSG_PeekMessage().

	* [windows/win.c]
	Rearranged DestroyWindow() to fit "Windows Internals"
	description.

	* [windows/win.c] [windows/winpos.c] [windows/nonclient.c]
	Misc. fixes to CBT hook calls.

	* [controls/menu.c] [misc/user.c]
	Fixup resident popup menu window so that it doesn't get
	destroyed by USER_AppExit().

	* [loader/module.c] [loader/task.c] [windows/event.c]
	Process "unsafe" X events outside the scheduler to prevent
	deadlocks.

	* [windows/message.c] [windows/queue.c] [windows/winpos.c]
	Lots of fixes for better Win16 multitasking.

Wed Sep 25 20:36:30 1996  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [include/windows.h]
	Added some missing HOOK defines.

	* [misc/shell.c][if1632/shell32.spec][include/shell.h]
	SHGetFileInfoA stub added (win95 mplayer.exe /play bla.avi).

	* [win32/console.c][include/wincon.h]
	GetConsoleScreenBufferInfo, GetLargestConsoleWindowSize added.

	* [misc/registry.c]
	Some null ptr fixes.

	* [loader/pe_image.c]
	Fixed exported function lookup. (msvcrt20.dll)
	Add debugsyms for entrypoint, exported functions and sections.

	* [multimedia/mmsystem.c]
	MCIOpen: support for element opens (mplayer.exe /play bla.avi).

	* [several]
	Added several missing things/stubs/simple thunks from win32
	to win16 code.

Sat Sep 21 17:27:44 1996  O.Flebbe  <flebbe@science-computing.uni-tuebingen.de>

	* [windows/property.c]
	Fixed debugging of 16 Bit RemoveProp().

	* [debugger/memory.c]
	Added DEBUG_checkmap_bad() for linux.

Thu Sep 19 20:48:31 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [windows/event.c] [windows/hook.c]
	Use EnableHardwareInput() for JournalPlayback hook.

	* [controls/listbox.c]
	Changed handling of LB_GETITEMRECT in empty listboxes.

Thu Sep 19 13:34:35 1996  Slaven Rezic  <eserte@cs.tu-berlin.de>

	* [misc/main.c]
	Fixes to X resources handling.	

Wed Sep 18 00:31:15 1996  Huw D. M. Davies <h.davies1@physics.oxford.ac.uk>

	* [objects/metafile.c] [include/gdi.h] [objects/dc.c]
	Individual handle table created for each metafile. Fixed
 	GlobalReAlloc() bug in MF_AddHandleDC() (was MF_AddHandleInternal).

	* [windows/graphics.c] [objects/dc.c]
	Rectangle() changed to work better with wide pens and PS_NULL.
	Use JoinMiter.

	* [windows/winpos.c]
	Make the whole (non X) window invalid on resize if CS_[VH]REDRAW
 	is set.

	* [windows/nonclient.c]
	AdjustWindowRectEx() should perform calculations even if the
 	window is minimized.

	* [windows/mdi.c]
	Better handling of system button painting. Maximized windows can
 	contain scroll bars. Icons now maximize properly.

	* [windows/defwnd.c] [windows/nonclient.c] [controls/menu.c]
	Improved greying of items in system menu. WM_INITMEMUPOPUP no
 	longer caught in DefWndProc, DEFWND_InitSysMenuPopup moved to
 	menu.c.

Mon Sep 16 21:30:00 1996  Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>

	* [several files]
	Fix missing includes and wrong printing arguments.

	* [controls/listbox.c]
	Don't sort drives in ListBoxDirectory().
	
Sat Sep 14 09:05:47 1996  Petri Tuomola <ptuomola@xs4all.nl>

	* [windows/dialog.c]
	Fixed handling of Shift-TAB in dialogs.

Thu Sep 12 18:31:00 1996  Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk>

	* [if1632/gdi32.spec]
	Added SelectClipRgn - call win16 version.

	* [if1632/user32.spec]
	Added GetAsyncKeyState, GetMenuItemID and GetMenuStringA.

	* [include/wincon.h]
	Added COORD and SMALL_RECT typedefs, moved CONSOLE_SCREEN_BUFFER_INFO
	out of #if 0 protected portion of file.

	* [loader/pe_image.c]
	PE_InitTEB() - Tidy up, bug fix to stack pointer value (Borland
	programs now work better)

	* [win32/console.c]
	Added stub functions for GetConsoleScreenBufferInfo and 
	GetLargestConsoleWindowSize

	* [win32/findfile.c]
	FindFirstFile32A() - removed erroneous strcpy

	* [windows/keyboard.c]
	GetAsyncKeyState() - bug fix - now returns value as per Microsoft
	specification. NB - I still have doubts about some other functions
	in this file.
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 5b060b0..53237a8 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -262,12 +262,34 @@
 }
 
 /**********************************************************************
+ *	    CopyImage32    (USER32.60)
+ *
+ * FIXME: implementation still lacks nearly all features, see LR_*
+ * defines in windows.h
+ */
+HANDLE32 CopyImage32( HANDLE32 hnd, UINT32 type, INT32 desiredx,
+                      INT32 desiredy, UINT32 flags )
+{
+    switch (type)
+    {
+	case IMAGE_BITMAP:
+		return hnd;	/* FIXME ... need to copy here */
+	case IMAGE_ICON:
+		return CopyIcon32(hnd);
+	case IMAGE_CURSOR:
+		return CopyCursor32(hnd);
+    }
+    return 0;
+}
+
+
+/**********************************************************************
  *	    LoadBitmap16    (USER.175)
  */
 HBITMAP16 LoadBitmap16( HINSTANCE16 instance, SEGPTR name )
 {
     HBITMAP16 hbitmap = 0;
-    HDC hdc;
+    HDC32 hdc;
     HRSRC16 hRsrc;
     HGLOBAL16 handle;
     BITMAPINFO *info;
@@ -292,12 +314,12 @@
     if (!(handle = LoadResource16( instance, hRsrc ))) return 0;
 
     info = (BITMAPINFO *)LockResource16( handle );
-    if ((hdc = GetDC(0)) != 0)
+    if ((hdc = GetDC32(0)) != 0)
     {
         char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
         hbitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT,
                                   bits, info, DIB_RGB_COLORS );
-        ReleaseDC( 0, hdc );
+        ReleaseDC32( 0, hdc );
     }
     FreeResource16( handle );
     return hbitmap;
@@ -309,7 +331,7 @@
 HBITMAP32 LoadBitmap32W( HINSTANCE32 instance, LPCWSTR name )
 {
     HBITMAP32 hbitmap = 0;
-    HDC hdc;
+    HDC32 hdc;
     HRSRC32 hRsrc;
     HGLOBAL32 handle;
     BITMAPINFO *info;
@@ -325,12 +347,12 @@
     if (!(handle = LoadResource32( instance, hRsrc ))) return 0;
 
     info = (BITMAPINFO *)LockResource32( handle );
-    if ((hdc = GetDC(0)) != 0)
+    if ((hdc = GetDC32(0)) != 0)
     {
         char *bits = (char *)info + DIB_BitmapInfoSize( info, DIB_RGB_COLORS );
         hbitmap = CreateDIBitmap( hdc, &info->bmiHeader, CBM_INIT,
                                   bits, info, DIB_RGB_COLORS );
-        ReleaseDC( 0, hdc );
+        ReleaseDC32( 0, hdc );
     }
     return hbitmap;
 }
diff --git a/objects/cursoricon.c b/objects/cursoricon.c
index 2b1c67f..180e1ae 100644
--- a/objects/cursoricon.c
+++ b/objects/cursoricon.c
@@ -236,7 +236,7 @@
                                       BOOL fCursor )
 {
     HANDLE hAndBits, hXorBits;
-    HDC hdc;
+    HDC32 hdc;
     int size, sizeAnd, sizeXor;
     POINT16 hotspot = { 0 ,0 };
     BITMAPOBJ *bmpXor, *bmpAnd;
@@ -285,7 +285,7 @@
 
     /* Create the XOR bitmap */
 
-    if (!(hdc = GetDC( 0 )))
+    if (!(hdc = GetDC32( 0 )))
     {
         free( pInfo );
         return 0;
@@ -323,7 +323,7 @@
 
     hAndBits = CreateDIBitmap( hdc, &pInfo->bmiHeader, CBM_INIT,
                                bits, pInfo, DIB_RGB_COLORS );
-    ReleaseDC( 0, hdc );
+    ReleaseDC32( 0, hdc );
 
     /* Now create the CURSORICONINFO structure */
 
@@ -788,7 +788,7 @@
     else
     {
         /* Set the same cursor for all top-level windows */
-        HWND hwnd = GetWindow( GetDesktopWindow(), GW_CHILD );
+        HWND hwnd = GetWindow( GetDesktopWindow32(), GW_CHILD );
         while(hwnd)
         {
             Window win = WIN_GetXWindow( hwnd );
diff --git a/objects/dc.c b/objects/dc.c
index db20ea8..76d925a 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -26,6 +26,8 @@
     0,                      /* flags */
     NULL,                   /* devCaps */
     0,                      /* hMetaFile */
+    0,			    /* hHT */
+    0,			    /* HTLen */
     0,                      /* hClipRgn */
     0,                      /* hVisRgn */
     0,                      /* hGCClipRgn */
@@ -293,7 +295,7 @@
     else val.line_style = LineSolid;
     val.line_width = dc->u.x.pen.width;
     val.cap_style  = CapRound;
-    val.join_style = JoinBevel;
+    val.join_style = JoinMiter;
     XChangeGC( display, dc->u.x.gc, 
 	       GCFunction | GCForeground | GCBackground | GCLineWidth |
 	       GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle, &val );
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 7686405..f196635 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -108,7 +108,7 @@
 static FONTOBJ SystemFont =
 {
     { 0, FONT_MAGIC, 1 },   /* header */
-    { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+    { 12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
       0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, "" }
 };
 
@@ -122,7 +122,7 @@
 static FONTOBJ SystemFixedFont =
 {
     { 0, FONT_MAGIC, 1 },   /* header */
-    { 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+    { 12, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
       0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, "" }
 };
 
diff --git a/objects/metafile.c b/objects/metafile.c
index 170a6d9..3d38d3a 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -2,7 +2,7 @@
  * Metafile functions
  *
  * Copyright  David W. Metcalfe, 1994
- *            Niels de Carpentier, Albrecht Kleine 1996
+ *            Niels de Carpentier, Albrecht Kleine, Huw Davies 1996
  *
  */
 
@@ -17,9 +17,6 @@
 
 #define HTINCR  10      /* handle table allocation size increment */
 
-static HANDLE hHT;      /* handle of the handle table */
-static int HTLen;       /* allocated length of handle table */
-
 /******************************************************************
  *         GetMetafile         GDI.124 By Kenny MacDonald 30 Nov 94
  */
@@ -49,7 +46,7 @@
     return 0;
   }
   
-  if (FILE_Read(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR) {
+  if (_lread32(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR) {
     GlobalFree16(hmf);
     return 0;
   }
@@ -64,7 +61,7 @@
     return 0;
   }
   
-  if (FILE_Read(hFile, (char*)mh + mh->mtHeaderSize * 2, 
+  if (_lread32(hFile, (char*)mh + mh->mtHeaderSize * 2, 
 	        size - mh->mtHeaderSize * 2) == HFILE_ERROR) {
     GlobalFree16(hmf);
     return 0;
@@ -91,7 +88,7 @@
     DC *dc;
     HANDLE handle;
     METAHEADER *mh;
-    int hFile;
+    HFILE hFile;
     
     dprintf_metafile(stddeb,"CreateMetaFile: %s\n", lpFilename);
 
@@ -106,7 +103,14 @@
         GDI_FreeObject(handle);
 	return 0;
     }
-    dc->w.bitsPerPixel    = screenDepth;
+    if (!(dc->w.hHT = GlobalAlloc16(GMEM_MOVEABLE | GMEM_ZEROINIT,
+				    sizeof(HANDLETABLE16) * HTINCR))) {
+	GlobalFree16(dc->w.hMetaFile);
+	GDI_FreeObject(handle);
+	return 0;
+    }
+    dc->w.HTLen = HTINCR;
+    dc->w.bitsPerPixel = screenDepth;
     mh = (METAHEADER *)GlobalLock16(dc->w.hMetaFile);
 
     mh->mtHeaderSize = MFHEADERSIZE / 2;
@@ -122,7 +126,9 @@
 	hFile = _lcreat(lpFilename, 0);
 	if (_lwrite32(hFile, (char *)mh, MFHEADERSIZE) == -1)
 	{
+	    GlobalFree16(dc->w.hHT);
 	    GlobalFree16(dc->w.hMetaFile);
+	    GDI_FreeObject(handle);
 	    return 0;
 	}
 	mh->mtNoParameters = hFile; /* store file descriptor here */
@@ -131,11 +137,6 @@
     else                     /* memory based metafile */
 	mh->mtType = 0;
 
-    /* create the handle table */
-    HTLen = HTINCR;
-    hHT = GlobalAlloc16(GMEM_MOVEABLE | GMEM_ZEROINIT, 
-		      sizeof(HANDLETABLE16) * HTLen);
-    
     GlobalUnlock16(dc->w.hMetaFile);
     dprintf_metafile(stddeb,"CreateMetaFile: returning %04x\n", handle);
     return handle;
@@ -150,7 +151,7 @@
     HMETAFILE16 handle = 0;
     METAHEADER *mh;
     METAHEADER *mh2;
-    int hFile;
+    HFILE hFile;
     
     dprintf_metafile(stddeb,"CopyMetaFile: %s\n", lpFilename);
     
@@ -191,12 +192,13 @@
 {
     BOOL resu=FALSE;
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
-    if (mh)
+    if (mh) {
       if (mh->mtType == 1 || mh->mtType == 0) 
         if (mh->mtHeaderSize == MFHEADERSIZE/sizeof(INT16))
           if (mh->mtVersion == MFVERSION)
             resu=TRUE;
-    GlobalUnlock16(hmf);            
+      GlobalUnlock16(hmf);
+    }
     dprintf_metafile(stddeb,"IsValidMetaFile %x => %d\n",hmf,resu);
     return resu;         
 }
@@ -228,7 +230,9 @@
 
     if (!MF_MetaParam0(dc, META_EOF))
     {
+	GlobalFree16(dc->w.hHT);
 	GlobalFree16(dc->w.hMetaFile);
+	GDI_FreeObject(hdc);
 	return 0;
     }	
 
@@ -238,20 +242,22 @@
 	mh->mtNoParameters = 0;
         if (_llseek(hFile, 0L, 0) == -1)
         {
+	    GlobalFree16(dc->w.hHT);
             GlobalFree16(dc->w.hMetaFile);
+	    GDI_FreeObject(hdc);
             return 0;
         }
         if (_lwrite32(hFile, (char *)mh, MFHEADERSIZE) == -1)
         {
+	    GlobalFree16(dc->w.hHT);
             GlobalFree16(dc->w.hMetaFile);
+	    GDI_FreeObject(hdc);
             return 0;
         }
         _lclose(hFile);
     }
 
-    /* delete the handle table */
-    GlobalFree16(hHT);
-
+    GlobalFree16(dc->w.hHT);
     hmf = dc->w.hMetaFile;
     GlobalUnlock16(hmf);
     GDI_FreeObject(hdc);
@@ -284,6 +290,7 @@
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
     METARECORD *mr;
     HANDLETABLE16 *ht;
+    HGLOBAL16 hHT;
     int offset = 0;
     WORD i;
 
@@ -326,6 +333,7 @@
 {
     METAHEADER *mh = (METAHEADER *)GlobalLock16(hmf);
     METARECORD *mr;
+    HGLOBAL16 hHT;
     SEGPTR ht, spRecord;
     int offset = 0;
   
@@ -848,32 +856,27 @@
 
 
 /******************************************************************
- *         MF_AddHandleInternal
+ *         MF_AddHandleDC
  *
- *    Add a handle to the internal handle table and return the index
+ *    Add a handle to the handle table in the DC, growing table if
+ *    necessary. Return the index
  */
 
-int MF_AddHandleInternal(HANDLE hobj)
+int MF_AddHandleDC(DC *dc, HANDLE hobj)
 {
     int i;
-    HANDLETABLE16 *ht = (HANDLETABLE16 *)GlobalLock16(hHT);
+    HANDLETABLE16 *ht = (HANDLETABLE16 *)GlobalLock16(dc->w.hHT);
 
-    for (i = 0; i < HTLen; i++)
-    {
-	if (*(ht->objectHandle + i) == 0)
-	{
-	    *(ht->objectHandle + i) = hobj;
-	    GlobalUnlock16(hHT);
-	    return i;
-	}
+    if((i = MF_AddHandle(ht, dc->w.HTLen, hobj)) == -1) {
+	GlobalUnlock16(dc->w.hHT);
+	if(!(dc->w.hHT = GlobalReAlloc16(dc->w.hHT, (dc->w.HTLen + HTINCR) *
+	 sizeof(HANDLETABLE16), GMEM_MOVEABLE | GMEM_ZEROINIT)))
+	    return -1;
+	dc->w.HTLen += HTINCR;
+	ht = (HANDLETABLE16 *)GlobalLock16(dc->w.hHT);
+	i = MF_AddHandle(ht, dc->w.HTLen, hobj);
     }
-    GlobalUnlock16(hHT);
-    if (!(hHT = GlobalReAlloc16(hHT, HTINCR, GMEM_MOVEABLE | GMEM_ZEROINIT)))
-	return -1;
-    HTLen += HTINCR;
-    ht = (HANDLETABLE16 *)GlobalLock16(hHT);
-    *(ht->objectHandle + i) = hobj;
-    GlobalUnlock16(hHT);
+    GlobalUnlock16(dc->w.hHT);
     return i;
 }
 
@@ -1036,7 +1039,7 @@
     mr->rdSize = sizeof(METARECORD) / 2;
     mr->rdFunction = META_SELECTOBJECT;
 
-    if ((index = MF_AddHandleInternal(hBrush)) == -1)
+    if ((index = MF_AddHandleDC(dc, hBrush)) == -1)
 	return FALSE;
 
     mh = (METAHEADER *)GlobalLock16(dc->w.hMetaFile);
@@ -1128,7 +1131,7 @@
     mr = (METARECORD *)&buffer;
     mr->rdSize = sizeof(METARECORD) / 2;
     mr->rdFunction = META_SELECTOBJECT;
-    if ((index = MF_AddHandleInternal(hBrush)) == -1)
+    if ((index = MF_AddHandleDC(dc, hBrush)) == -1)
 	return FALSE;
 
     mh = (METAHEADER *)GlobalLock16(dc->w.hMetaFile);
@@ -1165,7 +1168,7 @@
     mr->rdSize = sizeof(METARECORD) / 2;
     mr->rdFunction = META_SELECTOBJECT;
 
-    if ((index = MF_AddHandleInternal(hPen)) == -1)
+    if ((index = MF_AddHandleDC(dc, hPen)) == -1)
 	return FALSE;
 
     mh = (METAHEADER *)GlobalLock16(dc->w.hMetaFile);
@@ -1202,7 +1205,7 @@
     mr->rdSize = sizeof(METARECORD) / 2;
     mr->rdFunction = META_SELECTOBJECT;
 
-    if ((index = MF_AddHandleInternal(hFont)) == -1)
+    if ((index = MF_AddHandleDC(dc, hFont)) == -1)
 	return FALSE;
 
     mh = (METAHEADER *)GlobalLock16(dc->w.hMetaFile);
diff --git a/objects/palette.c b/objects/palette.c
index a4897ba..1682d91 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -387,8 +387,8 @@
 
     if( hPal != STOCK_DEFAULT_PALETTE )
     {
-	HWND hWnd = WindowFromDC( hDC );
-	HWND hActive = GetActiveWindow();
+	HWND32 hWnd = WindowFromDC32( hDC );
+	HWND32 hActive = GetActiveWindow();
 	
 	/* set primary palette if it's related to current active */
 
@@ -414,8 +414,8 @@
     {
 	/* Send palette change notification */
 
-	HWND hWnd;
- 	if( (hWnd = WindowFromDC( hDC )) )
+	HWND32 hWnd;
+ 	if( (hWnd = WindowFromDC32( hDC )) )
             SendMessage16( HWND_BROADCAST, WM_PALETTECHANGED, hWnd, 0L);
     }
     return realized;
@@ -428,7 +428,7 @@
  */
 int UpdateColors( HDC hDC )
 {
-    HWND hWnd = WindowFromDC( hDC );
+    HWND32 hWnd = WindowFromDC32( hDC );
 
     /* Docs say that we have to remap current drawable pixel by pixel
      * but it would take forever given the speed of XGet/PutPixel.
diff --git a/objects/text.c b/objects/text.c
index fbe88bc..3d7eb81 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -224,6 +224,8 @@
 	tabwidth = size.cx * tabstop;
     }
 
+    if (flags & DT_CALCRECT) flags |= DT_NOCLIP;
+
     do
     {
 	prefix_offset = -1;
@@ -268,7 +270,7 @@
 	y += lh;
 	if (strPtr)
 	{
-	    if (!(flags & DT_NOCLIP) && !(flags & DT_CALCRECT))
+	    if (!(flags & DT_NOCLIP))
 	    {
 		if (y > rect->bottom - lh)
 		    break;