move more dlls
[reactos.git] / reactos / lib / cpl / cplsample / cplsample.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/cplsample/cplsample.c
23 * PURPOSE: ReactOS Sample Control Panel
24 * PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
25 * UPDATE HISTORY:
26 * 05-01-2004 Created
27 */
28 #include <windows.h>
29 #include <commctrl.h>
30 #include <cpl.h>
31
32 #include "resource.h"
33 #include "cplsample.h"
34
35 #define NUM_APPLETS (1)
36
37 LONG APIENTRY Applet1(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam);
38 HINSTANCE hApplet = 0;
39
40 /* Applets */
41 APPLET Applets[NUM_APPLETS] =
42 {
43 {IDC_CPLICON_1, IDS_CPLNAME_1, IDS_CPLDESCRIPTION_1, Applet1}
44 };
45
46 static void
47 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
48 {
49 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
50 psp->dwSize = sizeof(PROPSHEETPAGE);
51 psp->dwFlags = PSP_DEFAULT;
52 psp->hInstance = hApplet;
53 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
54 psp->pfnDlgProc = DlgProc;
55 }
56
57 /* Property page dialog callback */
58 INT_PTR CALLBACK
59 Page1Proc(
60 HWND hwndDlg,
61 UINT uMsg,
62 WPARAM wParam,
63 LPARAM lParam
64 )
65 {
66 switch(uMsg)
67 {
68 case WM_INITDIALOG:
69 break;
70 }
71 return FALSE;
72 }
73
74 /* Property page dialog callback */
75 INT_PTR CALLBACK
76 Page2Proc(
77 HWND hwndDlg,
78 UINT uMsg,
79 WPARAM wParam,
80 LPARAM lParam
81 )
82 {
83 switch(uMsg)
84 {
85 case WM_INITDIALOG:
86 break;
87 }
88 return FALSE;
89 }
90
91 /* Property page dialog callback */
92 INT_PTR CALLBACK
93 Page3Proc(
94 HWND hwndDlg,
95 UINT uMsg,
96 WPARAM wParam,
97 LPARAM lParam
98 )
99 {
100 switch(uMsg)
101 {
102 case WM_INITDIALOG:
103 break;
104 }
105 return FALSE;
106 }
107
108 /* Property Sheet Callback */
109 int CALLBACK
110 PropSheetProc(
111 HWND hwndDlg,
112 UINT uMsg,
113 LPARAM lParam
114 )
115 {
116 switch(uMsg)
117 {
118 case PSCB_BUTTONPRESSED:
119 switch(lParam)
120 {
121 case PSBTN_OK: /* OK */
122 break;
123 case PSBTN_CANCEL: /* Cancel */
124 break;
125 case PSBTN_APPLYNOW: /* Apply now */
126 break;
127 case PSBTN_FINISH: /* Close */
128 break;
129 default:
130 return FALSE;
131 }
132 break;
133
134 case PSCB_INITIALIZED:
135 break;
136 }
137 return TRUE;
138 }
139
140 /* First Applet */
141
142 LONG APIENTRY
143 Applet1(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
144 {
145 PROPSHEETPAGE psp[3];
146 PROPSHEETHEADER psh;
147 TCHAR Caption[1024];
148
149 LoadString(hApplet, IDS_CPLNAME_1, Caption, sizeof(Caption) / sizeof(TCHAR));
150
151 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
152 psh.dwSize = sizeof(PROPSHEETHEADER);
153 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
154 psh.hwndParent = NULL;
155 psh.hInstance = hApplet;
156 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON_1));
157 psh.pszCaption = Caption;
158 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
159 psh.nStartPage = 0;
160 psh.ppsp = psp;
161 psh.pfnCallback = PropSheetProc;
162
163 InitPropSheetPage(&psp[0], IDD_PROPPAGE1, Page1Proc);
164 InitPropSheetPage(&psp[1], IDD_PROPPAGE2, Page2Proc);
165 InitPropSheetPage(&psp[2], IDD_PROPPAGE3, Page3Proc);
166
167 return (LONG)(PropertySheet(&psh) != -1);
168 }
169
170 /* Control Panel Callback */
171 LONG CALLBACK
172 CPlApplet(
173 HWND hwndCPl,
174 UINT uMsg,
175 LPARAM lParam1,
176 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(hwndCPl, uMsg, lParam1, lParam2);
202 break;
203 }
204 }
205 return FALSE;
206 }
207
208
209 BOOL STDCALL
210 DllMain(
211 HINSTANCE hinstDLL,
212 DWORD dwReason,
213 LPVOID lpvReserved)
214 {
215 switch(dwReason)
216 {
217 case DLL_PROCESS_ATTACH:
218 case DLL_THREAD_ATTACH:
219 hApplet = hinstDLL;
220 break;
221 }
222 return TRUE;
223 }
224