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