[CPL][SHELL32] Add icons to input, joy, sysdm, folder options (#1138)
[reactos.git] / dll / cpl / input / input.c
1 /*
2 * PROJECT: input.dll
3 * FILE: dll/cpl/input/input.c
4 * PURPOSE: input.dll
5 * PROGRAMMER: Dmitry Chapyshev (lentind@yandex.ru)
6 * Colin Finck
7 * UPDATE HISTORY:
8 * 06-09-2007 Created
9 */
10
11 #include "input.h"
12
13 #include <cpl.h>
14
15 #define NUM_APPLETS (1)
16
17 static LONG CALLBACK SystemApplet(VOID);
18
19 HINSTANCE hApplet = NULL;
20 static HWND hCPLWindow;
21
22 /* Applets */
23 static APPLET Applets[NUM_APPLETS] =
24 {
25 {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
26 };
27
28
29 static VOID
30 InitPropSheetPage(PROPSHEETPAGEW *page, WORD idDlg, DLGPROC DlgProc)
31 {
32 ZeroMemory(page, sizeof(*page));
33
34 page->dwSize = sizeof(*page);
35 page->dwFlags = PSP_DEFAULT;
36 page->hInstance = hApplet;
37 page->pszTemplate = MAKEINTRESOURCEW(idDlg);
38 page->pfnDlgProc = DlgProc;
39 }
40
41 static int CALLBACK
42 PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
43 {
44 // NOTE: This callback is needed to set large icon correctly.
45 HICON hIcon;
46 switch (uMsg)
47 {
48 case PSCB_INITIALIZED:
49 {
50 hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_KEY_SHORT_ICO));
51 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
52 break;
53 }
54 }
55 return 0;
56 }
57
58 /* First Applet */
59 static LONG CALLBACK
60 SystemApplet(VOID)
61 {
62 PROPSHEETPAGEW page[2];
63 PROPSHEETHEADERW header;
64 WCHAR szCaption[MAX_STR_LEN];
65
66 LoadStringW(hApplet, IDS_CPLSYSTEMNAME, szCaption, ARRAYSIZE(szCaption));
67
68 ZeroMemory(&header, sizeof(header));
69
70 header.dwSize = sizeof(header);
71 header.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
72 header.hwndParent = hCPLWindow;
73 header.hInstance = hApplet;
74 header.pszIcon = MAKEINTRESOURCEW(IDI_KEY_SHORT_ICO);
75 header.pszCaption = szCaption;
76 header.nPages = ARRAYSIZE(page);
77 header.nStartPage = 0;
78 header.ppsp = page;
79 header.pfnCallback = PropSheetProc;
80
81 /* Settings */
82 InitPropSheetPage(&page[0], IDD_PROPPAGESETTINGS, SettingsPageProc);
83
84 /* Advanced Settings */
85 InitPropSheetPage(&page[1], IDD_PROPPAGEADVANCEDSETTINGS, AdvancedSettingsPageProc);
86
87 return (LONG)(PropertySheetW(&header) != -1);
88 }
89
90
91 /* Control Panel Callback */
92 LONG CALLBACK
93 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
94 {
95 CPLINFO *CPlInfo;
96 DWORD i;
97
98 i = (DWORD)lParam1;
99
100 switch (uMsg)
101 {
102 case CPL_INIT:
103 return TRUE;
104
105 case CPL_GETCOUNT:
106 return NUM_APPLETS;
107
108 case CPL_INQUIRE:
109 CPlInfo = (CPLINFO*)lParam2;
110 CPlInfo->lData = 0;
111 CPlInfo->idIcon = Applets[i].idIcon;
112 CPlInfo->idName = Applets[i].idName;
113 CPlInfo->idInfo = Applets[i].idDescription;
114 break;
115
116 case CPL_DBLCLK:
117 hCPLWindow = hwndCPl;
118 Applets[i].AppletProc();
119 break;
120 }
121
122 return FALSE;
123 }
124
125
126 BOOL WINAPI
127 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
128 {
129 UNREFERENCED_PARAMETER(lpvReserved);
130
131 switch (dwReason)
132 {
133 case DLL_PROCESS_ATTACH:
134 case DLL_THREAD_ATTACH:
135 hApplet = hinstDLL;
136 break;
137 }
138
139 return TRUE;
140 }
141
142 /* EOF */