Release 960324

Sun Mar 24 13:13:11 1996  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [include/win.h] [windows/*.c]
	Replaced next, parent, child and owner handles by pointers in WND
	structure. This should improve performance, and should be
	reasonably safe since Microsoft did the same in Win95.

	* [include/wintypes.h] [*/*]
	Redefined HANDLE to be UINT instead of a pointer for Winelib. This
	allows removing a lot of unnecessary casts and NPFMTs.

	* [windows/caret.c]
	Create the caret brush upon CreateCaret(); use the bitmap
	dimensions for the caret.
	Fixed CARET_DisplayCaret() to use PatBlt().

Fri Mar 22 16:00:00 1996  Anand Kumria <akumria@ozemail.com.au>

	* [misc/winsocket.c]
	More sanity checks, fixup some erroneous return codes.

	* [documentation/winsock]
	Description of how compatible the winsock is currently.

Fri Mar 22 13:05:34 1996  Ulrich Schmid  <uschmid@mail.hh.provi.de>

	* [library/winmain.c]
	Set `lpszCmdParam' by concatenating arguments.

	* [loader/module.c]
	WinExec: accept Unix commands, use Wine emulator.

Mon Mar 18 12:16:27 1996  Martin von Loewis <loewis@informatik.hu-berlin.de>

	* [if1632/kernel32.spec][win32/thread.c][include/kernel32.h]
	DeleteCriticalSection, EnterCriticalSection,
 	InitializeCriticalSection, LeaveCriticalSection, TlsAlloc,
 	TlsFree, TlsGetValue, TlsSetValue: new functions.
	CRITICAL_SECTION: new structure.

	* [if1632/kernel32.spec][win32/code_page.c]
	WideCharToMultiByte: new function.

	* [if1632/kernel32.spec][win32/file.c]
	GetFileAttributesA: new function.

	* [if1632/kernel32.spec][misc/main.c]
	GetEnvironmentStringsW, FreeEnvironmentStringsA,
 	FreeEnvironmentStringsW: new functions.
	
	* [if1632/user.spec][win32/cursoricon32.c][win32/Makefile.in]
	cursoricon32.c: new file.
	LoadCursorA, LoadCursorW: modified implementation from LoadCursor
 	to WIN32_*.
	LoadIconA, LoadIconW: modified implementation from LoadIconA32
	to WIN32_*.

	* [include/struct32.h]
	pragma pack inserted.
	CURSORICON32 structures added.

	* [include/winnls.h]
	Constants CP_* and WC_* added.

	* [loader/pe_image.c]
	PE_LoadModule: call PE_InitDLL with hModule rather than wpnt.

Sun Mar 17 16:59:12 1996  Albrecht Kleine  <kleine@ak.sax.de>

	* [misc/commdlg.c]
	Introduced hook function handling in file dialog.
	Removed an unnecessary ShowWindow call in FILEDLG_WMCommand().

Thu Mar 14 10:50:00 1996  Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk>

	* [if1632/gdi32.spec]
	Added GetNearestColor.

	* [if1632/kernel32.spec]
	Added GlobalAddAtomA.

	* [win32/param32.c]
	Added stackframe.h to includes.
	WIN32_GlobalAddAtomA() - new function.
diff --git a/windows/message.c b/windows/message.c
index 8f00ed8..415f39c 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -50,6 +50,7 @@
  */
 static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove )
 {
+    WND *pWnd;
     BOOL eatMsg = FALSE;
     INT hittest;
     static DWORD lastClickTime = 0;
@@ -75,9 +76,10 @@
                                 msg->message, (LPARAM)MAKE_SEGPTR(&hook));
     }
    
-    if ((hittest = WINPOS_WindowFromPoint( msg->pt, &msg->hwnd )) != HTERROR)
+    hittest = WINPOS_WindowFromPoint( msg->pt, &pWnd );
+    msg->hwnd = pWnd->hwndSelf;
+    if (hittest != HTERROR)
     {
-
         /* Send the WM_PARENTNOTIFY message */
 
         if (mouseClick) WIN_SendParentNotify( msg->hwnd, msg->message, 0,
@@ -126,9 +128,7 @@
 	if (dbl_click && (hittest == HTCLIENT))
 	{
 	    /* Check whether window wants the double click message. */
-	    WND * wndPtr = WIN_FindWndPtr( msg->hwnd );
-            if (!wndPtr || !(WIN_CLASS_STYLE(wndPtr) & CS_DBLCLKS))
-                dbl_click = FALSE;
+            dbl_click = (WIN_CLASS_STYLE(pWnd) & CS_DBLCLKS) != 0;
 	}
 
 	if (dbl_click) switch(msg->message)
@@ -576,20 +576,20 @@
        return TRUE;
 #endif  /* CONFIG_IPC */
     
-    if (hwnd == HWND_BROADCAST) {
-      dprintf_msg(stddeb,"PostMessage // HWND_BROADCAST !\n");
-      hwnd = GetTopWindow(GetDesktopWindow());
-      while (hwnd) {
-	if (!(wndPtr = WIN_FindWndPtr(hwnd))) break;
-	if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) {
-	  dprintf_msg(stddeb,"BROADCAST Message to hWnd="NPFMT" m=%04X w=%04X l=%08lX !\n",
-		      hwnd, message, wParam, lParam);
-	  PostMessage(hwnd, message, wParam, lParam);
-	}
-	hwnd = wndPtr->hwndNext;
-      }
-      dprintf_msg(stddeb,"PostMessage // End of HWND_BROADCAST !\n");
-      return TRUE;
+    if (hwnd == HWND_BROADCAST)
+    {
+        dprintf_msg(stddeb,"PostMessage // HWND_BROADCAST !\n");
+        for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next)
+        {
+            if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
+            {
+                dprintf_msg(stddeb,"BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n",
+                            wndPtr->hwndSelf, message, wParam, lParam);
+                PostMessage( wndPtr->hwndSelf, message, wParam, lParam );
+            }
+        }
+        dprintf_msg(stddeb,"PostMessage // End of HWND_BROADCAST !\n");
+        return TRUE;
     }
 
     wndPtr = WIN_FindWndPtr( hwnd );
@@ -641,17 +641,14 @@
     if (hwnd == HWND_BROADCAST)
     {
         dprintf_msg(stddeb,"SendMessage // HWND_BROADCAST !\n");
-        hwnd = GetTopWindow(GetDesktopWindow());
-        while (hwnd)
-	{
-            if (!(wndPtr = WIN_FindWndPtr(hwnd))) break;
+        for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next)
+        {
             if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION)
             {
-                dprintf_msg(stddeb,"BROADCAST Message to hWnd="NPFMT" m=%04X w=%04lX l=%08lX !\n",
-                            hwnd, msg, (DWORD)wParam, lParam);
-                 ret |= SendMessage( hwnd, msg, wParam, lParam );
+                dprintf_msg(stddeb,"BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n",
+                            wndPtr->hwndSelf, msg, (DWORD)wParam, lParam);
+                ret |= SendMessage( wndPtr->hwndSelf, msg, wParam, lParam );
 	    }
-            hwnd = wndPtr->hwndNext;
         }
         dprintf_msg(stddeb,"SendMessage // End of HWND_BROADCAST !\n");
         return TRUE;
@@ -732,7 +729,7 @@
     {
 	if (msg->lParam)
         {
-#ifndef WINELIB32
+#ifndef WINELIB
             HINSTANCE ds = msg->hwnd ? WIN_GetWindowInstance( msg->hwnd )
                                      : (HINSTANCE)CURRENT_DS;
 #endif
@@ -753,7 +750,7 @@
     if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) &&
         (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate)
     {
-	fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd "NPFMT"!\n", 
+	fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", 
 		msg->hwnd);
 	wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
         /* Validate the update region to avoid infinite WM_PAINT loop */
@@ -768,7 +765,7 @@
  */
 WORD RegisterWindowMessage( SEGPTR str )
 {
-    dprintf_msg(stddeb, "RegisterWindowMessage: '"SPFMT"'\n", str );
+    dprintf_msg(stddeb, "RegisterWindowMessage: %08lx\n", (DWORD)str );
     return GlobalAddAtom( str );
 }