reshuffling of dlls
[reactos.git] / reactos / dll / cpl / mmsys / mmsys.c
1 /*
2 * ReactOS
3 * Copyright (C) 2005 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: main.c 12852 2005-01-06 13:58:04Z mf $
20 *
21 * PROJECT: ReactOS Multimedia Control Panel
22 * FILE: lib/cpl/mmsys/mmsys.c
23 * PURPOSE: ReactOS Multimedia Control Panel
24 * PROGRAMMER: Thoams Weidenmueller <w3seek@reactos.com>
25 * UPDATE HISTORY:
26 * 2005/11/23 Created
27 */
28 #include <windows.h>
29 #include <commctrl.h>
30 #include <initguid.h>
31 #include <cfgmgr32.h>
32 #include <setupapi.h>
33 #include <devguid.h>
34 #include <cpl.h>
35
36 #include "mmsys.h"
37 #include "resource.h"
38
39 typedef enum
40 {
41 HWPD_STANDARDLIST = 0,
42 HWPD_LARGELIST,
43 HWPD_MAX = HWPD_LARGELIST
44 } HWPAGE_DISPLAYMODE, *PHWPAGE_DISPLAYMODE;
45
46 HWND WINAPI
47 DeviceCreateHardwarePageEx(HWND hWndParent,
48 LPGUID lpGuids,
49 UINT uNumberOfGuids,
50 HWPAGE_DISPLAYMODE DisplayMode);
51
52 #define NUM_APPLETS (1)
53
54
55 HINSTANCE hApplet = 0;
56
57 /* Applets */
58 const APPLET Applets[NUM_APPLETS] =
59 {
60 {IDI_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, MmSysApplet},
61 };
62
63 /* Hardware property page dialog callback */
64 static INT_PTR CALLBACK
65 HardwareDlgProc(HWND hwndDlg,
66 UINT uMsg,
67 WPARAM wParam,
68 LPARAM lParam)
69 {
70 switch(uMsg)
71 {
72 case WM_INITDIALOG:
73 {
74 GUID Guids[] = {
75 GUID_DEVCLASS_CDROM,
76 GUID_DEVCLASS_MEDIA,
77 };
78
79 /* create the hardware page */
80 DeviceCreateHardwarePageEx(hwndDlg,
81 Guids,
82 sizeof(Guids) / sizeof(Guids[0]),
83 HWPD_LARGELIST);
84 break;
85 }
86 }
87
88 return FALSE;
89 }
90
91 LONG APIENTRY
92 MmSysApplet(HWND hwnd,
93 UINT uMsg,
94 LONG wParam,
95 LONG lParam)
96 {
97 PROPSHEETPAGE psp[1];
98 PROPSHEETHEADER psh = {0};
99 TCHAR Caption[256];
100
101 LoadString(hApplet,
102 IDS_CPLNAME,
103 Caption,
104 sizeof(Caption) / sizeof(TCHAR));
105
106 psh.dwSize = sizeof(PROPSHEETHEADER);
107 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
108 psh.hwndParent = NULL;
109 psh.hInstance = hApplet;
110 psh.hIcon = LoadIcon(hApplet,
111 MAKEINTRESOURCE(IDI_CPLICON));
112 psh.pszCaption = Caption;
113 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
114 psh.nStartPage = 0;
115 psh.ppsp = psp;
116
117 InitPropSheetPage(&psp[0],
118 IDD_HARDWARE,
119 HardwareDlgProc);
120
121 return (LONG)(PropertySheet(&psh) != -1);
122 }
123
124 VOID
125 InitPropSheetPage(PROPSHEETPAGE *psp,
126 WORD idDlg,
127 DLGPROC DlgProc)
128 {
129 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
130 psp->dwSize = sizeof(PROPSHEETPAGE);
131 psp->dwFlags = PSP_DEFAULT;
132 psp->hInstance = hApplet;
133 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
134 psp->pfnDlgProc = DlgProc;
135 }
136
137
138 /* Control Panel Callback */
139 LONG CALLBACK
140 CPlApplet(HWND hwndCpl,
141 UINT uMsg,
142 LPARAM lParam1,
143 LPARAM lParam2)
144 {
145 switch(uMsg)
146 {
147 case CPL_INIT:
148 return TRUE;
149
150 case CPL_GETCOUNT:
151 return NUM_APPLETS;
152
153 case CPL_INQUIRE:
154 {
155 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
156 UINT uAppIndex = (UINT)lParam1;
157
158 CPlInfo->lData = 0;
159 CPlInfo->idIcon = Applets[uAppIndex].idIcon;
160 CPlInfo->idName = Applets[uAppIndex].idName;
161 CPlInfo->idInfo = Applets[uAppIndex].idDescription;
162 break;
163 }
164
165 case CPL_DBLCLK:
166 {
167 UINT uAppIndex = (UINT)lParam1;
168 Applets[uAppIndex].AppletProc(hwndCpl,
169 uMsg,
170 lParam1,
171 lParam2);
172 break;
173 }
174 }
175
176 return FALSE;
177 }
178
179
180 BOOL STDCALL
181 DllMain(HINSTANCE hinstDLL,
182 DWORD dwReason,
183 LPVOID lpReserved)
184 {
185 switch(dwReason)
186 {
187 case DLL_PROCESS_ATTACH:
188 hApplet = hinstDLL;
189 DisableThreadLibraryCalls(hinstDLL);
190 break;
191 }
192
193 return TRUE;
194 }