https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e0d80a4ab60a41e94fa7e…
commit e0d80a4ab60a41e94fa7e48bd4c78371adaa6c53
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Sun Jan 13 21:13:20 2019 +0300
Commit: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Jan 13 19:13:20 2019 +0100
[MMSYS] Add icons for the sound tree (#1235)
CORE-15584
---
dll/cpl/mmsys/mmsys.rc | 4 +-
dll/cpl/mmsys/resource.h | 7 +++
dll/cpl/mmsys/resources/4366.ico | Bin 318 -> 22486 bytes
dll/cpl/mmsys/sounds.c | 99 ++++++++++++++++++++++++++++++++++++++-
4 files changed, 106 insertions(+), 4 deletions(-)
diff --git a/dll/cpl/mmsys/mmsys.rc b/dll/cpl/mmsys/mmsys.rc
index 603ad5d47a..3d0a87380f 100644
--- a/dll/cpl/mmsys/mmsys.rc
+++ b/dll/cpl/mmsys/mmsys.rc
@@ -27,8 +27,8 @@ IDI_JOY_ICON ICON "resources/4361.ico"
4363 ICON "resources/4363.ico"
IDI_CAMERA_ICON ICON "resources/4364.ico"
4365 ICON "resources/4365.ico"
-4366 ICON "resources/4366.ico"
-4367 ICON "resources/4367.ico"
+IDI_SOUND_SECTION ICON "resources/4366.ico"
+IDI_SOUND_ASSIGNED ICON "resources/4367.ico"
4368 ICON "resources/4368.ico"
4369 ICON "resources/4369.ico"
4370 ICON "resources/4370.ico"
diff --git a/dll/cpl/mmsys/resource.h b/dll/cpl/mmsys/resource.h
index 246f9ef2d0..e5aff82484 100644
--- a/dll/cpl/mmsys/resource.h
+++ b/dll/cpl/mmsys/resource.h
@@ -7,6 +7,8 @@
#define IDI_MIDICON 3007
#define IDI_JOY_ICON 4361
#define IDI_CAMERA_ICON 4364
+#define IDI_SOUND_SECTION 4366
+#define IDI_SOUND_ASSIGNED 4367
#define IDI_SHUTDOWN_ICON 3009
#define IDI_NO_HW 4390
#define IDI_MUTED_ICON 4393
@@ -77,3 +79,8 @@
#define IDS_CPLDESCRIPTION 1001
#define IDS_NO_SOUND 1002
#define IDS_NO_DEVICES 1003
+
+/* Sounds Image List */
+#define IMAGE_SOUND_SECTION 0
+#define IMAGE_SOUND_ASSIGNED 1
+#define IMAGE_SOUND_NONE 2
diff --git a/dll/cpl/mmsys/resources/4366.ico b/dll/cpl/mmsys/resources/4366.ico
index 16972b9024..34bde78121 100644
Binary files a/dll/cpl/mmsys/resources/4366.ico and b/dll/cpl/mmsys/resources/4366.ico
differ
diff --git a/dll/cpl/mmsys/sounds.c b/dll/cpl/mmsys/sounds.c
index 4976e2322f..1fc9fb9e8c 100644
--- a/dll/cpl/mmsys/sounds.c
+++ b/dll/cpl/mmsys/sounds.c
@@ -57,6 +57,7 @@ static PLABEL_MAP s_Map = NULL;
static PAPP_MAP s_App = NULL;
TCHAR szDefault[MAX_PATH];
+HIMAGELIST hSoundsImageList = NULL;
/* A filter string is a list separated by NULL and ends with double NULLs. */
LPWSTR MakeFilter(LPWSTR psz)
@@ -813,6 +814,7 @@ ShowSoundScheme(HWND hwndDlg)
PSOUND_SCHEME_CONTEXT pScheme;
PAPP_MAP pAppMap;
PLABEL_MAP pLabelMap;
+ PLABEL_CONTEXT pLabelContext;
HWND hDlgCtrl, hList;
TVINSERTSTRUCT tvItem;
HTREEITEM hTreeItem;
@@ -820,6 +822,11 @@ ShowSoundScheme(HWND hwndDlg)
hDlgCtrl = GetDlgItem(hwndDlg, IDC_SOUND_SCHEME);
hList = GetDlgItem(hwndDlg, IDC_SCHEME_LIST);
+ if (hSoundsImageList != NULL)
+ {
+ TreeView_SetImageList(hList, hSoundsImageList, TVSIL_NORMAL);
+ }
+
lIndex = SendMessage(hDlgCtrl, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
if (lIndex == CB_ERR)
{
@@ -842,10 +849,12 @@ ShowSoundScheme(HWND hwndDlg)
tvItem.hParent = TVI_ROOT;
tvItem.hInsertAfter = TVI_FIRST;
- tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM;
+ tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE |
TVIF_SELECTEDIMAGE;
tvItem.item.state = TVIS_EXPANDED;
tvItem.item.stateMask = TVIS_EXPANDED;
tvItem.item.pszText = pAppMap->szDesc;
+ tvItem.item.iImage = IMAGE_SOUND_SECTION;
+ tvItem.item.iSelectedImage = IMAGE_SOUND_SECTION;
tvItem.item.lParam = (LPARAM)NULL;
hTreeItem = TreeView_InsertItem(hList, &tvItem);
@@ -853,14 +862,26 @@ ShowSoundScheme(HWND hwndDlg)
pLabelMap = pAppMap->LabelMap;
while (pLabelMap)
{
+ pLabelContext = FindLabelContext(pScheme, pAppMap->szName,
pLabelMap->szName);
+
ZeroMemory(&tvItem, sizeof(tvItem));
tvItem.hParent = /*TVI_ROOT;*/ hTreeItem;
tvItem.hInsertAfter = TVI_SORT;
- tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM;
+ tvItem.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE |
TVIF_SELECTEDIMAGE;
tvItem.item.state = TVIS_EXPANDED;
tvItem.item.stateMask = TVIS_EXPANDED;
tvItem.item.pszText = pLabelMap->szDesc;
+ if (pLabelContext->szValue && _tcslen(pLabelContext->szValue)
> 0)
+ {
+ tvItem.item.iImage = IMAGE_SOUND_ASSIGNED;
+ tvItem.item.iSelectedImage = IMAGE_SOUND_ASSIGNED;
+ }
+ else
+ {
+ tvItem.item.iImage = IMAGE_SOUND_NONE;
+ tvItem.item.iSelectedImage = IMAGE_SOUND_NONE;
+ }
tvItem.item.lParam = (LPARAM)FindLabelContext(pScheme, pAppMap->szName,
pLabelMap->szName);
TreeView_InsertItem(hList, &tvItem);
@@ -940,6 +961,68 @@ ApplyChanges(HWND hwndDlg)
}
+HIMAGELIST
+InitImageList(UINT StartResource,
+ UINT EndResource,
+ UINT Width,
+ UINT Height,
+ ULONG type)
+{
+ HANDLE hImage;
+ HIMAGELIST himl;
+ UINT i;
+ INT ret;
+
+ /* Create the toolbar icon image list */
+ himl = ImageList_Create(Width,
+ Height,
+ ILC_MASK | ILC_COLOR32,
+ EndResource - StartResource,
+ 0);
+ if (himl == NULL)
+ return NULL;
+
+ ret = 0;
+ for (i = StartResource; i <= EndResource && ret != -1; i++)
+ {
+ hImage = LoadImageW(hApplet,
+ MAKEINTRESOURCEW(i),
+ type,
+ Width,
+ Height,
+ LR_LOADTRANSPARENT);
+ if (hImage == NULL)
+ {
+ ImageList_Destroy(himl);
+ himl = NULL;
+ break;
+ }
+
+ if (type == IMAGE_BITMAP)
+ {
+ ret = ImageList_AddMasked(himl,
+ hImage,
+ RGB(255, 0, 128));
+ }
+ else if (type == IMAGE_ICON)
+ {
+ ret = ImageList_AddIcon(himl,
+ hImage);
+ }
+
+ DeleteObject(hImage);
+ }
+
+ if (ret == -1)
+ {
+ ImageList_Destroy(himl);
+ himl = NULL;
+ }
+
+ return himl;
+}
+
+
/* Sounds property page dialog callback */
INT_PTR
CALLBACK
@@ -964,6 +1047,12 @@ SoundsDlgProc(HWND hwndDlg,
BM_SETIMAGE,(WPARAM)IMAGE_ICON,
(LPARAM)(HANDLE)LoadIcon(hApplet,
MAKEINTRESOURCE(IDI_PLAY_ICON)));
+ hSoundsImageList = InitImageList(IDI_SOUND_SECTION,
+ IDI_SOUND_ASSIGNED,
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CXSMICON),
+ IMAGE_ICON);
+
LoadEventLabels();
LoadSoundProfiles(hwndDlg);
LoadSoundFiles(hwndDlg);
@@ -1114,6 +1203,12 @@ SoundsDlgProc(HWND hwndDlg,
}
break;
}
+ case WM_DESTROY:
+ {
+ if (hSoundsImageList)
+ ImageList_Destroy(hSoundsImageList);
+ break;
+ }
case WM_NOTIFY:
{
PLABEL_CONTEXT pLabelContext;