winebrowser: Don't put the default mailers or browsers into the registry.
[wine/multimedia.git] / dlls / hhctrl.ocx / hhctrl.c
blobde66a8a69dd26d2c1950353fc540af32b3d979d5
1 /*
2 * hhctrl implementation
4 * Copyright 2004 Krzysztof Foltman
5 * Copyright 2007 Jacek Caban for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
24 #define INIT_GUID
25 #include "hhctrl.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
29 HINSTANCE hhctrl_hinstance;
30 BOOL hh_process = FALSE;
32 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
34 TRACE("(%p,%d,%p)\n", hInstance, fdwReason, lpvReserved);
36 switch (fdwReason)
38 case DLL_PROCESS_ATTACH:
39 hhctrl_hinstance = hInstance;
40 DisableThreadLibraryCalls(hInstance);
41 break;
42 case DLL_PROCESS_DETACH:
43 break;
45 return TRUE;
48 static const char *command_to_string(UINT command)
50 #define X(x) case x: return #x
51 switch (command)
53 X( HH_DISPLAY_TOPIC );
54 X( HH_DISPLAY_TOC );
55 X( HH_DISPLAY_INDEX );
56 X( HH_DISPLAY_SEARCH );
57 X( HH_SET_WIN_TYPE );
58 X( HH_GET_WIN_TYPE );
59 X( HH_GET_WIN_HANDLE );
60 X( HH_ENUM_INFO_TYPE );
61 X( HH_SET_INFO_TYPE );
62 X( HH_SYNC );
63 X( HH_RESERVED1 );
64 X( HH_RESERVED2 );
65 X( HH_RESERVED3 );
66 X( HH_KEYWORD_LOOKUP );
67 X( HH_DISPLAY_TEXT_POPUP );
68 X( HH_HELP_CONTEXT );
69 X( HH_TP_HELP_CONTEXTMENU );
70 X( HH_TP_HELP_WM_HELP );
71 X( HH_CLOSE_ALL );
72 X( HH_ALINK_LOOKUP );
73 X( HH_GET_LAST_ERROR );
74 X( HH_ENUM_CATEGORY );
75 X( HH_ENUM_CATEGORY_IT );
76 X( HH_RESET_IT_FILTER );
77 X( HH_SET_INCLUSIVE_FILTER );
78 X( HH_SET_EXCLUSIVE_FILTER );
79 X( HH_INITIALIZE );
80 X( HH_UNINITIALIZE );
81 X( HH_PRETRANSLATEMESSAGE );
82 X( HH_SET_GLOBAL_PROPERTY );
83 default: return "???";
85 #undef X
88 /******************************************************************
89 * HtmlHelpW (hhctrl.ocx.15)
91 HWND WINAPI HtmlHelpW(HWND caller, LPCWSTR filename, UINT command, DWORD data)
93 TRACE("(%p, %s, command=%s, data=%d)\n",
94 caller, debugstr_w( filename ),
95 command_to_string( command ), data);
97 switch (command)
99 case HH_DISPLAY_TOPIC:
100 case HH_DISPLAY_TOC:
101 case HH_DISPLAY_SEARCH:{
102 HHInfo *info;
103 BOOL res;
105 FIXME("Not all HH cases handled correctly\n");
107 info = CreateHelpViewer(filename);
109 res = NavigateToChm(info, info->pCHMInfo->szFile, info->WinType.pszFile);
110 if(!res)
111 ReleaseHelpViewer(info);
113 return NULL; /* FIXME */
115 case HH_HELP_CONTEXT: {
116 HHInfo *info;
117 LPWSTR url;
119 info = CreateHelpViewer(filename);
120 if(!info)
121 return NULL;
123 url = FindContextAlias(info->pCHMInfo, data);
124 if(!url)
125 return NULL;
127 NavigateToUrl(info, url);
128 hhctrl_free(url);
130 return NULL; /* FIXME */
132 default:
133 FIXME("HH case %s not handled.\n", command_to_string( command ));
136 return 0;
139 /******************************************************************
140 * HtmlHelpA (hhctrl.ocx.14)
142 HWND WINAPI HtmlHelpA(HWND caller, LPCSTR filename, UINT command, DWORD data)
144 WCHAR *wfile = NULL;
145 HWND result;
147 if (filename)
149 DWORD len = MultiByteToWideChar( CP_ACP, 0, filename, -1, NULL, 0 );
151 wfile = hhctrl_alloc(len*sizeof(WCHAR));
152 MultiByteToWideChar( CP_ACP, 0, filename, -1, wfile, len );
155 result = HtmlHelpW( caller, wfile, command, data );
157 hhctrl_free(wfile);
158 return result;
161 /******************************************************************
162 * doWinMain (hhctrl.ocx.13)
164 int WINAPI doWinMain(HINSTANCE hInstance, LPSTR szCmdLine)
166 MSG msg;
168 hh_process = TRUE;
170 /* FIXME: Check szCmdLine for bad arguments */
171 HtmlHelpA(GetDesktopWindow(), szCmdLine, HH_DISPLAY_TOPIC, 0);
173 while (GetMessageW(&msg, 0, 0, 0))
175 TranslateMessage(&msg);
176 DispatchMessageW(&msg);
179 return 0;
182 /******************************************************************
183 * DllGetClassObject (hhctrl.ocx.@)
185 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
187 FIXME("(%s %s %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
188 return CLASS_E_CLASSNOTAVAILABLE;