[INPUT]
[reactos.git] / reactos / dll / cpl / input / input.c
1 /*
2 * PROJECT: input.dll
3 * FILE: dll/win32/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 #define NUM_APPLETS (1)
14
15 LONG CALLBACK SystemApplet(VOID);
16 HINSTANCE hApplet = 0;
17 HANDLE hProcessHeap;
18 HWND hCPLWindow;
19
20 /* Applets */
21 APPLET Applets[NUM_APPLETS] =
22 {
23 {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
24 };
25
26
27 VOID
28 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
29 {
30 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
31 psp->dwSize = sizeof(PROPSHEETPAGE);
32 psp->dwFlags = PSP_DEFAULT;
33 psp->hInstance = hApplet;
34 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
35 psp->pfnDlgProc = DlgProc;
36 }
37
38
39 /* First Applet */
40
41 LONG CALLBACK
42 SystemApplet(VOID)
43 {
44 PROPSHEETPAGE psp[2];
45 PROPSHEETHEADER psh;
46 TCHAR Caption[1024];
47
48 LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
49
50 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
51 psh.dwSize = sizeof(PROPSHEETHEADER);
52 psh.dwFlags = PSH_PROPSHEETPAGE;
53 psh.hwndParent = hCPLWindow;
54 psh.hInstance = hApplet;
55 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
56 psh.pszCaption = Caption;
57 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
58 psh.nStartPage = 0;
59 psh.ppsp = psp;
60 psh.pfnCallback = NULL;
61
62 /* Settings */
63 InitPropSheetPage(&psp[0], IDD_PROPPAGESETTINGS, (DLGPROC)SettingsPageProc);
64
65 /* Advanced Settings */
66 InitPropSheetPage(&psp[1], IDD_PROPPAGEADVANCEDSETTINGS, (DLGPROC)AdvancedSettingsPageProc);
67
68 return (LONG)(PropertySheet(&psh) != -1);
69 }
70
71
72 /* Control Panel Callback */
73 LONG CALLBACK
74 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
75 {
76 CPLINFO *CPlInfo;
77 DWORD i;
78
79 i = (DWORD)lParam1;
80 switch (uMsg)
81 {
82 case CPL_INIT:
83 return TRUE;
84
85 case CPL_GETCOUNT:
86 return NUM_APPLETS;
87
88 case CPL_INQUIRE:
89 CPlInfo = (CPLINFO*)lParam2;
90 CPlInfo->lData = 0;
91 CPlInfo->idIcon = Applets[i].idIcon;
92 CPlInfo->idName = Applets[i].idName;
93 CPlInfo->idInfo = Applets[i].idDescription;
94 break;
95
96 case CPL_DBLCLK:
97 hCPLWindow = hwndCPl;
98 Applets[i].AppletProc();
99 break;
100 }
101
102 return FALSE;
103 }
104
105
106 BOOL WINAPI
107 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
108 {
109 UNREFERENCED_PARAMETER(lpvReserved);
110
111 switch (dwReason)
112 {
113 case DLL_PROCESS_ATTACH:
114 case DLL_THREAD_ATTACH:
115 hApplet = hinstDLL;
116 hProcessHeap = GetProcessHeap();
117 break;
118 }
119
120 return TRUE;
121 }
122
123 /* EOF */