9 #include "debugtools.h"
12 #include "wine/winuser16.h"
13 #include "wine/winbase16.h"
16 DEFAULT_DEBUG_CHANNEL(win);
19 /* WinHelp internal structure */
30 /**********************************************************************
33 BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
39 /* We might call WinExec() */
40 ReleaseThunkLock( &mutex_count );
42 if (!(ret = WinHelpA( WIN_Handle32(hWnd), lpHelpFile, wCommand, (DWORD)MapSL(dwData) )))
44 /* try to start the 16-bit winhelp */
45 if (WinExec( "winhelp.exe -x", SW_SHOWNORMAL ) >= 32)
48 ret = WinHelpA( WIN_Handle32(hWnd), lpHelpFile, wCommand, (DWORD)MapSL(dwData) );
52 RestoreThunkLock( mutex_count );
57 /**********************************************************************
60 BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand,
63 static WORD WM_WINHELP = 0;
72 WM_WINHELP=RegisterWindowMessageA("WM_WINHELP");
77 hDest = FindWindowA( "MS_WINHELP", NULL );
79 if(wCommand == HELP_QUIT) return TRUE;
80 if (WinExec ( "winhlp32.exe -x", SW_SHOWNORMAL ) < 32) {
81 ERR("can't start winhlp32.exe -x ?\n");
84 if ( ! ( hDest = FindWindowA ( "MS_WINHELP", NULL ) )) {
85 FIXME("did not find MS_WINHELP (FindWindow() failed, maybe global window handling still unimplemented)\n");
94 case HELP_SETCONTENTS:
96 case HELP_CONTEXTPOPUP:
104 case HELP_PARTIALKEY:
106 dsize = dwData ? strlen( (LPSTR)dwData )+1: 0;
109 dsize = ((LPMULTIKEYHELPA)dwData)->mkSize;
112 dsize = ((LPHELPWININFOA)dwData)->wStructSize;
115 FIXME("Unknown help command %d\n",wCommand);
119 nlen = strlen(lpHelpFile)+1;
122 size = sizeof(WINHELP) + nlen + dsize;
123 hwh = GlobalAlloc16(0,size);
124 lpwh = GlobalLock16(hwh);
126 lpwh->command = wCommand;
129 strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
130 lpwh->ofsFilename = sizeof(WINHELP);
132 lpwh->ofsFilename = 0;
134 memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
135 lpwh->ofsData = sizeof(WINHELP)+nlen;
139 return SendMessage16(hDest,WM_WINHELP,hWnd,hwh);
143 /**********************************************************************
144 * WinHelpW (USER32.@)
146 BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command, DWORD dwData )
152 if (!helpFile) return WinHelpA( hWnd, NULL, command, dwData );
154 len = WideCharToMultiByte( CP_ACP, 0, helpFile, -1, NULL, 0, NULL, NULL );
155 if ((file = HeapAlloc( GetProcessHeap(), 0, len )))
157 WideCharToMultiByte( CP_ACP, 0, helpFile, -1, file, len, NULL, NULL );
158 ret = WinHelpA( hWnd, file, command, dwData );
159 HeapFree( GetProcessHeap(), 0, file );