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