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.
20 * PROJECT: ReactOS user32.dll
21 * FILE: lib/user32/misc/winhelp.c
23 * PROGRAMMER: Robert Dickenson(robd@reactos.org)
25 * 23-08-2002 RDD Created from wine sources
28 /* INCLUDES ******************************************************************/
32 #include <wine/debug.h>
34 /* WinHelp internal structure */
46 /* FUNCTIONS *****************************************************************/
53 WinHelpA(HWND hWnd
, LPCSTR lpszHelp
, UINT uCommand
, DWORD_PTR dwData
)
55 static WORD WM_WINHELP
= 0;
62 WM_WINHELP
= RegisterWindowMessageA("WM_WINHELP");
67 hDest
= FindWindowA("MS_WINHELP", NULL
);
69 if (uCommand
== HELP_QUIT
) return TRUE
;
70 if (WinExec("winhlp32.exe -x", SW_SHOWNORMAL
) < 32) {
71 //ERR("can't start winhlp32.exe -x ?\n");
74 if (!(hDest
= FindWindowA("MS_WINHELP", NULL
))) {
75 //FIXME("did not find MS_WINHELP (FindWindow() failed, maybe global window handling still unimplemented)\n");
81 case HELP_SETCONTENTS
:
83 case HELP_CONTEXTPOPUP
:
93 dsize
= dwData
? strlen( (LPSTR
)dwData
)+1: 0;
96 dsize
= ((LPMULTIKEYHELPA
)dwData
)->mkSize
;
99 dsize
= ((LPHELPWININFOA
)dwData
)->wStructSize
;
102 //FIXME("Unknown help command %d\n",uCommand);
106 nlen
= strlen(lpszHelp
)+1;
109 size
= sizeof(WINHELP
) + nlen
+ dsize
;
110 hwh
= GlobalAlloc(0,size
);
113 lpwh
= GlobalLock(hwh
);
115 lpwh
->command
= uCommand
;
118 strcpy(((char*)lpwh
) + sizeof(WINHELP
), lpszHelp
);
119 lpwh
->ofsFilename
= sizeof(WINHELP
);
121 lpwh
->ofsFilename
= 0;
124 memcpy(((char*)lpwh
)+sizeof(WINHELP
)+nlen
,(LPSTR
)dwData
,dsize
);
125 lpwh
->ofsData
= sizeof(WINHELP
)+nlen
;
130 return SendMessageA(hDest
, WM_WINHELP
, (WPARAM
)hWnd
, (LPARAM
)hwh
);
139 WinHelpW(HWND hWnd
, LPCWSTR lpszHelp
, UINT uCommand
, DWORD_PTR dwData
)
145 if (!lpszHelp
) return WinHelpA(hWnd
, NULL
, uCommand
, dwData
);
147 len
= WideCharToMultiByte(CP_ACP
, 0, lpszHelp
, -1, NULL
, 0, NULL
, NULL
);
148 if ((file
= HeapAlloc(GetProcessHeap(), 0, len
))) {
149 WideCharToMultiByte(CP_ACP
, 0, lpszHelp
, -1, file
, len
, NULL
, NULL
);
150 ret
= WinHelpA(hWnd
, file
, uCommand
, dwData
);
151 HeapFree(GetProcessHeap(), 0, file
);