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