reshuffling of dlls
[reactos.git] / reactos / dll / cpl / access / access.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 System Control Panel
22 * FILE: lib/cpl/system/sysdm.c
23 * PURPOSE: ReactOS System Control Panel
24 * PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
25 * UPDATE HISTORY:
26 * 03-04-2004 Created
27 */
28 #include <windows.h>
29 #include <commctrl.h>
30 #include <cpl.h>
31
32 #include <stdlib.h>
33
34 #include "resource.h"
35 #include "access.h"
36
37 #define NUM_APPLETS (1)
38
39 LONG CALLBACK SystemApplet(VOID);
40 INT_PTR CALLBACK DisplayPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
41 INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
42 INT_PTR CALLBACK KeyboardPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
43 INT_PTR CALLBACK MousePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
44 INT_PTR CALLBACK SoundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
45 HINSTANCE hApplet = 0;
46
47 /* Applets */
48 APPLET Applets[NUM_APPLETS] =
49 {
50 {IDI_CPLACCESS, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
51 };
52
53 static void
54 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
55 {
56 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
57 psp->dwSize = sizeof(PROPSHEETPAGE);
58 psp->dwFlags = PSP_DEFAULT;
59 psp->hInstance = hApplet;
60 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
61 psp->pfnDlgProc = DlgProc;
62 }
63
64 /* Property Sheet Callback */
65 int CALLBACK
66 PropSheetProc(
67 HWND hwndDlg,
68 UINT uMsg,
69 LPARAM lParam
70 )
71 {
72 switch(uMsg)
73 {
74 case PSCB_BUTTONPRESSED:
75 switch(lParam)
76 {
77 case PSBTN_OK: /* OK */
78 break;
79 case PSBTN_CANCEL: /* Cancel */
80 break;
81 case PSBTN_APPLYNOW: /* Apply now */
82 break;
83 case PSBTN_FINISH: /* Close */
84 break;
85 default:
86 return FALSE;
87 }
88 break;
89
90 case PSCB_INITIALIZED:
91 break;
92 }
93 return TRUE;
94 }
95
96 /* First Applet */
97
98 LONG CALLBACK
99 SystemApplet(VOID)
100 {
101 PROPSHEETPAGE psp[5];
102 PROPSHEETHEADER psh;
103 TCHAR Caption[1024];
104
105 LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
106
107 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
108 psh.dwSize = sizeof(PROPSHEETHEADER);
109 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
110 psh.hwndParent = NULL;
111 psh.hInstance = hApplet;
112 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLACCESS));
113 psh.pszCaption = Caption;
114 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
115 psh.nStartPage = 0;
116 psh.ppsp = psp;
117 psh.pfnCallback = PropSheetProc;
118
119 InitPropSheetPage(&psp[0], IDD_PROPPAGEKEYBOARD, KeyboardPageProc);
120 InitPropSheetPage(&psp[1], IDD_PROPPAGESOUND, SoundPageProc);
121 InitPropSheetPage(&psp[2], IDD_PROPPAGEDISPLAY, DisplayPageProc);
122 InitPropSheetPage(&psp[3], IDD_PROPPAGEMOUSE, MousePageProc);
123 InitPropSheetPage(&psp[4], IDD_PROPPAGEGENERAL, GeneralPageProc);
124
125 return (LONG)(PropertySheet(&psh) != -1);
126 }
127
128 /* Control Panel Callback */
129 LONG CALLBACK
130 CPlApplet(
131 HWND hwndCPl,
132 UINT uMsg,
133 LPARAM lParam1,
134 LPARAM lParam2)
135 {
136 int i = (int)lParam1;
137
138 switch(uMsg)
139 {
140 case CPL_INIT:
141 {
142 return TRUE;
143 }
144 case CPL_GETCOUNT:
145 {
146 return NUM_APPLETS;
147 }
148 case CPL_INQUIRE:
149 {
150 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
151 CPlInfo->lData = 0;
152 CPlInfo->idIcon = Applets[i].idIcon;
153 CPlInfo->idName = Applets[i].idName;
154 CPlInfo->idInfo = Applets[i].idDescription;
155 break;
156 }
157 case CPL_DBLCLK:
158 {
159 Applets[i].AppletProc();
160 break;
161 }
162 }
163 return FALSE;
164 }
165
166
167 BOOL STDCALL
168 DllMain(
169 HINSTANCE hinstDLL,
170 DWORD dwReason,
171 LPVOID lpvReserved)
172 {
173 switch(dwReason)
174 {
175 case DLL_PROCESS_ATTACH:
176 case DLL_THREAD_ATTACH:
177 hApplet = hinstDLL;
178 break;
179 }
180 return TRUE;
181 }
182