d90f791d863e3722bb6fd6d15301956ca51e3bae
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.
19 /* $Id: winhelp.c,v 1.6 2004/01/23 23:38:26 ekohl Exp $
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 ******************************************************************/
36 /* WinHelp internal structure */
48 /* FUNCTIONS *****************************************************************/
55 WinHelpA(HWND hWnd
, LPCSTR lpszHelp
, UINT uCommand
, DWORD dwData
)
57 static WORD WM_WINHELP
= 0;
64 WM_WINHELP
= RegisterWindowMessageA("WM_WINHELP");
69 hDest
= FindWindowA("MS_WINHELP", NULL
);
71 if (uCommand
== HELP_QUIT
) return TRUE
;
72 if (WinExec("winhlp32.exe -x", SW_SHOWNORMAL
) < 32) {
73 //ERR("can't start winhlp32.exe -x ?\n");
76 if (!(hDest
= FindWindowA("MS_WINHELP", NULL
))) {
77 //FIXME("did not find MS_WINHELP (FindWindow() failed, maybe global window handling still unimplemented)\n");
83 case HELP_SETCONTENTS
:
85 case HELP_CONTEXTPOPUP
:
95 dsize
= dwData
? strlen( (LPSTR
)dwData
)+1: 0;
98 dsize
= ((LPMULTIKEYHELPA
)dwData
)->mkSize
;
101 dsize
= ((LPHELPWININFOA
)dwData
)->wStructSize
;
104 //FIXME("Unknown help command %d\n",uCommand);
108 nlen
= strlen(lpszHelp
)+1;
111 size
= sizeof(WINHELP
) + nlen
+ dsize
;
112 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 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
);