My first patch, so a deep check is welcome
Change log:
- Remove W->A call from WineHelpA/W
- This patch is dedicated to dimi that guided me
Hatky.
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Index: windows/winhelp.c
===================================================================
RCS file: /home/wine/wine/windows/winhelp.c,v
retrieving revision 1.29
diff -u -r1.29 winhelp.c
--- windows/winhelp.c 22 Nov 2002 04:47:10 -0000 1.29
+++ windows/winhelp.c 5 Sep 2003 19:39:03 -0000
@@ -32,6 +32,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
+#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(win);
@@ -44,7 +45,7 @@
*
* So we use (for now) the simple protocol:
* 1/ it's based on copy data
- * 2/ we tag the message with a magic number, to make it a bit more robust
+ * 2/ we tag the message with a magic number, to make it a bit more robust
* (even if it's not 100% safe)
* 3/ data structure (WINHELP) has the same layout that the one used on Win95.
* This doesn't bring much, except not going to far away from real
@@ -64,7 +65,7 @@
} WINHELP;
/* magic number for this message:
- * aide means help is French ;-)
+ * aide means help is French ;-)
* SOS means ???
*/
#define WINHELP_MAGIC 0xA1DE505
@@ -72,30 +73,55 @@
/**********************************************************************
* WinHelpA (USER32.@)
*/
-BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand, ULONG_PTR dwData )
+BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT uCommand, ULONG_PTR dwData )
{
+ INT len;
+ LPWSTR file;
+ BOOL ret = FALSE;
+
+ // should dwData be converted too in case it's a string?
+
+ if (!lpHelpFile) return WinHelpW( hWnd, NULL, uCommand, dwData );
+
+ len = MultiByteToWideChar( CP_ACP, 0, lpHelpFile, -1, NULL, 0 );
+ if ((file = HeapAlloc( GetProcessHeap(), 0, len )))
+ {
+ MultiByteToWideChar( CP_ACP, 0, lpHelpFile, -1, file, len );
+ ret = WinHelpW( hWnd, file, uCommand, dwData );
+ HeapFree( GetProcessHeap(), 0, file );
+ }
+ return ret;
+}
+
+
+/**********************************************************************
+ * WinHelpW (USER32.@)
+ */
+BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR lpHelpFile, UINT uCommand, ULONG_PTR dwData )
+{
+ static const WCHAR clsName[]= { 'M', 'S', '_', 'W', 'I', 'N', 'H', 'E', 'L', 'P', 0 };
COPYDATASTRUCT cds;
HWND hDest;
int size, dsize, nlen;
WINHELP* lpwh;
- hDest = FindWindowA("MS_WINHELP", NULL);
- if (!hDest)
+ hDest = FindWindowW(clsName, NULL);
+ if (!hDest)
{
- if (wCommand == HELP_QUIT) return TRUE;
- if (WinExec("winhelp.exe -x", SW_SHOWNORMAL) < 32)
+ if (uCommand == HELP_QUIT) return TRUE;
+ if (WinExec("winhelp.exe -x", SW_SHOWNORMAL) < 32)
{
ERR("can't start winhelp.exe -x ?\n");
return FALSE;
}
- if (!(hDest = FindWindowA("MS_WINHELP", NULL)))
+ if (!(hDest = FindWindowW(clsName, NULL)))
{
FIXME("Did not find a MS_WINHELP Window\n");
return FALSE;
}
}
- switch (wCommand)
+ switch (uCommand)
{
case HELP_CONTEXT:
case HELP_SETCONTENTS:
@@ -119,11 +145,11 @@
dsize = ((LPHELPWININFOA)dwData)->wStructSize;
break;
default:
- FIXME("Unknown help command %d\n", wCommand);
+ FIXME("Unknown help command %d\n", uCommand);
return FALSE;
}
if (lpHelpFile)
- nlen = strlen(lpHelpFile) + 1;
+ nlen = strlenW(lpHelpFile) + 1;
else
nlen = 0;
size = sizeof(WINHELP) + nlen + dsize;
@@ -136,45 +162,23 @@
cds.lpData = (void*)lpwh;
lpwh->size = size;
- lpwh->command = wCommand;
+ lpwh->command = uCommand;
lpwh->data = dwData;
- if (nlen)
+ if (nlen)
{
- strcpy(((char*)lpwh) + sizeof(WINHELP), lpHelpFile);
+ strcpyW( (LPWSTR)(((char*)lpwh) + sizeof(WINHELP)), lpHelpFile );
lpwh->ofsFilename = sizeof(WINHELP);
} else
lpwh->ofsFilename = 0;
- if (dsize)
+ if (dsize)
{
memcpy(((char*)lpwh) + sizeof(WINHELP) + nlen, (LPSTR)dwData, dsize);
lpwh->ofsData = sizeof(WINHELP) + nlen;
} else
lpwh->ofsData = 0;
- WINE_TRACE("Sending[%u]: cmd=%u data=%08lx fn=%s\n",
+ WINE_TRACE("Sending[%u]: cmd=%u data=%08lx fn=%s\n",
lpwh->size, lpwh->command, lpwh->data,
lpwh->ofsFilename ? (LPSTR)lpwh + lpwh->ofsFilename : "");
- return SendMessageA(hDest, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
-}
-
-
-/**********************************************************************
- * WinHelpW (USER32.@)
- */
-BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command, ULONG_PTR dwData )
-{
- INT len;
- LPSTR file;
- BOOL ret = FALSE;
-
- if (!helpFile) return WinHelpA( hWnd, NULL, command, dwData );
-
- len = WideCharToMultiByte( CP_ACP, 0, helpFile, -1, NULL, 0, NULL, NULL );
- if ((file = HeapAlloc( GetProcessHeap(), 0, len )))
- {
- WideCharToMultiByte( CP_ACP, 0, helpFile, -1, file, len, NULL, NULL );
- ret = WinHelpA( hWnd, file, command, dwData );
- HeapFree( GetProcessHeap(), 0, file );
- }
- return ret;
+ return SendMessageW(hDest, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
}