[CPL][SHELL32] Add icons to input, joy, sysdm, folder options (#1138)
[reactos.git] / dll / cpl / joy / joy.c
1 /*
2 * ReactOS
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /*
20 *
21 * PROJECT: ReactOS Software Control Panel
22 * FILE: dll/cpl/joy/joy.c
23 * PURPOSE: ReactOS Software Control Panel
24 * PROGRAMMER: Dmitry Chapyshev (lentind@yandex.ru)
25 * UPDATE HISTORY:
26 * 10-18-2007 Created
27 */
28
29 #include "joy.h"
30
31 #define NUM_APPLETS (1)
32
33 LONG CALLBACK SystemApplet(VOID);
34 HINSTANCE hApplet = 0;
35 HWND MainDlg;
36
37 /* Applets */
38
39 APPLET Applets[NUM_APPLETS] =
40 {
41 {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
42 };
43
44 VOID
45 AddColumns(HWND hList)
46 {
47 LV_COLUMN dummy;
48 RECT rect;
49 int Size;
50 TCHAR szBuf[256];
51
52 GetClientRect(hList, &rect);
53 Size = rect.right - rect.left - 250;
54
55 LoadString(hApplet, IDS_STATUS, szBuf, sizeof(szBuf) / sizeof(TCHAR));
56
57 ZeroMemory(&dummy, sizeof(LV_COLUMN));
58 dummy.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
59 dummy.iSubItem = 0;
60 dummy.pszText = (LPTSTR)szBuf;
61 dummy.cx = Size;
62 (void)ListView_InsertColumn(hList, 0, &dummy);
63
64 GetClientRect(hList, &rect);
65
66 LoadString(hApplet, IDS_CONTROLLER, szBuf, sizeof(szBuf) / sizeof(TCHAR));
67
68 ZeroMemory(&dummy, sizeof(LV_COLUMN));
69 dummy.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
70 dummy.iSubItem = 0;
71 dummy.pszText = (LPTSTR)szBuf;
72 dummy.cx = rect.right - rect.left - Size;
73 (void)ListView_InsertColumn(hList, 0, &dummy);
74 }
75
76 INT_PTR CALLBACK
77 AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
78 {
79 UNREFERENCED_PARAMETER(lParam);
80
81 switch (uMsg)
82 {
83 case WM_INITDIALOG:
84 break;
85
86 case WM_COMMAND:
87 switch (LOWORD(wParam))
88 {
89 case IDOK:
90 EndDialog(hwndDlg,LOWORD(wParam));
91 break;
92
93 case IDCANCEL:
94 EndDialog(hwndDlg,LOWORD(wParam));
95 break;
96 }
97 break;
98
99 case WM_NOTIFY:
100 break;
101
102 case WM_SYSCOMMAND:
103 switch (LOWORD(wParam))
104 {
105 case SC_CONTEXTHELP:
106 // Not implemented yet
107 break;
108 }
109 break;
110 }
111 return 0;
112 }
113
114 INT_PTR CALLBACK
115 CustomPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
116 {
117 UNREFERENCED_PARAMETER(lParam);
118
119 switch (uMsg)
120 {
121 case WM_INITDIALOG:
122 break;
123
124 case WM_COMMAND:
125 switch (LOWORD(wParam))
126 {
127 case IDOK:
128 EndDialog(hwndDlg,LOWORD(wParam));
129 break;
130
131 case IDCANCEL:
132 EndDialog(hwndDlg,LOWORD(wParam));
133 break;
134 }
135 break;
136
137 case WM_NOTIFY:
138 break;
139
140 case WM_SYSCOMMAND:
141 switch (LOWORD(wParam))
142 {
143 case SC_CONTEXTHELP:
144 // Not implemented yet
145 break;
146 }
147 break;
148 }
149 return 0;
150 }
151
152 INT_PTR CALLBACK
153 AddPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
154 {
155 UNREFERENCED_PARAMETER(lParam);
156
157 switch (uMsg)
158 {
159 case WM_INITDIALOG:
160 break;
161
162 case WM_COMMAND:
163 switch (LOWORD(wParam))
164 {
165 case IDC_CUSTOM_BUTTON:
166 DialogBox(hApplet,
167 MAKEINTRESOURCE(IDD_CUSTOM),
168 hwndDlg,
169 CustomPageProc);
170 break;
171
172 case IDOK:
173 EndDialog(hwndDlg,LOWORD(wParam));
174 break;
175
176 case IDCANCEL:
177 EndDialog(hwndDlg,LOWORD(wParam));
178 break;
179 }
180 break;
181
182 case WM_NOTIFY:
183 break;
184
185 case WM_SYSCOMMAND:
186 switch (LOWORD(wParam))
187 {
188 case SC_CONTEXTHELP:
189 // Not implemented yet
190 break;
191 }
192 break;
193 }
194 return 0;
195 }
196
197 /* Property page dialog callback */
198 INT_PTR CALLBACK
199 MainPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
200 {
201 static HICON s_hIcon = NULL, s_hIconSm = NULL;
202 UNREFERENCED_PARAMETER(lParam);
203
204 switch (uMsg)
205 {
206 case WM_INITDIALOG:
207 AddColumns(GetDlgItem(hwndDlg,IDC_CONTROLLER_LIST));
208 s_hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_CPLSYSTEM));
209 s_hIconSm = (HICON)LoadImageW(hApplet, MAKEINTRESOURCEW(IDI_CPLSYSTEM),
210 IMAGE_ICON,
211 GetSystemMetrics(SM_CXSMICON),
212 GetSystemMetrics(SM_CYSMICON), 0);
213 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)s_hIcon);
214 SendMessageW(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)s_hIconSm);
215 break;
216
217 case WM_COMMAND:
218 switch (LOWORD(wParam))
219 {
220 case IDC_ADD_BUTTON:
221 DialogBox(hApplet,
222 MAKEINTRESOURCE(IDD_ADD),
223 hwndDlg,
224 AddPageProc);
225 break;
226
227 case IDC_ADVANCED_BUTTON:
228 DialogBox(hApplet,
229 MAKEINTRESOURCE(IDD_ADVANCED),
230 hwndDlg,
231 AdvancedPageProc);
232 break;
233
234 case IDOK:
235 DestroyIcon(s_hIcon);
236 DestroyIcon(s_hIconSm);
237 EndDialog(hwndDlg,LOWORD(wParam));
238 break;
239 }
240 break;
241
242 case WM_NOTIFY:
243 break;
244
245 case WM_SYSCOMMAND:
246 switch (LOWORD(wParam))
247 {
248 case SC_CLOSE:
249 DestroyIcon(s_hIcon);
250 DestroyIcon(s_hIconSm);
251 EndDialog(hwndDlg,LOWORD(wParam));
252 break;
253
254 case SC_CONTEXTHELP:
255 // Not implemented yet
256 break;
257 }
258 break;
259 }
260 return 0;
261 }
262
263 /* First Applet */
264 LONG CALLBACK
265 SystemApplet(VOID)
266 {
267 DialogBox(hApplet,
268 MAKEINTRESOURCE(IDD_PROPPAGEMAIN),
269 MainDlg,
270 MainPageProc);
271
272 return (LONG)TRUE;
273 }
274
275 /* Control Panel Callback */
276 LONG CALLBACK
277 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
278 {
279 CPLINFO *CPlInfo;
280 DWORD i;
281
282 UNREFERENCED_PARAMETER(hwndCPl);
283
284 i = (DWORD)lParam1;
285 switch (uMsg)
286 {
287 case CPL_INIT:
288 return TRUE;
289
290 case CPL_GETCOUNT:
291 return NUM_APPLETS;
292
293 case CPL_INQUIRE:
294 CPlInfo = (CPLINFO*)lParam2;
295 CPlInfo->lData = 0;
296 CPlInfo->idIcon = Applets[i].idIcon;
297 CPlInfo->idName = Applets[i].idName;
298 CPlInfo->idInfo = Applets[i].idDescription;
299 break;
300
301 case CPL_DBLCLK:
302 {
303 MainDlg = hwndCPl;
304 Applets[i].AppletProc();
305 }
306 break;
307 }
308
309 return FALSE;
310 }
311
312 BOOL WINAPI
313 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
314 {
315 UNREFERENCED_PARAMETER(lpvReserved);
316
317 switch (dwReason)
318 {
319 case DLL_PROCESS_ATTACH:
320 case DLL_THREAD_ATTACH:
321 CoInitialize(NULL);
322 hApplet = hinstDLL;
323 break;
324 }
325
326 return TRUE;
327 }