ReactOS  0.4.15-dev-1197-g8081ba9
winhelp.c
Go to the documentation of this file.
1 /*
2  * ReactOS kernel
3  * Copyright (C) 1998, 1999, 2000, 2001, 2002 ReactOS Team
4  *
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.
9  *
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.
14  *
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.
18  */
19 /*
20  * PROJECT: ReactOS user32.dll
21  * FILE: win32ss/user/user32/misc/winhelp.c
22  * PURPOSE: WinHelp
23  * PROGRAMMER: Robert Dickenson(robd@reactos.org)
24  * UPDATE HISTORY:
25  * 23-08-2002 RDD Created from wine sources
26  */
27 
28 #include <user32.h>
29 
30 /* WinHelp internal structure */
31 typedef struct
32 {
33  WORD size;
34  WORD command;
35  LONG data;
36  LONG reserved;
37  WORD ofsFilename;
38  WORD ofsData;
40 
41 
42 /* FUNCTIONS *****************************************************************/
43 
44 /*
45  * @unimplemented
46  */
47 BOOL
48 WINAPI
49 WinHelpA(HWND hWnd, LPCSTR lpszHelp, UINT uCommand, DWORD_PTR dwData)
50 {
51  static WORD WM_WINHELP = 0;
52  HWND hDest;
53  LPWINHELP lpwh;
54  HGLOBAL hwh;
55  int size,dsize,nlen;
56 
57  if (!WM_WINHELP) {
58  WM_WINHELP = RegisterWindowMessageA("WM_WINHELP");
59  if (!WM_WINHELP)
60  return FALSE;
61  }
62 
63  hDest = FindWindowA("MS_WINHELP", NULL);
64  if (!hDest) {
65  if (uCommand == HELP_QUIT) return TRUE;
66  if (WinExec("winhlp32.exe -x", SW_SHOWNORMAL) < 32) {
67  //ERR("can't start winhlp32.exe -x ?\n");
68  return FALSE;
69  }
70  if (!(hDest = FindWindowA("MS_WINHELP", NULL))) {
71  //FIXME("did not find MS_WINHELP (FindWindow() failed, maybe global window handling still unimplemented)\n");
72  return FALSE;
73  }
74  }
75  switch (uCommand) {
76  case HELP_CONTEXT:
77  case HELP_SETCONTENTS:
78  case HELP_CONTENTS:
79  case HELP_CONTEXTPOPUP:
80  case HELP_FORCEFILE:
81  case HELP_HELPONHELP:
82  case HELP_FINDER:
83  case HELP_QUIT:
84  dsize=0;
85  break;
86  case HELP_KEY:
87  case HELP_PARTIALKEY:
88  case HELP_COMMAND:
89  dsize = dwData ? strlen( (LPSTR)dwData )+1: 0;
90  break;
91  case HELP_MULTIKEY:
92  dsize = ((LPMULTIKEYHELPA)dwData)->mkSize;
93  break;
94  case HELP_SETWINPOS:
95  dsize = ((LPHELPWININFOA)dwData)->wStructSize;
96  break;
97  default:
98  //FIXME("Unknown help command %d\n",uCommand);
99  return FALSE;
100  }
101  if (lpszHelp)
102  nlen = strlen(lpszHelp)+1;
103  else
104  nlen = 0;
105  size = sizeof(WINHELP) + nlen + dsize;
106  hwh = GlobalAlloc(0,size);
107  if (hwh == NULL)
108  return FALSE;
109  lpwh = GlobalLock(hwh);
110  lpwh->size = size;
111  lpwh->command = uCommand;
112  lpwh->data = dwData;
113  if (nlen) {
114  strcpy(((char*)lpwh) + sizeof(WINHELP), lpszHelp);
115  lpwh->ofsFilename = sizeof(WINHELP);
116  } else {
117  lpwh->ofsFilename = 0;
118  }
119  if (dsize) {
120  memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
121  lpwh->ofsData = sizeof(WINHELP)+nlen;
122  } else {
123  lpwh->ofsData = 0;
124  }
125  GlobalUnlock(hwh);
126  return SendMessageA(hDest, WM_WINHELP, (WPARAM)hWnd, (LPARAM)hwh);
127 }
128 
129 
130 /*
131  * @unimplemented
132  */
133 BOOL
134 WINAPI
136 {
137  INT len;
138  LPSTR file;
139  BOOL ret = FALSE;
140 
141  if (!lpszHelp) return WinHelpA(hWnd, NULL, uCommand, dwData);
142 
143  len = WideCharToMultiByte(CP_ACP, 0, lpszHelp, -1, NULL, 0, NULL, NULL);
144  if ((file = HeapAlloc(GetProcessHeap(), 0, len))) {
145  WideCharToMultiByte(CP_ACP, 0, lpszHelp, -1, file, len, NULL, NULL);
146  ret = WinHelpA(hWnd, file, uCommand, dwData);
148  }
149  return ret;
150 }
151 
WORD ofsData
Definition: winhelp.c:337
#define HELP_PARTIALKEY
Definition: winuser.h:2388
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define HELP_CONTENTS
Definition: winuser.h:2380
#define HELP_CONTEXTPOPUP
Definition: winuser.h:2382
LONG data
Definition: winhelp.c:334
#define WideCharToMultiByte
Definition: compat.h:111
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
WORD size
Definition: winhelp.c:332
#define TRUE
Definition: types.h:120
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CP_ACP
Definition: compat.h:109
#define HELP_QUIT
Definition: winuser.h:2389
#define HELP_HELPONHELP
Definition: winuser.h:2384
HWND hWnd
Definition: settings.c:17
static HANDLE ULONG_PTR dwData
Definition: file.c:35
UINT_PTR WPARAM
Definition: windef.h:207
UINT WINAPI DECLSPEC_HOTPATCH WinExec(LPCSTR lpCmdLine, UINT uCmdShow)
Definition: proc.c:4776
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:58
#define HELP_FINDER
Definition: winuser.h:2394
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
r reserved
Definition: btrfs.c:2940
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI WinHelpA(HWND hWnd, LPCSTR lpszHelp, UINT uCommand, DWORD_PTR dwData)
Definition: winhelp.c:49
const char * LPCSTR
Definition: xmlstorage.h:183
struct WINHELP * LPWINHELP
#define HELP_FORCEFILE
Definition: winuser.h:2383
WORD ofsFilename
Definition: winhelp.c:336
GLsizeiptr size
Definition: glext.h:5919
#define HELP_CONTEXT
Definition: winuser.h:2381
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI WinHelpW(HWND hWnd, LPCWSTR lpszHelp, UINT uCommand, DWORD_PTR dwData)
Definition: winhelp.c:135
#define HELP_SETWINPOS
Definition: winuser.h:2392
#define WINAPI
Definition: msvc.h:6
const char file[]
Definition: icontest.c:11
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define HELP_MULTIKEY
Definition: winuser.h:2387
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
uint32_t DWORD_PTR
Definition: typedefs.h:65
HWND WINAPI FindWindowA(_In_opt_ LPCSTR, _In_opt_ LPCSTR)
struct tagMULTIKEYHELPA * LPMULTIKEYHELPA
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define HELP_COMMAND
Definition: winuser.h:2379
struct tagHELPWININFOA * LPHELPWININFOA
#define HELP_SETCONTENTS
Definition: winuser.h:2390
unsigned int UINT
Definition: ndis.h:50
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
int command(const char *fmt,...)
Definition: ftp.c:266
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
WORD command
Definition: winhelp.c:333
#define HeapFree(x, y, z)
Definition: compat.h:483
UINT WINAPI RegisterWindowMessageA(_In_ LPCSTR)
Definition: fci.c:126
#define HELP_KEY
Definition: winuser.h:2386