d9307282dea3d102d8acbbe91d73ddd6a4021caf
[reactos.git] / reactos / lib / cpl / main / main.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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * PROJECT: ReactOS Sample Control Panel
22 * FILE: lib/cpl/main/main.c
23 * PURPOSE: ReactOS Main Control Panel
24 * PROGRAMMER: Eric Kohl
25 * UPDATE HISTORY:
26 * 05-01-2004 Created
27 */
28 #include <windows.h>
29 #include <commctrl.h>
30 #include <cpl.h>
31
32 #include "main.h"
33 #include "resource.h"
34
35
36 #define NUM_APPLETS (2)
37
38
39 HINSTANCE hApplet = 0;
40
41
42 /* Applets */
43 APPLET Applets[NUM_APPLETS] =
44 {
45 {IDC_CPLICON_1, IDS_CPLNAME_1, IDS_CPLDESCRIPTION_1, MouseApplet},
46 {IDC_CPLICON_2, IDS_CPLNAME_2, IDS_CPLDESCRIPTION_2, KeyboardApplet}
47 };
48
49
50 VOID
51 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
52 {
53 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
54 psp->dwSize = sizeof(PROPSHEETPAGE);
55 psp->dwFlags = PSP_DEFAULT;
56 psp->hInstance = hApplet;
57 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
58 psp->pfnDlgProc = DlgProc;
59 }
60
61
62 /* Control Panel Callback */
63 LONG CALLBACK
64 CPlApplet(HWND hwndCpl,
65 UINT uMsg,
66 LPARAM lParam1,
67 LPARAM lParam2)
68 {
69 switch(uMsg)
70 {
71 case CPL_INIT:
72 return TRUE;
73
74 case CPL_GETCOUNT:
75 return NUM_APPLETS;
76
77 case CPL_INQUIRE:
78 {
79 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
80 UINT uAppIndex = (UINT)lParam1;
81
82 CPlInfo->lData = 0;
83 CPlInfo->idIcon = Applets[uAppIndex].idIcon;
84 CPlInfo->idName = Applets[uAppIndex].idName;
85 CPlInfo->idInfo = Applets[uAppIndex].idDescription;
86 break;
87 }
88
89 case CPL_DBLCLK:
90 {
91 UINT uAppIndex = (UINT)lParam1;
92 Applets[uAppIndex].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
93 break;
94 }
95 }
96
97 return FALSE;
98 }
99
100
101 BOOL STDCALL
102 DllMain(HINSTANCE hinstDLL,
103 DWORD dwReason,
104 LPVOID lpReserved)
105 {
106 switch(dwReason)
107 {
108 case DLL_PROCESS_ATTACH:
109 case DLL_THREAD_ATTACH:
110 hApplet = hinstDLL;
111 break;
112 }
113
114 return TRUE;
115 }
116