2013-01-24 23:00:42 +00:00
|
|
|
/*
|
2011-04-06 21:05:05 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Sound Volume Control
|
2015-09-09 13:13:35 +00:00
|
|
|
* FILE: base/applications/sndvol32/dialog.c
|
2011-04-06 21:05:05 +00:00
|
|
|
* PROGRAMMERS: Johannes Anderwald
|
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "sndvol32.h"
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2014-01-13 12:42:34 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
VOID
|
|
|
|
ConvertRect(LPRECT lpRect, UINT xBaseUnit, UINT yBaseUnit)
|
|
|
|
{
|
|
|
|
lpRect->left = MulDiv(lpRect->left, xBaseUnit, 4);
|
|
|
|
lpRect->right = MulDiv(lpRect->right, xBaseUnit, 4);
|
|
|
|
lpRect->top = MulDiv(lpRect->top, yBaseUnit, 8);
|
|
|
|
lpRect->bottom = MulDiv(lpRect->bottom, yBaseUnit, 8);
|
|
|
|
}
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
LPVOID
|
|
|
|
LoadDialogResource(
|
|
|
|
IN HMODULE hModule,
|
|
|
|
IN LPCWSTR ResourceName,
|
|
|
|
OUT LPDWORD ResourceLength)
|
|
|
|
{
|
|
|
|
HRSRC hSrc;
|
|
|
|
HGLOBAL hRes;
|
|
|
|
PVOID Result;
|
|
|
|
|
|
|
|
/* find resource */
|
|
|
|
hSrc = FindResourceW(hModule, ResourceName, (LPCWSTR)RT_DIALOG);
|
|
|
|
|
|
|
|
if (!hSrc)
|
|
|
|
{
|
|
|
|
/* failed to find resource */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now load the resource */
|
|
|
|
hRes = LoadResource(hAppInstance, hSrc);
|
|
|
|
if (!hRes)
|
|
|
|
{
|
|
|
|
/* failed to load resource */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now lock the resource */
|
|
|
|
Result = LockResource(hRes);
|
|
|
|
|
|
|
|
if (!Result)
|
|
|
|
{
|
|
|
|
/* failed to lock resource */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ResourceLength)
|
|
|
|
{
|
|
|
|
/* store output length */
|
|
|
|
*ResourceLength = SizeofResource(hAppInstance, hSrc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
LPWORD
|
|
|
|
AddDialogControl(
|
|
|
|
IN HWND hwndDialog,
|
|
|
|
IN HWND * OutWnd,
|
|
|
|
IN LPRECT DialogOffset,
|
|
|
|
IN PDLGITEMTEMPLATE DialogItem,
|
|
|
|
IN DWORD DialogIdMultiplier,
|
2018-03-10 20:10:40 +00:00
|
|
|
IN HFONT hFont,
|
|
|
|
UINT xBaseUnit,
|
|
|
|
UINT yBaseUnit)
|
2011-04-06 21:05:05 +00:00
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
LPWORD Offset;
|
|
|
|
LPWSTR ClassName, WindowName = NULL;
|
|
|
|
HWND hwnd;
|
|
|
|
DWORD wID;
|
2018-03-15 21:03:33 +00:00
|
|
|
INT nSteps, i;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
/* initialize client rectangle */
|
2018-03-10 20:10:40 +00:00
|
|
|
rect.left = DialogItem->x;
|
|
|
|
rect.top = DialogItem->y;
|
|
|
|
rect.right = DialogItem->x + DialogItem->cx;
|
|
|
|
rect.bottom = DialogItem->y + DialogItem->cy;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
/* Convert Dialog units to pixes */
|
|
|
|
ConvertRect(&rect, xBaseUnit, yBaseUnit);
|
|
|
|
|
|
|
|
rect.left += DialogOffset->left;
|
|
|
|
rect.right += DialogOffset->left;
|
|
|
|
rect.top += DialogOffset->top;
|
|
|
|
rect.bottom += DialogOffset->top;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
/* move offset after dialog item */
|
|
|
|
Offset = (LPWORD)(DialogItem + 1);
|
|
|
|
|
|
|
|
if (*Offset == 0xFFFF)
|
|
|
|
{
|
|
|
|
/* class is encoded as type */
|
|
|
|
Offset++;
|
|
|
|
|
|
|
|
/* get control type */
|
|
|
|
switch(*Offset)
|
|
|
|
{
|
|
|
|
case 0x80:
|
|
|
|
ClassName = L"button";
|
|
|
|
WindowName = (LPWSTR)(Offset + 1);
|
|
|
|
break ;
|
|
|
|
case 0x82:
|
|
|
|
ClassName = L"static";
|
|
|
|
WindowName = (LPWSTR)(Offset + 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* FIXME */
|
|
|
|
assert(0);
|
2018-01-26 21:30:15 +00:00
|
|
|
ClassName = NULL;
|
2011-04-06 21:05:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* class name is encoded as string */
|
|
|
|
ClassName = (LPWSTR)Offset;
|
|
|
|
|
2018-01-26 21:30:15 +00:00
|
|
|
/* move offset to the end of class string */
|
|
|
|
Offset += wcslen(ClassName);
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-01-26 21:30:15 +00:00
|
|
|
/* get window name */
|
2011-04-06 21:05:05 +00:00
|
|
|
WindowName = (LPWSTR)(Offset + 1);
|
|
|
|
}
|
2018-01-26 21:30:15 +00:00
|
|
|
|
|
|
|
/* move offset past class type/string */
|
|
|
|
Offset++;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
if (DialogItem->id == MAXWORD)
|
|
|
|
{
|
|
|
|
/* id is not important */
|
|
|
|
wID = DialogItem->id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* calculate id */
|
|
|
|
wID = DialogItem->id * (DialogIdMultiplier + 1);
|
|
|
|
|
|
|
|
}
|
2018-03-15 21:03:33 +00:00
|
|
|
|
|
|
|
/* Hack: Disable TBS_AUTOTICKS because it looks ugly */
|
|
|
|
if (!wcsicmp(ClassName, L"msctls_trackbar32"))
|
|
|
|
DialogItem->style &= ~TBS_AUTOTICKS;
|
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
/* now create the window */
|
2011-04-08 23:18:20 +00:00
|
|
|
hwnd = CreateWindowExW(DialogItem->dwExtendedStyle,
|
|
|
|
ClassName,
|
|
|
|
WindowName,
|
|
|
|
DialogItem->style,
|
|
|
|
rect.left,
|
2011-04-06 21:05:05 +00:00
|
|
|
rect.top,
|
2018-03-10 20:10:40 +00:00
|
|
|
rect.right - rect.left,
|
|
|
|
rect.bottom - rect.top,
|
2011-04-06 21:05:05 +00:00
|
|
|
hwndDialog,
|
|
|
|
(HMENU)(wID),
|
|
|
|
hAppInstance,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
/* store window */
|
|
|
|
*OutWnd = hwnd;
|
|
|
|
|
|
|
|
/* check if this the track bar */
|
|
|
|
if (!wcsicmp(ClassName, L"msctls_trackbar32"))
|
|
|
|
{
|
2018-03-15 21:03:33 +00:00
|
|
|
if (DialogItem->style & TBS_VERT)
|
|
|
|
{
|
|
|
|
/* Vertical trackbar: Volume */
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-15 21:03:33 +00:00
|
|
|
/* set up range */
|
|
|
|
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, VOLUME_STEPS));
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-15 21:03:33 +00:00
|
|
|
/* set up page size */
|
|
|
|
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)VOLUME_PAGE_SIZE);
|
2011-04-07 21:31:21 +00:00
|
|
|
|
2018-03-15 21:03:33 +00:00
|
|
|
/* set position */
|
|
|
|
SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)0);
|
2011-04-07 21:31:21 +00:00
|
|
|
|
2018-03-15 21:03:33 +00:00
|
|
|
/* Calculate and set ticks */
|
|
|
|
nSteps = (VOLUME_STEPS / (VOLUME_TICKS + 1));
|
|
|
|
if (VOLUME_STEPS % (VOLUME_TICKS + 1) != 0)
|
|
|
|
nSteps++;
|
|
|
|
for (i = nSteps; i < VOLUME_STEPS; i += nSteps)
|
|
|
|
SendMessage(hwnd, TBM_SETTIC, 0, (LPARAM)i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Horizontal trackbar: Balance */
|
|
|
|
|
|
|
|
/* set up range */
|
|
|
|
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(0, BALANCE_STEPS));
|
|
|
|
|
|
|
|
/* set up page size */
|
|
|
|
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)BALANCE_PAGE_SIZE);
|
|
|
|
|
|
|
|
/* set position */
|
|
|
|
SendMessage(hwnd, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)BALANCE_STEPS / 2);
|
|
|
|
|
|
|
|
/* Calculate and set ticks */
|
|
|
|
nSteps = (BALANCE_STEPS / (BALANCE_TICKS + 1));
|
|
|
|
if (BALANCE_STEPS % (BALANCE_TICKS + 1) != 0)
|
|
|
|
nSteps++;
|
|
|
|
for (i = nSteps; i < BALANCE_STEPS; i += nSteps)
|
|
|
|
SendMessage(hwnd, TBM_SETTIC, 0, (LPARAM)i);
|
|
|
|
}
|
2011-04-06 21:05:05 +00:00
|
|
|
}
|
|
|
|
else if (!wcsicmp(ClassName, L"static") || !wcsicmp(ClassName, L"button"))
|
|
|
|
{
|
|
|
|
/* set font */
|
|
|
|
SendMessageW(hwnd, WM_SETFONT, (WPARAM)hFont, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//ShowWindow(hwnd, SW_SHOWNORMAL);
|
|
|
|
|
|
|
|
if (WindowName != NULL)
|
|
|
|
{
|
2018-01-26 21:30:15 +00:00
|
|
|
/* move offset past window name */
|
|
|
|
Offset += wcslen(WindowName) + 1;
|
2011-04-06 21:05:05 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 23:18:20 +00:00
|
|
|
/* check if there is additional data */
|
2011-04-06 21:05:05 +00:00
|
|
|
if (*Offset == 0)
|
|
|
|
{
|
|
|
|
/* no additional data */
|
|
|
|
Offset++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-01-26 21:30:15 +00:00
|
|
|
/* FIXME: Determine whether this should be "Offset += 1 + *Offset" to explicitly skip the data count too. */
|
|
|
|
/* skip past additional data */
|
2011-04-06 21:05:05 +00:00
|
|
|
Offset += *Offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure next template is word-aligned */
|
|
|
|
Offset = (LPWORD)(((ULONG_PTR)Offset + 3) & ~3);
|
|
|
|
|
|
|
|
/* done */
|
|
|
|
return Offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
LoadDialogControls(
|
|
|
|
IN PMIXER_WINDOW MixerWindow,
|
|
|
|
LPRECT DialogOffset,
|
2018-03-10 20:10:40 +00:00
|
|
|
WORD ItemCount,
|
|
|
|
PDLGITEMTEMPLATE DialogItem,
|
|
|
|
DWORD DialogIdMultiplier,
|
|
|
|
UINT xBaseUnit,
|
|
|
|
UINT yBaseUnit)
|
2011-04-06 21:05:05 +00:00
|
|
|
{
|
|
|
|
LPWORD Offset;
|
2018-03-10 20:10:40 +00:00
|
|
|
WORD Index;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
/* sanity check */
|
2018-03-10 20:10:40 +00:00
|
|
|
assert(ItemCount);
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
if (MixerWindow->Window)
|
2018-03-10 20:10:40 +00:00
|
|
|
MixerWindow->Window = (HWND*)HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, MixerWindow->Window, (MixerWindow->WindowCount + ItemCount) * sizeof(HWND));
|
2011-04-06 21:05:05 +00:00
|
|
|
else
|
2018-03-10 20:10:40 +00:00
|
|
|
MixerWindow->Window = (HWND*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ItemCount * sizeof(HWND));
|
2011-04-06 21:05:05 +00:00
|
|
|
if (!MixerWindow->Window)
|
|
|
|
{
|
|
|
|
/* no memory */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
/* enumerate now all controls */
|
|
|
|
for (Index = 0; Index < ItemCount; Index++)
|
|
|
|
{
|
|
|
|
/* add controls */
|
|
|
|
Offset = AddDialogControl(MixerWindow->hWnd, &MixerWindow->Window[MixerWindow->WindowCount], DialogOffset, DialogItem, DialogIdMultiplier, MixerWindow->hFont, xBaseUnit, yBaseUnit);
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
assert(Offset);
|
|
|
|
|
|
|
|
/* move dialog item to new offset */
|
|
|
|
DialogItem =(PDLGITEMTEMPLATE)Offset;
|
|
|
|
|
|
|
|
/* increment window count */
|
|
|
|
MixerWindow->WindowCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
LoadDialog(
|
|
|
|
IN HMODULE hModule,
|
|
|
|
IN PMIXER_WINDOW MixerWindow,
|
|
|
|
IN LPCWSTR DialogResId,
|
|
|
|
IN DWORD Index)
|
|
|
|
{
|
|
|
|
LPDLGTEMPLATE DlgTemplate;
|
|
|
|
PDLGITEMTEMPLATE DlgItem;
|
|
|
|
RECT dialogRect;
|
|
|
|
LPWORD Offset;
|
|
|
|
WORD FontSize;
|
|
|
|
WCHAR FontName[100];
|
|
|
|
WORD Length;
|
|
|
|
int width;
|
|
|
|
|
|
|
|
DWORD units = GetDialogBaseUnits();
|
|
|
|
UINT xBaseUnit = LOWORD(units);
|
|
|
|
UINT yBaseUnit = HIWORD(units);
|
|
|
|
|
|
|
|
/* first load the dialog resource */
|
|
|
|
DlgTemplate = (LPDLGTEMPLATE)LoadDialogResource(hModule, DialogResId, NULL);
|
|
|
|
if (!DlgTemplate)
|
|
|
|
{
|
|
|
|
/* failed to load resource */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now walk past the dialog header */
|
|
|
|
Offset = (LPWORD)(DlgTemplate + 1);
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
/* FIXME: support menu */
|
|
|
|
assert(*Offset == 0);
|
|
|
|
Offset++;
|
|
|
|
|
|
|
|
/* FIXME: support classes */
|
|
|
|
assert(*Offset == 0);
|
|
|
|
Offset++;
|
|
|
|
|
|
|
|
/* FIXME: support titles */
|
|
|
|
assert(*Offset == 0);
|
|
|
|
Offset++;
|
|
|
|
|
|
|
|
/* get font size */
|
|
|
|
FontSize = *Offset;
|
|
|
|
Offset++;
|
|
|
|
|
|
|
|
/* calculate font length */
|
|
|
|
Length = wcslen((LPWSTR)Offset) + 1;
|
|
|
|
assert(Length < (sizeof(FontName) / sizeof(WCHAR)));
|
|
|
|
|
|
|
|
/* copy font */
|
|
|
|
wcscpy(FontName, (LPWSTR)Offset);
|
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
if (DlgTemplate->style & DS_SETFONT)
|
2011-04-06 21:05:05 +00:00
|
|
|
{
|
2018-03-10 20:10:40 +00:00
|
|
|
HDC hDC;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
hDC = GetDC(0);
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
if (!MixerWindow->hFont)
|
|
|
|
{
|
|
|
|
int pixels = MulDiv(FontSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
|
|
|
|
MixerWindow->hFont = CreateFontW(-pixels, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, FontName);
|
|
|
|
}
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
if (MixerWindow->hFont)
|
|
|
|
{
|
|
|
|
SIZE charSize;
|
|
|
|
HFONT hOldFont;
|
|
|
|
|
|
|
|
hOldFont = SelectObject(hDC, MixerWindow->hFont);
|
|
|
|
charSize.cx = GdiGetCharDimensions(hDC, NULL, &charSize.cy);
|
|
|
|
if (charSize.cx)
|
|
|
|
{
|
|
|
|
xBaseUnit = charSize.cx;
|
|
|
|
yBaseUnit = charSize.cy;
|
|
|
|
}
|
|
|
|
SelectObject(hDC, hOldFont);
|
|
|
|
}
|
2011-04-06 21:05:05 +00:00
|
|
|
}
|
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
// assert(MixerWindow->hFont);
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
/* move offset after font name */
|
|
|
|
Offset += Length;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
/* offset is now at first dialog item control */
|
|
|
|
DlgItem = (PDLGITEMTEMPLATE)Offset;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
dialogRect.left = 0;
|
|
|
|
dialogRect.right = DlgTemplate->cx;
|
|
|
|
dialogRect.top = 0;
|
|
|
|
dialogRect.bottom = DlgTemplate->cy;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
ConvertRect(&dialogRect, xBaseUnit, yBaseUnit);
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
width = dialogRect.right - dialogRect.left;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
dialogRect.left += MixerWindow->rect.right;
|
|
|
|
dialogRect.right += MixerWindow->rect.right;
|
|
|
|
dialogRect.top += MixerWindow->rect.top;
|
|
|
|
dialogRect.bottom += MixerWindow->rect.top;
|
|
|
|
|
|
|
|
MixerWindow->rect.right += width;
|
|
|
|
if ((dialogRect.bottom - dialogRect.top) > (MixerWindow->rect.bottom - MixerWindow->rect.top))
|
|
|
|
MixerWindow->rect.bottom = MixerWindow->rect.top + dialogRect.bottom - dialogRect.top;
|
2011-04-06 21:05:05 +00:00
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
/* now add the controls */
|
|
|
|
LoadDialogControls(MixerWindow, &dialogRect, DlgTemplate->cdit, DlgItem, Index, xBaseUnit, yBaseUnit);
|
2011-04-06 21:05:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
CALLBACK
|
|
|
|
EnumConnectionsCallback(
|
2011-04-08 23:18:20 +00:00
|
|
|
PSND_MIXER Mixer,
|
|
|
|
DWORD LineID,
|
2011-04-06 21:05:05 +00:00
|
|
|
LPMIXERLINE Line,
|
|
|
|
PVOID Context)
|
|
|
|
{
|
|
|
|
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
|
|
|
DWORD Flags;
|
|
|
|
DWORD wID;
|
2011-04-07 21:31:21 +00:00
|
|
|
UINT ControlCount = 0, Index;
|
|
|
|
LPMIXERCONTROL Control = NULL;
|
|
|
|
HWND hDlgCtrl;
|
2011-04-06 21:05:05 +00:00
|
|
|
PPREFERENCES_CONTEXT PrefContext = (PPREFERENCES_CONTEXT)Context;
|
|
|
|
|
|
|
|
if (Line->cControls != 0)
|
|
|
|
{
|
|
|
|
/* get line name */
|
2011-04-09 10:36:25 +00:00
|
|
|
if (SndMixerGetLineName(PrefContext->MixerWindow->Mixer, PrefContext->SelectedLine, LineName, MIXER_LONG_NAME_CHARS, TRUE) == -1)
|
2011-04-06 21:05:05 +00:00
|
|
|
{
|
|
|
|
/* failed to get line name */
|
|
|
|
LineName[0] = L'\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if line is found in registry settings */
|
|
|
|
if (ReadLineConfig(PrefContext->DeviceName,
|
|
|
|
LineName,
|
|
|
|
Line->szName,
|
|
|
|
&Flags))
|
|
|
|
{
|
|
|
|
/* is it selected */
|
|
|
|
if (Flags != 0x4)
|
|
|
|
{
|
2018-03-11 00:13:22 +00:00
|
|
|
int dlgId = (PrefContext->MixerWindow->Mode == SMALL_MODE) ? IDD_SMALL_MASTER : IDD_NORMAL_MASTER;
|
2018-03-10 20:10:40 +00:00
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
/* load dialog resource */
|
2018-03-10 20:10:40 +00:00
|
|
|
LoadDialog(hAppInstance, PrefContext->MixerWindow, MAKEINTRESOURCE(dlgId), PrefContext->Count);
|
2011-04-06 21:05:05 +00:00
|
|
|
|
|
|
|
/* get id */
|
|
|
|
wID = (PrefContext->Count + 1) * IDC_LINE_NAME;
|
|
|
|
|
|
|
|
/* set line name */
|
|
|
|
SetDlgItemTextW(PrefContext->MixerWindow->hWnd, wID, Line->szName);
|
|
|
|
|
2011-04-07 21:31:21 +00:00
|
|
|
/* query controls */
|
2017-10-01 14:42:04 +00:00
|
|
|
if (SndMixerQueryControls(Mixer, &ControlCount, Line, &Control) != FALSE)
|
2011-04-07 21:31:21 +00:00
|
|
|
{
|
|
|
|
/* now go through all controls and update their states */
|
2018-03-15 21:03:33 +00:00
|
|
|
for(Index = 0; Index < Line->cControls; Index++)
|
2011-04-07 21:31:21 +00:00
|
|
|
{
|
2018-03-15 21:03:33 +00:00
|
|
|
if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_SWITCH)
|
|
|
|
{
|
|
|
|
MIXERCONTROLDETAILS_BOOLEAN Details;
|
|
|
|
|
|
|
|
/* get volume control details */
|
|
|
|
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_BOOLEAN), (LPVOID)&Details) != -1)
|
|
|
|
{
|
|
|
|
/* update dialog control */
|
|
|
|
wID = (PrefContext->Count + 1) * IDC_LINE_SWITCH;
|
|
|
|
|
|
|
|
/* get dialog control */
|
|
|
|
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
|
|
|
|
|
|
|
if (hDlgCtrl != NULL)
|
|
|
|
{
|
|
|
|
/* check state */
|
|
|
|
if (SendMessageW(hDlgCtrl, BM_GETCHECK, 0, 0) != Details.fValue)
|
|
|
|
{
|
|
|
|
/* update control state */
|
|
|
|
SendMessageW(hDlgCtrl, BM_SETCHECK, (WPARAM)Details.fValue, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((Control[Index].dwControlType & MIXERCONTROL_CT_CLASS_MASK) == MIXERCONTROL_CT_CLASS_FADER)
|
|
|
|
{
|
|
|
|
MIXERCONTROLDETAILS_UNSIGNED Details;
|
|
|
|
|
|
|
|
/* get volume control details */
|
|
|
|
if (SndMixerGetVolumeControlDetails(Mixer, Control[Index].dwControlID, sizeof(MIXERCONTROLDETAILS_UNSIGNED), (LPVOID)&Details) != -1)
|
|
|
|
{
|
|
|
|
/* update dialog control */
|
|
|
|
DWORD Position;
|
|
|
|
DWORD Step = 0x10000 / VOLUME_STEPS;
|
|
|
|
|
|
|
|
/* FIXME: give me granularity */
|
|
|
|
Position = VOLUME_STEPS - (Details.dwValue / Step);
|
|
|
|
|
|
|
|
/* FIXME support left - right slider */
|
|
|
|
wID = (PrefContext->Count + 1) * IDC_LINE_SLIDER_VERT;
|
|
|
|
|
|
|
|
/* get dialog control */
|
|
|
|
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
|
|
|
|
|
|
|
if (hDlgCtrl != NULL)
|
|
|
|
{
|
|
|
|
/* check state */
|
|
|
|
LRESULT OldPosition = SendMessageW(hDlgCtrl, TBM_GETPOS, 0, 0);
|
|
|
|
if (OldPosition != Position)
|
|
|
|
{
|
|
|
|
/* update control state */
|
|
|
|
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, Position + Index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-07 21:31:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free controls */
|
|
|
|
HeapFree(GetProcessHeap(), 0, Control);
|
|
|
|
}
|
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
/* increment dialog count */
|
|
|
|
PrefContext->Count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
LoadDialogCtrls(
|
|
|
|
PPREFERENCES_CONTEXT PrefContext)
|
|
|
|
{
|
2011-04-07 21:31:21 +00:00
|
|
|
HWND hDlgCtrl;
|
2018-03-10 20:10:40 +00:00
|
|
|
RECT statusRect;
|
2011-04-07 21:31:21 +00:00
|
|
|
|
|
|
|
/* set dialog count to zero */
|
2011-04-06 21:05:05 +00:00
|
|
|
PrefContext->Count = 0;
|
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
SetRectEmpty(&PrefContext->MixerWindow->rect);
|
|
|
|
|
2011-04-06 21:05:05 +00:00
|
|
|
/* enumerate controls */
|
2011-04-07 21:31:21 +00:00
|
|
|
SndMixerEnumConnections(PrefContext->MixerWindow->Mixer, PrefContext->SelectedLine, EnumConnectionsCallback, (PVOID)PrefContext);
|
|
|
|
|
2018-03-10 20:10:40 +00:00
|
|
|
if (PrefContext->MixerWindow->hStatusBar)
|
|
|
|
{
|
|
|
|
GetWindowRect(PrefContext->MixerWindow->hStatusBar, &statusRect);
|
|
|
|
PrefContext->MixerWindow->rect.bottom += (statusRect.bottom - statusRect.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now move the window */
|
|
|
|
AdjustWindowRect(&PrefContext->MixerWindow->rect, WS_DLGFRAME | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, TRUE);
|
|
|
|
SetWindowPos(PrefContext->MixerWindow->hWnd, HWND_TOP, PrefContext->MixerWindow->rect.left, PrefContext->MixerWindow->rect.top, PrefContext->MixerWindow->rect.right - PrefContext->MixerWindow->rect.left, PrefContext->MixerWindow->rect.bottom - PrefContext->MixerWindow->rect.top, SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
|
2016-11-05 14:55:55 +00:00
|
|
|
/* get last line separator */
|
2011-04-07 21:31:21 +00:00
|
|
|
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, IDC_LINE_SEP * PrefContext->Count);
|
|
|
|
|
|
|
|
if (hDlgCtrl != NULL)
|
|
|
|
{
|
2016-11-05 14:55:55 +00:00
|
|
|
/* hide last separator */
|
2011-04-07 21:31:21 +00:00
|
|
|
ShowWindow(hDlgCtrl, SW_HIDE);
|
|
|
|
}
|
2011-04-06 21:05:05 +00:00
|
|
|
}
|
2011-04-07 21:31:21 +00:00
|
|
|
|
|
|
|
VOID
|
|
|
|
UpdateDialogLineSwitchControl(
|
|
|
|
PPREFERENCES_CONTEXT PrefContext,
|
|
|
|
LPMIXERLINE Line,
|
|
|
|
LONG fValue)
|
|
|
|
{
|
|
|
|
DWORD Index;
|
|
|
|
DWORD wID;
|
|
|
|
HWND hDlgCtrl;
|
|
|
|
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
|
|
|
|
|
|
|
/* find the index of this line */
|
|
|
|
for(Index = 0; Index < PrefContext->Count; Index++)
|
|
|
|
{
|
|
|
|
/* get id */
|
|
|
|
wID = (Index + 1) * IDC_LINE_NAME;
|
|
|
|
|
|
|
|
if (GetDlgItemText(PrefContext->MixerWindow->hWnd, wID, LineName, MIXER_LONG_NAME_CHARS) == 0)
|
|
|
|
{
|
|
|
|
/* failed to retrieve id */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if the line name matches */
|
|
|
|
if (!wcsicmp(LineName, Line->szName))
|
|
|
|
{
|
|
|
|
/* found matching line name */
|
|
|
|
wID = (Index + 1) * IDC_LINE_SWITCH;
|
|
|
|
|
|
|
|
/* get dialog control */
|
|
|
|
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
|
|
|
|
|
|
|
if (hDlgCtrl != NULL)
|
|
|
|
{
|
|
|
|
/* check state */
|
|
|
|
if (SendMessageW(hDlgCtrl, BM_GETCHECK, 0, 0) != fValue)
|
|
|
|
{
|
|
|
|
/* update control state */
|
|
|
|
SendMessageW(hDlgCtrl, BM_SETCHECK, (WPARAM)fValue, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
UpdateDialogLineSliderControl(
|
|
|
|
PPREFERENCES_CONTEXT PrefContext,
|
|
|
|
LPMIXERLINE Line,
|
|
|
|
DWORD dwControlID,
|
|
|
|
DWORD dwDialogID,
|
|
|
|
DWORD Position)
|
|
|
|
{
|
|
|
|
DWORD Index;
|
|
|
|
DWORD wID;
|
|
|
|
HWND hDlgCtrl;
|
|
|
|
WCHAR LineName[MIXER_LONG_NAME_CHARS];
|
|
|
|
|
|
|
|
/* find the index of this line */
|
|
|
|
for(Index = 0; Index < PrefContext->Count; Index++)
|
|
|
|
{
|
|
|
|
/* get id */
|
|
|
|
wID = (Index + 1) * IDC_LINE_NAME;
|
|
|
|
|
|
|
|
if (GetDlgItemText(PrefContext->MixerWindow->hWnd, wID, LineName, MIXER_LONG_NAME_CHARS) == 0)
|
|
|
|
{
|
|
|
|
/* failed to retrieve id */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if the line name matches */
|
|
|
|
if (!wcsicmp(LineName, Line->szName))
|
|
|
|
{
|
|
|
|
/* found matching line name */
|
|
|
|
wID = (Index + 1) * dwDialogID;
|
|
|
|
|
|
|
|
/* get dialog control */
|
|
|
|
hDlgCtrl = GetDlgItem(PrefContext->MixerWindow->hWnd, wID);
|
|
|
|
|
|
|
|
if (hDlgCtrl != NULL)
|
|
|
|
{
|
|
|
|
/* check state */
|
|
|
|
LRESULT OldPosition = SendMessageW(hDlgCtrl, TBM_GETPOS, 0, 0);
|
|
|
|
if (OldPosition != Position)
|
|
|
|
{
|
|
|
|
/* update control state */
|
|
|
|
SendMessageW(hDlgCtrl, TBM_SETPOS, (WPARAM)TRUE, Position + Index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|