added an initial mmsys.cpl. not added to the build system because w32api lacks a...
[reactos.git] / reactos / lib / 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 HWND WINAPI
40 DeviceCreateHardwarePageEx(HWND hWndParent,
41 LPGUID lpGuids,
42 UINT uNumberOfGuids,
43 UINT Unknown);
44
45 #define NUM_APPLETS (1)
46
47
48 HINSTANCE hApplet = 0;
49
50 /* Applets */
51 const APPLET Applets[NUM_APPLETS] =
52 {
53 {IDI_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, MmSysApplet},
54 };
55
56 /* Hardware property page dialog callback */
57 static INT_PTR CALLBACK
58 HardwareDlgProc(HWND hwndDlg,
59 UINT uMsg,
60 WPARAM wParam,
61 LPARAM lParam)
62 {
63 switch(uMsg)
64 {
65 case WM_INITDIALOG:
66 {
67 GUID Guids[] = {
68 GUID_DEVCLASS_CDROM,
69 GUID_DEVCLASS_MEDIA,
70 };
71
72 /* create the hardware page */
73 DeviceCreateHardwarePageEx(hwndDlg,
74 Guids,
75 sizeof(Guids) / sizeof(Guids[0]),
76 1);
77 break;
78 }
79 }
80
81 return FALSE;
82 }
83
84 LONG APIENTRY
85 MmSysApplet(HWND hwnd,
86 UINT uMsg,
87 LONG wParam,
88 LONG lParam)
89 {
90 PROPSHEETPAGE psp[1];
91 PROPSHEETHEADER psh = {0};
92 TCHAR Caption[256];
93
94 LoadString(hApplet,
95 IDS_CPLNAME,
96 Caption,
97 sizeof(Caption) / sizeof(TCHAR));
98
99 psh.dwSize = sizeof(PROPSHEETHEADER);
100 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
101 psh.hwndParent = NULL;
102 psh.hInstance = hApplet;
103 psh.hIcon = LoadIcon(hApplet,
104 MAKEINTRESOURCE(IDI_CPLICON));
105 psh.pszCaption = Caption;
106 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
107 psh.nStartPage = 0;
108 psh.ppsp = psp;
109
110 InitPropSheetPage(&psp[0],
111 IDD_HARDWARE,
112 HardwareDlgProc);
113
114 return (LONG)(PropertySheet(&psh) != -1);
115 }
116
117 VOID
118 InitPropSheetPage(PROPSHEETPAGE *psp,
119 WORD idDlg,
120 DLGPROC DlgProc)
121 {
122 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
123 psp->dwSize = sizeof(PROPSHEETPAGE);
124 psp->dwFlags = PSP_DEFAULT;
125 psp->hInstance = hApplet;
126 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
127 psp->pfnDlgProc = DlgProc;
128 }
129
130
131 /* Control Panel Callback */
132 LONG CALLBACK
133 CPlApplet(HWND hwndCpl,
134 UINT uMsg,
135 LPARAM lParam1,
136 LPARAM lParam2)
137 {
138 switch(uMsg)
139 {
140 case CPL_INIT:
141 return TRUE;
142
143 case CPL_GETCOUNT:
144 return NUM_APPLETS;
145
146 case CPL_INQUIRE:
147 {
148 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
149 UINT uAppIndex = (UINT)lParam1;
150
151 CPlInfo->lData = 0;
152 CPlInfo->idIcon = Applets[uAppIndex].idIcon;
153 CPlInfo->idName = Applets[uAppIndex].idName;
154 CPlInfo->idInfo = Applets[uAppIndex].idDescription;
155 break;
156 }
157
158 case CPL_DBLCLK:
159 {
160 UINT uAppIndex = (UINT)lParam1;
161 Applets[uAppIndex].AppletProc(hwndCpl,
162 uMsg,
163 lParam1,
164 lParam2);
165 break;
166 }
167 }
168
169 return FALSE;
170 }
171
172
173 BOOL STDCALL
174 DllMain(HINSTANCE hinstDLL,
175 DWORD dwReason,
176 LPVOID lpReserved)
177 {
178 switch(dwReason)
179 {
180 case DLL_PROCESS_ATTACH:
181 hApplet = hinstDLL;
182 DisableThreadLibraryCalls(hinstDLL);
183 break;
184 }
185
186 return TRUE;
187 }