4 * Copyright 1996 Martin von Loewis
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/debug.h"
33 #include "wine/winuser16.h"
34 #include "wine/winbase16.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(win
);
40 /* WinHelp internal structure */
51 /**********************************************************************
54 BOOL16 WINAPI
WinHelp16( HWND16 hWnd
, LPCSTR lpHelpFile
, UINT16 wCommand
,
60 /* We might call WinExec() */
61 ReleaseThunkLock( &mutex_count
);
63 if (!(ret
= WinHelpA( WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
) )))
65 /* try to start the 16-bit winhelp */
66 if (WinExec( "winhelp.exe -x", SW_SHOWNORMAL
) >= 32)
69 ret
= WinHelpA( WIN_Handle32(hWnd
), lpHelpFile
, wCommand
, (DWORD
)MapSL(dwData
) );
73 RestoreThunkLock( mutex_count
);
78 /**********************************************************************
81 BOOL WINAPI
WinHelpA( HWND hWnd
, LPCSTR lpHelpFile
, UINT wCommand
,
84 static WORD WM_WINHELP
= 0;
93 WM_WINHELP
=RegisterWindowMessageA("WM_WINHELP");
98 hDest
= FindWindowA( "MS_WINHELP", NULL
);
100 if(wCommand
== HELP_QUIT
) return TRUE
;
101 if (WinExec ( "winhlp32.exe -x", SW_SHOWNORMAL
) < 32) {
102 ERR("can't start winhlp32.exe -x ?\n");
105 if ( ! ( hDest
= FindWindowA ( "MS_WINHELP", NULL
) )) {
106 FIXME("did not find MS_WINHELP (FindWindow() failed, maybe global window handling still unimplemented)\n");
115 case HELP_SETCONTENTS
:
117 case HELP_CONTEXTPOPUP
:
119 case HELP_HELPONHELP
:
125 case HELP_PARTIALKEY
:
127 dsize
= dwData
? strlen( (LPSTR
)dwData
)+1: 0;
130 dsize
= ((LPMULTIKEYHELPA
)dwData
)->mkSize
;
133 dsize
= ((LPHELPWININFOA
)dwData
)->wStructSize
;
136 FIXME("Unknown help command %d\n",wCommand
);
140 nlen
= strlen(lpHelpFile
)+1;
143 size
= sizeof(WINHELP
) + nlen
+ dsize
;
144 hwh
= GlobalAlloc16(0,size
);
145 lpwh
= GlobalLock16(hwh
);
147 lpwh
->command
= wCommand
;
150 strcpy(((char*)lpwh
) + sizeof(WINHELP
),lpHelpFile
);
151 lpwh
->ofsFilename
= sizeof(WINHELP
);
153 lpwh
->ofsFilename
= 0;
155 memcpy(((char*)lpwh
)+sizeof(WINHELP
)+nlen
,(LPSTR
)dwData
,dsize
);
156 lpwh
->ofsData
= sizeof(WINHELP
)+nlen
;
160 return SendMessage16(HWND_16(hDest
),WM_WINHELP
,HWND_16(hWnd
),hwh
);
164 /**********************************************************************
165 * WinHelpW (USER32.@)
167 BOOL WINAPI
WinHelpW( HWND hWnd
, LPCWSTR helpFile
, UINT command
, DWORD dwData
)
173 if (!helpFile
) return WinHelpA( hWnd
, NULL
, command
, dwData
);
175 len
= WideCharToMultiByte( CP_ACP
, 0, helpFile
, -1, NULL
, 0, NULL
, NULL
);
176 if ((file
= HeapAlloc( GetProcessHeap(), 0, len
)))
178 WideCharToMultiByte( CP_ACP
, 0, helpFile
, -1, file
, len
, NULL
, NULL
);
179 ret
= WinHelpA( hWnd
, file
, command
, dwData
);
180 HeapFree( GetProcessHeap(), 0, file
);