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 */
DllMain(HINSTANCE hdll,DWORD reason,LPVOID reserved)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 */
DllInstall(BOOL bInstall,LPCWSTR cmdline)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 */
propsheet_callback(HWND hwnd,UINT msg,LPARAM lparam)78 static int CALLBACK propsheet_callback(HWND hwnd, UINT msg, LPARAM lparam)
79 {
80 #ifdef __REACTOS__
81 // NOTE: This callback is needed to set large icon correctly.
82 HICON hIcon;
83 #endif
84 TRACE("(%p, 0x%08x/%d, 0x%lx)\n", hwnd, msg, msg, lparam);
85 switch (msg)
86 {
87 case PSCB_INITIALIZED:
88 #ifdef __REACTOS__
89 {
90 hIcon = LoadIconW(hcpl, MAKEINTRESOURCEW(ICO_MAIN));
91 SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
92 break;
93 }
94 #else
95 SendMessageW(hwnd, WM_SETICON, ICON_BIG, (LPARAM) LoadIconW(hcpl, MAKEINTRESOURCEW(ICO_MAIN)));
96 break;
97 #endif
98 }
99 return 0;
100 }
101
102 /******************************************************************************
103 * display_cpl_sheets [internal]
104 *
105 * Build and display the dialog with all control panel propertysheets
106 *
107 */
display_cpl_sheets(HWND parent)108 static void display_cpl_sheets(HWND parent)
109 {
110 INITCOMMONCONTROLSEX icex;
111 PROPSHEETPAGEW psp[NUM_PROPERTY_PAGES];
112 PROPSHEETHEADERW psh;
113 DWORD id = 0;
114
115 OleInitialize(NULL);
116 /* Initialize common controls */
117 icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
118 icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES;
119 InitCommonControlsEx(&icex);
120
121 ZeroMemory(&psh, sizeof(psh));
122 ZeroMemory(psp, sizeof(psp));
123
124 /* Fill out all PROPSHEETPAGE */
125 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
126 psp[id].hInstance = hcpl;
127 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_GENERAL);
128 psp[id].pfnDlgProc = general_dlgproc;
129 id++;
130
131 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
132 psp[id].hInstance = hcpl;
133 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_SECURITY);
134 psp[id].pfnDlgProc = security_dlgproc;
135 id++;
136
137 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
138 psp[id].hInstance = hcpl;
139 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONTENT);
140 psp[id].pfnDlgProc = content_dlgproc;
141 id++;
142
143 psp[id].dwSize = sizeof (PROPSHEETPAGEW);
144 psp[id].hInstance = hcpl;
145 psp[id].u.pszTemplate = MAKEINTRESOURCEW(IDD_CONNECTIONS);
146 psp[id].pfnDlgProc = connections_dlgproc;
147 id++;
148
149 /* Fill out the PROPSHEETHEADER */
150 psh.dwSize = sizeof (PROPSHEETHEADERW);
151 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
152 psh.hwndParent = parent;
153 psh.hInstance = hcpl;
154 psh.u.pszIcon = MAKEINTRESOURCEW(ICO_MAIN);
155 psh.pszCaption = MAKEINTRESOURCEW(IDS_CPL_NAME);
156 psh.nPages = id;
157 psh.u3.ppsp = psp;
158 psh.pfnCallback = propsheet_callback;
159
160 /* display the dialog */
161 PropertySheetW(&psh);
162
163 OleUninitialize();
164 }
165
166 /*********************************************************************
167 * CPlApplet (inetcpl.@)
168 *
169 * Control Panel entry point
170 *
171 * PARAMS
172 * hWnd [I] Handle for the Control Panel Window
173 * command [I] CPL_* Command
174 * lParam1 [I] first extra Parameter
175 * lParam2 [I] second extra Parameter
176 *
177 * RETURNS
178 * Depends on the command
179 *
180 */
CPlApplet(HWND hWnd,UINT command,LPARAM lParam1,LPARAM lParam2)181 LONG CALLBACK CPlApplet(HWND hWnd, UINT command, LPARAM lParam1, LPARAM lParam2)
182 {
183 TRACE("(%p, %u, 0x%lx, 0x%lx)\n", hWnd, command, lParam1, lParam2);
184
185 switch (command)
186 {
187 case CPL_INIT:
188 return TRUE;
189
190 case CPL_GETCOUNT:
191 return 1;
192
193 case CPL_INQUIRE:
194 {
195 CPLINFO *appletInfo = (CPLINFO *) lParam2;
196
197 appletInfo->idIcon = ICO_MAIN;
198 appletInfo->idName = IDS_CPL_NAME;
199 appletInfo->idInfo = IDS_CPL_INFO;
200 appletInfo->lData = 0;
201 return TRUE;
202 }
203
204 case CPL_DBLCLK:
205 display_cpl_sheets(hWnd);
206 break;
207 }
208
209 return FALSE;
210 }
211
212 /*********************************************************************
213 * LaunchInternetControlPanel (inetcpl.@)
214 *
215 * Launch the Internet Control Panel dialog
216 *
217 * PARAMS
218 * parent [I] Handle for the parent window
219 *
220 * RETURNS
221 * Success: TRUE
222 *
223 * NOTES
224 * rundll32 callable function: rundll32 inetcpl.cpl,LaunchInternetControlPanel
225 *
226 */
LaunchInternetControlPanel(HWND parent)227 BOOL WINAPI LaunchInternetControlPanel(HWND parent)
228 {
229 display_cpl_sheets(parent);
230 return TRUE;
231 }
232
233 /*********************************************************************
234 * LaunchConnectionDialog (inetcpl.@)
235 *
236 */
LaunchConnectionDialog(HWND hParent)237 BOOL WINAPI LaunchConnectionDialog(HWND hParent)
238 {
239 FIXME("(%p): stub\n", hParent);
240 return FALSE;
241 }
242
243 /*********************************************************************
244 * LaunchInternetControlPanel (inetcpl.@)
245 *
246 */
LaunchPrivacyDialog(HWND hParent)247 BOOL WINAPI LaunchPrivacyDialog(HWND hParent)
248 {
249 FIXME("(%p): stub\n", hParent);
250 return FALSE;
251 }
252