Added DirectPlayLobby CLSID entries.
[wine/hacks.git] / windows / winhelp.c
blob55b2f1557004e7d4280ff7f91f58e8b843d6acff
1 /*
2 * Windows Help
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
21 #include "config.h"
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29 #include "wine/debug.h"
30 #include "windef.h"
31 #include "wingdi.h"
32 #include "wownt32.h"
33 #include "wine/winuser16.h"
34 #include "wine/winbase16.h"
35 #include "win.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(win);
40 /* WinHelp internal structure */
41 typedef struct
43 WORD size;
44 WORD command;
45 LONG data;
46 LONG reserved;
47 WORD ofsFilename;
48 WORD ofsData;
49 } WINHELP,*LPWINHELP;
51 /**********************************************************************
52 * WinHelp (USER.171)
54 BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
55 DWORD dwData )
57 BOOL ret;
58 DWORD mutex_count;
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)
68 K32WOWYield16();
69 ret = WinHelpA( WIN_Handle32(hWnd), lpHelpFile, wCommand, (DWORD)MapSL(dwData) );
73 RestoreThunkLock( mutex_count );
74 return ret;
78 /**********************************************************************
79 * WinHelpA (USER32.@)
81 BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand,
82 DWORD dwData )
84 static WORD WM_WINHELP = 0;
85 HWND hDest;
86 LPWINHELP lpwh;
87 HGLOBAL16 hwh;
88 int size,dsize,nlen;
91 if(!WM_WINHELP)
93 WM_WINHELP=RegisterWindowMessageA("WM_WINHELP");
94 if(!WM_WINHELP)
95 return FALSE;
98 hDest = FindWindowA( "MS_WINHELP", NULL );
99 if(!hDest) {
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");
103 return FALSE;
105 if ( ! ( hDest = FindWindowA ( "MS_WINHELP", NULL ) )) {
106 FIXME("did not find MS_WINHELP (FindWindow() failed, maybe global window handling still unimplemented)\n");
107 return FALSE;
112 switch(wCommand)
114 case HELP_CONTEXT:
115 case HELP_SETCONTENTS:
116 case HELP_CONTENTS:
117 case HELP_CONTEXTPOPUP:
118 case HELP_FORCEFILE:
119 case HELP_HELPONHELP:
120 case HELP_FINDER:
121 case HELP_QUIT:
122 dsize=0;
123 break;
124 case HELP_KEY:
125 case HELP_PARTIALKEY:
126 case HELP_COMMAND:
127 dsize = dwData ? strlen( (LPSTR)dwData )+1: 0;
128 break;
129 case HELP_MULTIKEY:
130 dsize = ((LPMULTIKEYHELPA)dwData)->mkSize;
131 break;
132 case HELP_SETWINPOS:
133 dsize = ((LPHELPWININFOA)dwData)->wStructSize;
134 break;
135 default:
136 FIXME("Unknown help command %d\n",wCommand);
137 return FALSE;
139 if(lpHelpFile)
140 nlen = strlen(lpHelpFile)+1;
141 else
142 nlen = 0;
143 size = sizeof(WINHELP) + nlen + dsize;
144 hwh = GlobalAlloc16(0,size);
145 lpwh = GlobalLock16(hwh);
146 lpwh->size = size;
147 lpwh->command = wCommand;
148 lpwh->data = dwData;
149 if(nlen) {
150 strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
151 lpwh->ofsFilename = sizeof(WINHELP);
152 } else
153 lpwh->ofsFilename = 0;
154 if(dsize) {
155 memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
156 lpwh->ofsData = sizeof(WINHELP)+nlen;
157 } else
158 lpwh->ofsData = 0;
159 GlobalUnlock16(hwh);
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 )
169 INT len;
170 LPSTR file;
171 BOOL ret = FALSE;
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 );
182 return ret;