4 * Copyright 1996 Martin von Loewis
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(win
);
38 /* Wine doesn't use the way WinHelp API sends information in Windows, because:
39 * 1/ it's not consistent acrosss Win9x, NT...
40 * 2/ NT implementation is not yet fully understood (and includes some shared
42 * 3/ uses a dynamically allocated message number (WM_WINHELP), which
45 * So we use (for now) the simple protocol:
46 * 1/ it's based on copy data
47 * 2/ we tag the message with a magic number, to make it a bit more robust
48 * (even if it's not 100% safe)
49 * 3/ data structure (WINHELP) has the same layout that the one used on Win95.
50 * This doesn't bring much, except not going to far away from real
53 * This means anyway that native winhelp.exe and winhlp32.exe cannot be
54 * called/manipulated from WinHelp API.
66 /* magic number for this message:
67 * aide means help is French ;-)
70 #define WINHELP_MAGIC 0xA1DE505
72 /**********************************************************************
75 BOOL WINAPI
WinHelpA( HWND hWnd
, LPCSTR lpHelpFile
, UINT wCommand
, ULONG_PTR dwData
)
79 int size
, dsize
, nlen
;
82 hDest
= FindWindowA("MS_WINHELP", NULL
);
85 if (wCommand
== HELP_QUIT
) return TRUE
;
86 if (WinExec("winhelp.exe -x", SW_SHOWNORMAL
) < 32)
88 ERR("can't start winhelp.exe -x ?\n");
91 if (!(hDest
= FindWindowA("MS_WINHELP", NULL
)))
93 FIXME("Did not find a MS_WINHELP Window\n");
101 case HELP_SETCONTENTS
:
103 case HELP_CONTEXTPOPUP
:
105 case HELP_HELPONHELP
:
111 case HELP_PARTIALKEY
:
113 dsize
= dwData
? strlen((LPSTR
)dwData
) + 1 : 0;
116 dsize
= ((LPMULTIKEYHELPA
)dwData
)->mkSize
;
119 dsize
= ((LPHELPWININFOA
)dwData
)->wStructSize
;
122 FIXME("Unknown help command %d\n", wCommand
);
126 nlen
= strlen(lpHelpFile
) + 1;
129 size
= sizeof(WINHELP
) + nlen
+ dsize
;
131 lpwh
= HeapAlloc(GetProcessHeap(), 0, size
);
132 if (!lpwh
) return FALSE
;
134 cds
.dwData
= WINHELP_MAGIC
;
136 cds
.lpData
= (void*)lpwh
;
139 lpwh
->command
= wCommand
;
143 strcpy(((char*)lpwh
) + sizeof(WINHELP
), lpHelpFile
);
144 lpwh
->ofsFilename
= sizeof(WINHELP
);
146 lpwh
->ofsFilename
= 0;
149 memcpy(((char*)lpwh
) + sizeof(WINHELP
) + nlen
, (LPSTR
)dwData
, dsize
);
150 lpwh
->ofsData
= sizeof(WINHELP
) + nlen
;
153 WINE_TRACE("Sending[%u]: cmd=%u data=%08lx fn=%s\n",
154 lpwh
->size
, lpwh
->command
, lpwh
->data
,
155 lpwh
->ofsFilename
? (LPSTR
)lpwh
+ lpwh
->ofsFilename
: "");
157 return SendMessageA(hDest
, WM_COPYDATA
, (WPARAM
)hWnd
, (LPARAM
)&cds
);
161 /**********************************************************************
162 * WinHelpW (USER32.@)
164 BOOL WINAPI
WinHelpW( HWND hWnd
, LPCWSTR helpFile
, UINT command
, ULONG_PTR dwData
)
170 if (!helpFile
) return WinHelpA( hWnd
, NULL
, command
, dwData
);
172 len
= WideCharToMultiByte( CP_ACP
, 0, helpFile
, -1, NULL
, 0, NULL
, NULL
);
173 if ((file
= HeapAlloc( GetProcessHeap(), 0, len
)))
175 WideCharToMultiByte( CP_ACP
, 0, helpFile
, -1, file
, len
, NULL
, NULL
);
176 ret
= WinHelpA( hWnd
, file
, command
, dwData
);
177 HeapFree( GetProcessHeap(), 0, file
);