Author: janderwald Date: Wed Sep 12 21:51:51 2007 New Revision: 29021
URL: http://svn.reactos.org/svn/reactos?rev=29021&view=rev Log: - start implementing sound scheme dialog
Added: trunk/reactos/dll/cpl/mmsys/sounds.c (with props) Modified: trunk/reactos/dll/cpl/mmsys/mmsys.c trunk/reactos/dll/cpl/mmsys/mmsys.h trunk/reactos/dll/cpl/mmsys/mmsys.rbuild
Modified: trunk/reactos/dll/cpl/mmsys/mmsys.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/mmsys.c?rev=2... ============================================================================== --- trunk/reactos/dll/cpl/mmsys/mmsys.c (original) +++ trunk/reactos/dll/cpl/mmsys/mmsys.c Wed Sep 12 21:51:51 2007 @@ -144,24 +144,7 @@ return FALSE; }
-/* Sounds property page dialog callback */ -static INT_PTR CALLBACK -SoundsDlgProc(HWND hwndDlg, - UINT uMsg, - WPARAM wParam, - LPARAM lParam) -{ - UNREFERENCED_PARAMETER(lParam); - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(hwndDlg); - switch(uMsg) - { - case WM_INITDIALOG: - break; - } - - return FALSE; -} +
/* Audio property page dialog callback */ static INT_PTR CALLBACK
Modified: trunk/reactos/dll/cpl/mmsys/mmsys.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/mmsys.h?rev=2... ============================================================================== --- trunk/reactos/dll/cpl/mmsys/mmsys.h (original) +++ trunk/reactos/dll/cpl/mmsys/mmsys.h Wed Sep 12 21:51:51 2007 @@ -27,6 +27,16 @@ LPARAM wParam, LPARAM lParam);
+/* sounds.c */ + +INT_PTR +CALLBACK +SoundsDlgProc(HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam); + + #endif /* __CPL_MMSYS_H */
/* EOF */
Modified: trunk/reactos/dll/cpl/mmsys/mmsys.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/mmsys.rbuild?... ============================================================================== --- trunk/reactos/dll/cpl/mmsys/mmsys.rbuild (original) +++ trunk/reactos/dll/cpl/mmsys/mmsys.rbuild Wed Sep 12 21:51:51 2007 @@ -13,6 +13,8 @@ <library>msvcrt</library> <library>devmgr</library> <library>gdi32</library> + <library>advapi32</library> <file>mmsys.c</file> + <file>sounds.c</file> <file>mmsys.rc</file> </module>
Added: trunk/reactos/dll/cpl/mmsys/sounds.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/mmsys/sounds.c?rev=... ============================================================================== --- trunk/reactos/dll/cpl/mmsys/sounds.c (added) +++ trunk/reactos/dll/cpl/mmsys/sounds.c Wed Sep 12 21:51:51 2007 @@ -1,0 +1,289 @@ +/* $Id: main.c 12852 2005-01-06 13:58:04Z mf $ + * + * PROJECT: ReactOS Multimedia Control Panel + * FILE: lib/cpl/mmsys/mmsys.c + * PURPOSE: ReactOS Multimedia Control Panel + * PROGRAMMER: Thomas Weidenmueller w3seek@reactos.com + * Johannes Anderwald janderwald@reactos.com + */ + +#include <windows.h> +#include <commctrl.h> +#include <setupapi.h> +#include <cpl.h> +#include <tchar.h> + +#include "mmsys.h" +#include "resource.h" + +BOOL +LoadEventLabel(HWND hwndDlg, HKEY hKey, TCHAR * szSubKey) +{ + HKEY hSubKey; + DWORD dwData; + DWORD dwDesc; + TCHAR szDesc[MAX_PATH]; + TCHAR szData[MAX_PATH]; + + + LRESULT lResult; + if (RegOpenKeyEx(hKey, + szSubKey, + 0, + KEY_READ, + &hSubKey) != ERROR_SUCCESS) + { + return FALSE; + } + + dwDesc = sizeof(szDesc) / sizeof(TCHAR); + if (RegQueryValueEx(hSubKey, + NULL, + NULL, + NULL, + (LPBYTE)szDesc, + &dwDesc) != ERROR_SUCCESS) + { + RegCloseKey(hSubKey); + return FALSE; + } + + dwData = sizeof(szDesc) / sizeof(TCHAR); + if (RegQueryValueEx(hSubKey, + _T("DispFileName"), + NULL, + NULL, + (LPBYTE)szData, + &dwData) != ERROR_SUCCESS) + { + RegCloseKey(hSubKey); + return FALSE; + } + + + //FIXME + //lResult = SendDlgItemMessage(hwndDlg, + lResult = 0; + return TRUE; +} + + + +BOOL +LoadEventLabels(HWND hwndDlg, HKEY hKey) +{ + HKEY hSubKey; + DWORD dwCurKey; + TCHAR szName[MAX_PATH]; + DWORD dwName; + DWORD dwResult; + DWORD dwCount; + if (RegOpenKeyEx(hKey, + _T("EventLabels"), + 0, + KEY_READ, + &hSubKey) != ERROR_SUCCESS) + { + return FALSE; + } + + dwCurKey = 0; + dwCount = 0; + do + { + dwName = sizeof(szName) / sizeof(szName[0]); + dwResult = RegEnumKeyEx(hSubKey, + dwCurKey, + szName, + &dwName, + NULL, + NULL, + NULL, + NULL); + + if (dwResult == ERROR_SUCCESS) + { + if (LoadEventLabel(hwndDlg, hSubKey, szName)) + { + dwCount++; + } + } + dwCurKey++; + + }while(dwResult == ERROR_SUCCESS); + + RegCloseKey(hSubKey); + return (dwCount != 0); +} + +BOOL +AddSoundScheme(HWND hwndDlg, HKEY hKey, TCHAR * szSubKey, BOOL SetDefault) +{ + HKEY hSubKey; + TCHAR szValue[MAX_PATH]; + DWORD dwValue, dwResult; + + if (RegOpenKeyEx(hKey, + szSubKey, + 0, + KEY_READ, + &hSubKey) != ERROR_SUCCESS) + { + return FALSE; + } + + dwValue = sizeof(szValue) / sizeof(TCHAR); + dwResult = RegQueryValueEx(hSubKey, + NULL, + NULL, + NULL, + (LPBYTE)szValue, + &dwValue); + RegCloseKey(hSubKey); + if (dwResult == ERROR_SUCCESS) + { + LRESULT lResult = SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValue); + if (lResult != CB_ERR) + { + /// + /// FIXME store a context struct + /// + SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)szSubKey); + if (SetDefault) + { + SendDlgItemMessage(hwndDlg, IDC_SOUND_SCHEME, CB_SETCURSEL, (WPARAM)lResult, (LPARAM)0); + } + } + return TRUE; + } + return FALSE; +} + + + +BOOL +EnumerateSoundSchemes(HWND hwndDlg, HKEY hKey) +{ + HKEY hSubKey; + DWORD dwName, dwCurKey, dwResult, dwNumSchemes; + TCHAR szName[MAX_PATH]; + TCHAR szDefault[MAX_PATH]; + + dwName = sizeof(szDefault) / sizeof(TCHAR); + if (RegQueryValueEx(hKey, + NULL, + NULL, + NULL, + (LPBYTE)szDefault, + &dwName) != ERROR_SUCCESS) + { + return FALSE; + } + + + + if (RegOpenKeyEx(hKey, + _T("Names"), + 0, + KEY_READ, + &hSubKey) != ERROR_SUCCESS) + { + return FALSE; + } + + dwNumSchemes = 0; + dwCurKey = 0; + do + { + dwName = sizeof(szName) / sizeof(szName[0]); + dwResult = RegEnumKeyEx(hSubKey, + dwCurKey, + szName, + &dwName, + NULL, + NULL, + NULL, + NULL); + + if (dwResult == ERROR_SUCCESS) + { + if (AddSoundScheme(hwndDlg, hSubKey, szName, (!_tcscmp(szName, szDefault)))) + { + dwNumSchemes++; + } + } + + dwCurKey++; + }while(dwResult == ERROR_SUCCESS); + + RegCloseKey(hSubKey); + return (dwNumSchemes != 0); +} + + +BOOL +LoadSoundSchemes(HWND hwndDlg, HKEY hKey) +{ + HKEY hSubKey; + BOOL Result; + + if (RegOpenKeyEx(hKey, + _T("Schemes"), + 0, + KEY_READ, + &hSubKey) != ERROR_SUCCESS) + { + return FALSE; + } + + + + Result = EnumerateSoundSchemes(hwndDlg, hSubKey); + RegCloseKey(hSubKey); + + return Result; +} + + + +BOOL +InitSoundSettings(HWND hwndDlg) +{ + HKEY hKey; + + if (RegOpenKey(HKEY_CURRENT_USER, + _T("AppEvents"), + &hKey) != ERROR_SUCCESS) + { + return FALSE; + } + + LoadEventLabels(hwndDlg, hKey); + LoadSoundSchemes(hwndDlg, hKey); + + RegCloseKey(hKey); + + return TRUE; +} + + +/* Sounds property page dialog callback */ +INT_PTR +CALLBACK +SoundsDlgProc(HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) +{ + UNREFERENCED_PARAMETER(lParam); + UNREFERENCED_PARAMETER(wParam); + UNREFERENCED_PARAMETER(hwndDlg); + switch(uMsg) + { + case WM_INITDIALOG: + InitSoundSettings(hwndDlg); + break; + } + + return FALSE; +}
Propchange: trunk/reactos/dll/cpl/mmsys/sounds.c ------------------------------------------------------------------------------ svn:eol-style = native