[MMSYS] Add icons for the sound tree (#1235)

CORE-15584
This commit is contained in:
Stanislav Motylkov 2019-01-13 21:13:20 +03:00 committed by Hermès BÉLUSCA - MAÏTO
parent da9accfba6
commit e0d80a4ab6
4 changed files with 106 additions and 4 deletions

View file

@ -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"

View file

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -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;