d794dc830fdf5391703009e811ae5a7298e9166c
[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
42 /* First Applet */
43 static LONG CALLBACK
44 SystemApplet(VOID)
45 {
46 PROPSHEETPAGEW page[2];
47 PROPSHEETHEADERW header;
48 WCHAR szCaption[MAX_STR_LEN];
49
50 LoadStringW(hApplet, IDS_CPLSYSTEMNAME, szCaption, ARRAYSIZE(szCaption));
51
52 ZeroMemory(&header, sizeof(header));
53
54 header.dwSize = sizeof(header);
55 header.dwFlags = PSH_PROPSHEETPAGE;
56 header.hwndParent = hCPLWindow;
57 header.hInstance = hApplet;
58 header.hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_CPLSYSTEM));
59 header.pszCaption = szCaption;
60 header.nPages = ARRAYSIZE(page);
61 header.nStartPage = 0;
62 header.ppsp = page;
63 header.pfnCallback = NULL;
64
65 /* Settings */
66 InitPropSheetPage(&page[0], IDD_PROPPAGESETTINGS, SettingsPageProc);
67
68 /* Advanced Settings */
69 InitPropSheetPage(&page[1], IDD_PROPPAGEADVANCEDSETTINGS, AdvancedSettingsPageProc);
70
71 return (LONG)(PropertySheetW(&header) != -1);
72 }
73
74
75 /* Control Panel Callback */
76 LONG CALLBACK
77 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
78 {
79 CPLINFO *CPlInfo;
80 DWORD i;
81
82 i = (DWORD)lParam1;
83
84 switch (uMsg)
85 {
86 case CPL_INIT:
87 return TRUE;
88
89 case CPL_GETCOUNT:
90 return NUM_APPLETS;
91
92 case CPL_INQUIRE:
93 CPlInfo = (CPLINFO*)lParam2;
94 CPlInfo->lData = 0;
95 CPlInfo->idIcon = Applets[i].idIcon;
96 CPlInfo->idName = Applets[i].idName;
97 CPlInfo->idInfo = Applets[i].idDescription;
98 break;
99
100 case CPL_DBLCLK:
101 hCPLWindow = hwndCPl;
102 Applets[i].AppletProc();
103 break;
104 }
105
106 return FALSE;
107 }
108
109
110 BOOL WINAPI
111 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
112 {
113 UNREFERENCED_PARAMETER(lpvReserved);
114
115 switch (dwReason)
116 {
117 case DLL_PROCESS_ATTACH:
118 case DLL_THREAD_ATTACH:
119 hApplet = hinstDLL;
120 break;
121 }
122
123 return TRUE;
124 }
125
126 /* EOF */