3 * Copyright (C) 1998, 1999, 2000, 2001, 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/misc/winhelp.c
24 * PROGRAMMER: Robert Dickenson(robd@reactos.org)
26 * 23-08-2002 RDD Created from wine sources
29 /* INCLUDES ******************************************************************/
33 #include <wine/debug.h>
35 /* WinHelp internal structure */
47 /* FUNCTIONS *****************************************************************/
54 WinHelpA(HWND hWnd
, LPCSTR lpszHelp
, UINT uCommand
, DWORD dwData
)
56 static WORD WM_WINHELP
= 0;
63 WM_WINHELP
= RegisterWindowMessageA("WM_WINHELP");
68 hDest
= FindWindowA("MS_WINHELP", NULL
);
70 if (uCommand
== HELP_QUIT
) return TRUE
;
71 if (WinExec("winhlp32.exe -x", SW_SHOWNORMAL
) < 32) {
72 //ERR("can't start winhlp32.exe -x ?\n");
75 if (!(hDest
= FindWindowA("MS_WINHELP", NULL
))) {
76 //FIXME("did not find MS_WINHELP (FindWindow() failed, maybe global window handling still unimplemented)\n");
82 case HELP_SETCONTENTS
:
84 case HELP_CONTEXTPOPUP
:
94 dsize
= dwData
? strlen( (LPSTR
)dwData
)+1: 0;
97 dsize
= ((LPMULTIKEYHELPA
)dwData
)->mkSize
;
100 dsize
= ((LPHELPWININFOA
)dwData
)->wStructSize
;
103 //FIXME("Unknown help command %d\n",uCommand);
107 nlen
= strlen(lpszHelp
)+1;
110 size
= sizeof(WINHELP
) + nlen
+ dsize
;
111 hwh
= GlobalAlloc(0,size
);
114 lpwh
= GlobalLock(hwh
);
116 lpwh
->command
= uCommand
;
119 strcpy(((char*)lpwh
) + sizeof(WINHELP
), lpszHelp
);
120 lpwh
->ofsFilename
= sizeof(WINHELP
);
122 lpwh
->ofsFilename
= 0;
125 memcpy(((char*)lpwh
)+sizeof(WINHELP
)+nlen
,(LPSTR
)dwData
,dsize
);
126 lpwh
->ofsData
= sizeof(WINHELP
)+nlen
;
131 return SendMessageA(hDest
, WM_WINHELP
, (WPARAM
)hWnd
, (LPARAM
)hwh
);
140 WinHelpW(HWND hWnd
, LPCWSTR lpszHelp
, UINT uCommand
, DWORD dwData
)
146 if (!lpszHelp
) return WinHelpA(hWnd
, NULL
, uCommand
, dwData
);
148 len
= WideCharToMultiByte(CP_ACP
, 0, lpszHelp
, -1, NULL
, 0, NULL
, NULL
);
149 if ((file
= HeapAlloc(GetProcessHeap(), 0, len
))) {
150 WideCharToMultiByte(CP_ACP
, 0, lpszHelp
, -1, file
, len
, NULL
, NULL
);
151 ret
= WinHelpA(hWnd
, file
, uCommand
, dwData
);
152 HeapFree(GetProcessHeap(), 0, file
);