8a595a57bac7e3f8925e89fde6579c660b5965e7
[reactos.git] / reactos / lib / cpl / desk / desk.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: desk.c,v 1.3 2004/10/13 10:17:41 ekohl Exp $
20 *
21 * PROJECT: ReactOS Display Control Panel
22 * FILE: lib/cpl/desk/desk.c
23 * PURPOSE: ReactOS Display Control Panel
24 * PROGRAMMER: Gero Kuehn (reactos.filter@gkware.com)
25 * UPDATE HISTORY:
26 * 06-17-2004 Created
27 * 08-07-2004 Initial Checkin
28 */
29
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <stdarg.h>
33 #include <tchar.h>
34 #include <windows.h>
35
36 #include <commctrl.h>
37 #include <cpl.h>
38
39 #include <process.h>
40
41 #include "resource.h"
42 #include "desk.h"
43
44 #define NUM_APPLETS (1)
45
46 LONG CALLBACK DisplayApplet(VOID);
47 INT_PTR CALLBACK BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
48 INT_PTR CALLBACK ScreenSaverPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
49 INT_PTR CALLBACK AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
50 INT_PTR CALLBACK SettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
51
52
53 HINSTANCE hApplet = 0;
54
55 /* Applets */
56 APPLET Applets[NUM_APPLETS] =
57 {
58 {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, DisplayApplet}
59 };
60
61
62
63 /* Property page dialog callback */
64 INT_PTR CALLBACK
65 BackgroundPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
66 {
67 switch(uMsg)
68 {
69 case WM_INITDIALOG:
70 break;
71 case WM_COMMAND:
72 break;
73 }
74 return FALSE;
75 }
76
77
78 /* Property page dialog callback */
79 INT_PTR CALLBACK
80 ScreenSaverPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
81 {
82 switch(uMsg)
83 {
84 case WM_INITDIALOG:
85 break;
86 case WM_COMMAND:
87 break;
88 }
89 return FALSE;
90 }
91
92
93 /* Property page dialog callback */
94 INT_PTR CALLBACK
95 AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
96 {
97 switch(uMsg)
98 {
99 case WM_INITDIALOG:
100 break;
101 case WM_COMMAND:
102 break;
103 }
104 return FALSE;
105 }
106
107
108 /* Property page dialog callback */
109 INT_PTR CALLBACK
110 SettingsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
111 {
112 switch(uMsg)
113 {
114 case WM_INITDIALOG:
115 break;
116 case WM_COMMAND:
117 break;
118 }
119 return FALSE;
120 }
121
122
123 static VOID
124 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
125 {
126 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
127 psp->dwSize = sizeof(PROPSHEETPAGE);
128 psp->dwFlags = PSP_DEFAULT;
129 psp->hInstance = hApplet;
130 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
131 psp->pfnDlgProc = DlgProc;
132 }
133
134
135 /* First Applet */
136
137 LONG CALLBACK
138 DisplayApplet(VOID)
139 {
140 PROPSHEETPAGE psp[4];
141 PROPSHEETHEADER psh;
142 TCHAR Caption[1024];
143
144 LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
145
146 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
147 psh.dwSize = sizeof(PROPSHEETHEADER);
148 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
149 psh.hwndParent = NULL;
150 psh.hInstance = hApplet;
151 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
152 psh.pszCaption = Caption;
153 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
154 psh.nStartPage = 0;
155 psh.ppsp = psp;
156 psh.pfnCallback = NULL;
157
158 InitPropSheetPage(&psp[0], IDD_PROPPAGEBACKGROUND, BackgroundPageProc);
159 InitPropSheetPage(&psp[1], IDD_PROPPAGESCREENSAVER, ScreenSaverPageProc);
160 InitPropSheetPage(&psp[2], IDD_PROPPAGEAPPEARANCE, AppearancePageProc);
161 InitPropSheetPage(&psp[3], IDD_PROPPAGESETTINGS, SettingsPageProc);
162
163 return (LONG)(PropertySheet(&psh) != -1);
164 }
165
166
167 /* Control Panel Callback */
168 LONG CALLBACK
169 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
170 {
171 int i = (int)lParam1;
172
173 switch(uMsg)
174 {
175 case CPL_INIT:
176 {
177 return TRUE;
178 }
179 case CPL_GETCOUNT:
180 {
181 return NUM_APPLETS;
182 }
183 case CPL_INQUIRE:
184 {
185 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
186 CPlInfo->lData = 0;
187 CPlInfo->idIcon = Applets[i].idIcon;
188 CPlInfo->idName = Applets[i].idName;
189 CPlInfo->idInfo = Applets[i].idDescription;
190 break;
191 }
192 case CPL_DBLCLK:
193 {
194 Applets[i].AppletProc();
195 break;
196 }
197 }
198 return FALSE;
199 }
200
201
202 BOOL WINAPI
203 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
204 {
205 switch(dwReason)
206 {
207 case DLL_PROCESS_ATTACH:
208 case DLL_THREAD_ATTACH:
209 hApplet = hinstDLL;
210 break;
211 }
212 return TRUE;
213 }
214