Release 980329

Sun Mar 29 15:18:57 1998  Uwe Bonnes <elektron.ikp.physik.tu-darmstadt.de>

	* [msdos/int21.c]
	More verbose Trace messages

Sun Mar 29 15:03:30 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [loader/ne_image.c]
	Terminate relocation chains on 0 offset.

Sun Mar 29 02:35:45 1998  James Juran  <jrj120@psu.edu>

	* [windows/caret.c] [windows/class.c] [windows/clipboard.c]
	Fixed more USER32 ordinal numbers in function documentation.

Sat Mar 28 22:40:23 1997  Andreas Mohr <100.30936@germany.net>

	* [controls/desktop.c]
	Return 1 for WM_NCCREATE in DesktopWndProc.

	* [controls/menu.c]
	Fixed crash when destroying a top popup win that was only created
	but not shown.

	* [ole/typelib.c] [if1632/typelib.spec]
	Implemented OABuildVersion.

	* [windows/win.c]
	Finally fixed ugly bug in GetParent32 that affected window placement:
	Didn't return 0 for windows that have neither WS_POPUP nor
	WS_CHILD set. Now it acts exactly like Windows (at least I hope so ;)

Sat Mar 28 02:26:43 1998  Dimitrie O. Paun  <dimi@mail.cs.toronto.edu>

	* [DEVELOPERS-HINTS] [documentation/debug-msgs]
	Updated documentation on debug messages

	* [include/button.h] [controls/button.c] [include/windows.h]
	[include/combo.h] [controls/combo.c] [controls/commctrl.c]
	[controls/icontitle.c] [controls/listbox.c]	[controls/menu.c]
	[controls/scroll.c] [controls/widgets.c] 
	Changed some 16-bit code to 32-bit code. I am positive this will
	not break anything.

	* [controls/uitools.c] 
	Renamed the prefix of some functions from UITOOLS_ to UITOOLS95_
	to reflect the fact that they implement Win95 look. Maybe we will
	have a UITOOLS31_ in the future. Anyhow, the change is completely
	internal to this file.

	* [*/*.c]
	Changed a lot of [f]printf into appropriate debug messages.

Fri Mar 27 19:56:12 1998  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>
	* [documentation/status/]
	Added directdraw and directsound status.

	* [if1632/thunk.c][ole/*.c][win32/kernel32.c]
	Added some documentation.
	Moved FUNC004 to thunk.c since it seems to be a 16->32 thunk
	(calling conventions and the like still unknown).

Fri Mar 27 09:59:32 1998  Morten Eriksen  <mortene@pvv.org>

	* [loader/resource.c][windows/keyboard.c]
	Implemented CopyAcceleratorTable() and CreateAcceleratorTable().
	
	* [include/compobj.h][ole/compobj.c][relay32/ole32.spec]
	Added implementation of StringFromGUID2(). 

Tue Mar 26 23:12:05 1998  Eric Kohl <ekohl@abo.rhein-zeitung.de>

	* [misc/imagelist.c][relay32/comctl32.spec]
	Implemented new debugging interface.
	Added missing functions (some are empty stubs).
	Changed ordinals in comctl32.spec (now dll version 4.72 comatible).

	* [objects/oembitmaps.c][include/windows.h]
	  [include/bitmaps/*]
	Added missing restore bitmaps for Win95 look.
	Added missing Win95 cursors.

Thu Mar 26 10:18:20 1998  Douglas Ridgway  <ridgway@winehq.com>

	* [programs/view/Makefile.in] [programs/view/view.c]
	Fix compilation, Aldus placeable metafile loading.

	* [graphics/metafiledrv/init.c] [relay32/gdi32.spec] 
	  [objects/metafile.c]
	Implemented various 32 bit versions of regular metafile API.

	* [objects/enhmetafile.c]
	Implemented rendering of a couple of dozen records.

Tue Mar 24 20:06:39 1998  Matthew Becker <mbecker@glasscity.net>

	* [memory/*.c]
	Updated documentation for API manpages.

Mon Mar 23 09:09:00 1998  Alex Korobka <alex@pharm.sunysb.edu>

	* [misc/winsock.c]
	Fixed 32-bit DNS lookup.

Mon Mar 23 23:54:47 1998  Luiz Otavio L. Zorzella  <zorzella@nr.conexware.com>

	* [multimedia/init.c]
	New code for the initialization and gathering of information about
	the MIDI devices, for future use.

Thu Mar 19 00:59:29 1998  Jim Peterson <jspeter@nospam.birch.ee.vt.edu>

	* [windows/win.c]
	Eliminated inaccurate setting of cs->hMenu in
	WIN_CreateWindowEx, along with superfluous SetMenu32 call.

Mon Mar 16 17:40:53 1998  Petter Reinholdtsen <pere@td.org.uit.no>

	* [debugger/dbg.y] [debugger/Makefile.in] [Makefile.in]
	Install wine.sym in $(exec_prefix)/lib and make sure the debugger
	finds it.

Sun Mar 15 22:36:35 1998  Michael Veksler <mveksler@tx.technion.ac.il>

	* [dummy.c] [if1632/gdi.spec]
	Fixed stub declaration of GDI_532, so Hebrew-Word2 kind of works.
diff --git a/loader/resource.c b/loader/resource.c
index 3219d78..24d87f2 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -20,9 +20,9 @@
 #include "task.h"
 #include "module.h"
 #include "resource.h"
-#include "debugstr.h"
 #include "debug.h"
 #include "libres.h"
+#include "winerror.h"
 
 extern WORD WINE_LanguageId;
 
@@ -414,6 +414,7 @@
 HACCEL16 WINAPI LoadAccelerators16(HINSTANCE16 instance, SEGPTR lpTableName)
 {
     HRSRC16	hRsrc;
+    HACCEL16    hAccel;
 
     if (HIWORD(lpTableName))
         TRACE(accel, "%04x '%s'\n",
@@ -422,8 +423,12 @@
         TRACE(accel, "%04x %04x\n",
                        instance, LOWORD(lpTableName) );
 
-    if (!(hRsrc = FindResource16( instance, lpTableName, RT_ACCELERATOR )))
+    if (!(hRsrc = FindResource16( instance, lpTableName, RT_ACCELERATOR ))) {
+      WARN(accel, "couldn't find accelerator table resource\n");
       return 0;
+    }
+
+    TRACE(accel, "returning HACCEL 0x%x\n", hRsrc);
     return LoadResource16(instance,hRsrc);
 }
 
@@ -439,18 +444,26 @@
 HACCEL32 WINAPI LoadAccelerators32W(HINSTANCE32 instance,LPCWSTR lpTableName)
 {
     HRSRC32 hRsrc;
+    HACCEL32 hRetval;
 
     if (HIWORD(lpTableName))
-        TRACE(accel, "%04x '%s'\n",
-                      instance, (char *)( lpTableName ) );
+        TRACE(accel, "%p '%s'\n",
+                      (LPVOID)instance, (char *)( lpTableName ) );
     else
-        TRACE(accel, "%04x %04x\n",
-                       instance, LOWORD(lpTableName) );
+        TRACE(accel, "%p 0x%04x\n",
+                       (LPVOID)instance, LOWORD(lpTableName) );
 
     if (!(hRsrc = FindResource32W( instance, lpTableName, 
-		(LPCWSTR)RT_ACCELERATOR )))
-      return 0;
-    return LoadResource32( instance, hRsrc );
+				   (LPCWSTR)RT_ACCELERATOR ))) {
+      WARN(accel, "couldn't find accelerator table resource\n");
+      hRetval = 0;
+    }
+    else {
+      hRetval = LoadResource32( instance, hRsrc );
+    }
+
+    TRACE(accel, "returning HACCEL 0x%x\n", hRsrc);
+    return hRetval;
 }
 
 HACCEL32 WINAPI LoadAccelerators32A(HINSTANCE32 instance,LPCSTR lpTableName)
@@ -471,25 +484,129 @@
  */
 INT32 WINAPI CopyAcceleratorTable32A(HACCEL32 src, LPACCEL32 dst, INT32 entries)
 {
-  fprintf(stderr,"CopyAcceleratorTable32A: not implemented: %d\n", entries);
-  return 0;
+  return CopyAcceleratorTable32W(src, dst, entries);
 }
 
 /**********************************************************************
  *             CopyAcceleratorTable32W   (USER32.59)
+ *
+ * By mortene@pvv.org 980321
  */
-INT32 WINAPI CopyAcceleratorTable32W(HACCEL32 src, LPACCEL32 dst, INT32 entries)
+INT32 WINAPI CopyAcceleratorTable32W(HACCEL32 src, LPACCEL32 dst,
+				     INT32 entries)
 {
-  fprintf(stderr,"CopyAcceleratorTable32W: not implemented: %d\n", entries);
-  return 0;
+  int i;
+  LPACCEL32 accel = (LPACCEL32)src;
+  BOOL32 done = FALSE;
+
+  /* Do parameter checking to avoid the explosions and the screaming
+     as far as possible. */
+  if((dst && (entries < 1)) || (src == (HACCEL32)NULL)) {
+    WARN(accel, "Application sent invalid parameters (%p %p %d).\n",
+	 (LPVOID)src, (LPVOID)dst, entries);
+    return 0;
+  }
+
+
+  i=0;
+  while(!done) {
+    /* Spit out some debugging information. */
+    TRACE(accel, "accel %d: type 0x%02x, event '%c', IDval 0x%04x.\n",
+	  i, accel[i].fVirt, accel[i].key, accel[i].cmd);
+
+    /* Copy data to the destination structure array (if dst == NULL,
+       we're just supposed to count the number of entries). */
+    if(dst) {
+      memcpy(&dst[i], &accel[i], sizeof(ACCEL32));
+
+      /* Check if we've reached the end of the application supplied
+         accelerator table. */
+      if(i+1 == entries) {
+	/* Turn off the high order bit, just in case. */
+	dst[i].fVirt &= 0x7f;
+	done = TRUE;
+      }
+    }
+
+    /* The highest order bit seems to mark the end of the accelerator
+       resource table. (?) */
+    if((accel[i].fVirt & 0x80) != 0) done = TRUE;
+
+    i++;
+  }
+
+  return i;
+}
+
+/*********************************************************************
+ *                    CreateAcceleratorTable   (USER32.64)
+ *
+ * By mortene@pvv.org 980321
+ */
+HACCEL32 WINAPI CreateAcceleratorTable32A(LPACCEL32 lpaccel, INT32 cEntries)
+{
+  HACCEL32 hAccel;
+
+  /* Do parameter checking just in case someone's trying to be
+     funny. */
+  if(cEntries < 1) {
+    WARN(accel, "Application sent invalid parameters (%p %d).\n",
+	 lpaccel, cEntries);
+    SetLastError(ERROR_INVALID_PARAMETER);
+    return (HACCEL32)NULL;
+  }
+  FIXME(accel, "should check that the accelerator descriptions are valid,"
+	" return NULL and SetLastError() if not.\n");
+
+
+  /* Allocate memory and copy the table. */
+  hAccel = (HACCEL32)HeapAlloc(GetProcessHeap(), 0,
+			       cEntries * sizeof(ACCEL32));
+  TRACE(accel, "handle %p\n", (LPVOID)hAccel);
+  if(!hAccel) {
+    WARN(accel, "Out of memory.\n");
+    SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+    return (HACCEL32)NULL;
+  }
+  memcpy((LPACCEL32)hAccel, lpaccel, cEntries * sizeof(ACCEL32));
+
+  /* Set the end-of-table terminator. */
+  ((LPACCEL32)hAccel)[cEntries-1].fVirt |= 0x80;
+
+  TRACE(accel, "Allocated accelerator handle %x\n", hAccel);
+  return hAccel;
 }
 
 /**********************************************************************
  *             DestroyAcceleratorTable   (USER32.130)
+ *
+ * By mortene@pvv.org 980321
  */
 BOOL32 WINAPI DestroyAcceleratorTable( HACCEL32 handle )
 {
-  fprintf(stderr,"DestroyAcceleratorTable: not implemented\n");
+  FIXME(accel, "stub (handle 0x%x)\n", handle);
+
+
+  /* Weird.. I thought this should work. According to the API
+     specification, DestroyAcceleratorTable() should only be called on
+     HACCEL32's made by CreateAcceleratorTable(), but Microsoft Visual
+     Studio 97 calls this function with a series of different handle
+     values without ever calling CreateAcceleratorTable(). Something
+     is very fishy in Denmark... */
+  /* Update: looks like the calls to this function matches the calls
+     to LoadAccelerators() in M$ Visual Studio, except that the handle
+     values are off by some variable size from the HACCEL's returned
+     from LoadAccelerators(). WTH? */
+  
+  /* Parameter checking to avoid any embarassing situations. */
+/*   if(!handle) { */
+/*     WARN(accel, "Application sent NULL ptr.\n"); */
+/*     SetLastError(ERROR_INVALID_PARAMETER); */
+/*     return FALSE; */
+/*   } */
+  
+/*   HeapFree(GetProcessHeap(), 0, (LPACCEL32)handle); */
+
   return TRUE;
 }
   
@@ -586,9 +703,8 @@
 	fprintf(stderr,"LoadString // and try to obtain string '%s'\n", p + 1);
 #endif
     }
-#if 0
-    TRACE(resource,"'%s' copied !\n", buffer);
-#endif
+
+    TRACE(resource,"'%s' copied !\n", (char *)buffer);
     return i;
 }