9f220164dbf18eb3f1d65389ac8950c93089a019
[reactos.git] / dll / cpl / inetcpl / inetcpl.c
1 /*
2 * Internet control panel applet
3 *
4 * Copyright 2010 Detlef Riekenberg
5 *
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.
10 *
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.
15 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 */
21
22 #define NONAMELESSUNION
23 #define COBJMACROS
24 #define CONST_VTABLE
25
26 #include <stdarg.h>
27 #include <windef.h>
28 #include <winbase.h>
29 #include <wingdi.h>
30 #include <winuser.h>
31 #include <commctrl.h>
32 #include <cpl.h>
33 #include "ole2.h"
34
35 #include "wine/debug.h"
36
37 #include "inetcpl.h"
38
39
40 WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);
41
42 DECLSPEC_HIDDEN HMODULE hcpl;
43
44 /*********************************************************************
45 * DllMain (inetcpl.@)
46 */
47 BOOL WINAPI DllMain(HINSTANCE hdll, DWORD reason, LPVOID reserved)
48 {
49 TRACE("(%p, %d, %p)\n", hdll, reason, reserved);
50
51 switch (reason)
52 {
53 #ifndef __REACTOS__
54 case DLL_WINE_PREATTACH:
55 return FALSE; /* prefer native version */
56 #endif
57
58 case DLL_PROCESS_ATTACH:
59 DisableThreadLibraryCalls(hdll);
60 hcpl = hdll;
61 }
62 return TRUE;
63 }
64
65 /***********************************************************************
66 * DllInstall (inetcpl.@)
67 */
68 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
69 {
70 FIXME("(%s, %s): stub\n", bInstall ? "TRUE" : "FALSE", debugstr_w(cmdline));
71 return S_OK;
72 }
73
74 /******************************************************************************
75 * propsheet_callback [internal]
76 *
77 */
78 static int CALLBACK propsheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
79 {
80
81 TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam);
82 switch (msg)
83 {
84 case PSCB_INITIALIZED:
85 SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIconW(hcpl, MAKEINTRESOURCEW(ICO_MAIN)));
86 break;
87 }
88 return 0;
89 }
90
91 /******************************************************************************
92 * display_cpl_sheets [internal]
93 *
94 * Build and display the dialog with all control panel propertysheets
95 *
96 */
97 static void display_cpl_sheets(HWND parent)
98 {
99 INITCOMMONCONTROLSEX icex;
100 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
101 PROPSHEETHEADERW psh;
102 DWORD id = 0;
103
104 OleInitialize(NULL);
105 /* Initialize common controls */
106 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
107 icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES;
108 InitCommonControlsEx(&icex);
109
110 ZeroMemory(&psh, sizeof(psh));
111 ZeroMemory(psp, sizeof(psp));
112
113 /* Fill out all PROPSHEETPAGE */
114 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
115 psp[id].hInstance = hcpl;
116 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_GENERAL);
117 psp[id].pfnDlgProc = general_dlgproc;
118 id++;
119
120 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
121 psp[id].hInstance = hcpl;
122 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_SECURITY);
123 psp[id].pfnDlgProc = security_dlgproc;
124 id++;
125
126 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
127 psp[id].hInstance = hcpl;
128 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONTENT);
129 psp[id].pfnDlgProc = content_dlgproc;
130 id++;
131
132 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
133 psp[id].hInstance = hcpl;
134 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONNECTIONS);
135 psp[id].pfnDlgProc = connections_dlgproc;
136 id++;
137
138 /* Fill out the PROPSHEETHEADER */
139 psh.dwSize = sizeof (PROPSHEETHEADERW);
140 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
141 psh.hwndParent = parent;
142 psh.hInstance = hcpl;
143 psh.u.pszIcon = MAKEINTRESOURCEW(ICO_MAIN);
144 psh.pszCaption = MAKEINTRESOURCEW(IDS_CPL_NAME);
145 psh.nPages = id;
146 psh.u3.ppsp = psp;
147 psh.pfnCallback = propsheet_callback;
148
149 /* display the dialog */
150 PropertySheetW(&psh);
151
152 OleUninitialize();
153 }
154
155 /*********************************************************************
156 * CPlApplet (inetcpl.@)
157 *
158 * Control Panel entry point
159 *
160 * PARAMS
161 * hWnd [I] Handle for the Control Panel Window
162 * command [I] CPL_* Command
163 * lParam1 [I] first extra Parameter
164 * lParam2 [I] second extra Parameter
165 *
166 * RETURNS
167 * Depends on the command
168 *
169 */
170 LONG CALLBACK CPlApplet(HWND hWnd, UINT command, LPARAM lParam1, LPARAM lParam2)
171 {
172 TRACE("(%p, %u, 0x%lx, 0x%lx)\n", hWnd, command, lParam1, lParam2);
173
174 switch (command)
175 {
176 case CPL_INIT:
177 return TRUE;
178
179 case CPL_GETCOUNT:
180 return 1;
181
182 case CPL_INQUIRE:
183 {
184 CPLINFO *appletInfo = (CPLINFO *) lParam2;
185
186 appletInfo->idIcon = ICO_MAIN;
187 appletInfo->idName = IDS_CPL_NAME;
188 appletInfo->idInfo = IDS_CPL_INFO;
189 appletInfo->lData = 0;
190 return TRUE;
191 }
192
193 case CPL_DBLCLK:
194 display_cpl_sheets(hWnd);
195 break;
196 }
197
198 return FALSE;
199 }
200
201 /*********************************************************************
202 * LaunchInternetControlPanel (inetcpl.@)
203 *
204 * Launch the Internet Control Panel dialog
205 *
206 * PARAMS
207 * parent [I] Handle for the parent window
208 *
209 * RETURNS
210 * Success: TRUE
211 *
212 * NOTES
213 * rundll32 callable function: rundll32 inetcpl.cpl,LaunchInternetControlPanel
214 *
215 */
216 BOOL WINAPI LaunchInternetControlPanel(HWND parent)
217 {
218 display_cpl_sheets(parent);
219 return TRUE;
220 }
221
222 /*********************************************************************
223 * LaunchConnectionDialog (inetcpl.@)
224 *
225 */
226 BOOL WINAPI LaunchConnectionDialog(HWND hParent)
227 {
228 FIXME("(%p): stub\n", hParent);
229 return FALSE;
230 }
231
232 /*********************************************************************
233 * LaunchInternetControlPanel (inetcpl.@)
234 *
235 */
236 BOOL WINAPI LaunchPrivacyDialog(HWND hParent)
237 {
238 FIXME("(%p): stub\n", hParent);
239 return FALSE;
240 }