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