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