2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Sound Volume Control
4 * FILE: base/applications/sndvol32/dialog.c
5 * PROGRAMMERS: Johannes Anderwald
12 ConvertRect(LPRECT lpRect
, UINT xBaseUnit
, UINT yBaseUnit
)
14 lpRect
->left
= MulDiv(lpRect
->left
, xBaseUnit
, 4);
15 lpRect
->right
= MulDiv(lpRect
->right
, xBaseUnit
, 4);
16 lpRect
->top
= MulDiv(lpRect
->top
, yBaseUnit
, 8);
17 lpRect
->bottom
= MulDiv(lpRect
->bottom
, yBaseUnit
, 8);
23 IN LPCWSTR ResourceName
,
24 OUT LPDWORD ResourceLength
)
31 hSrc
= FindResourceW(hModule
, ResourceName
, (LPCWSTR
)RT_DIALOG
);
35 /* failed to find resource */
39 /* now load the resource */
40 hRes
= LoadResource(hAppInstance
, hSrc
);
43 /* failed to load resource */
47 /* now lock the resource */
48 Result
= LockResource(hRes
);
52 /* failed to lock resource */
58 /* store output length */
59 *ResourceLength
= SizeofResource(hAppInstance
, hSrc
);
70 IN LPRECT DialogOffset
,
71 IN PDLGITEMTEMPLATE DialogItem
,
72 IN DWORD DialogIdMultiplier
,
80 LPWSTR ClassName
, WindowName
;
81 WCHAR WindowIdBuf
[sizeof("#65535")];
86 /* initialize client rectangle */
87 rect
.left
= DialogItem
->x
;
88 rect
.top
= DialogItem
->y
;
89 rect
.right
= DialogItem
->x
+ DialogItem
->cx
;
90 rect
.bottom
= DialogItem
->y
+ DialogItem
->cy
;
92 /* Convert Dialog units to pixes */
93 ConvertRect(&rect
, xBaseUnit
, yBaseUnit
);
95 rect
.left
+= DialogOffset
->left
;
96 rect
.right
+= DialogOffset
->left
;
97 rect
.top
+= DialogOffset
->top
;
98 rect
.bottom
+= DialogOffset
->top
;
100 /* move offset after dialog item */
101 Offset
= (LPWORD
)(DialogItem
+ 1);
103 if (*Offset
== 0xFFFF)
105 /* class is encoded as type */
108 /* get control type */
112 ClassName
= L
"button";
115 ClassName
= L
"static";
126 /* class name is encoded as string */
127 ClassName
= (LPWSTR
)(Offset
);
129 /* move offset to the end of class string */
130 Offset
+= wcslen(ClassName
) + 1;
133 if (*Offset
== 0xFFFF)
135 /* Window name is encoded as ordinal */
137 wsprintf(WindowIdBuf
, L
"#%u", (DWORD
)*Offset
);
138 WindowName
= WindowIdBuf
;
143 /* window name is encoded as string */
144 WindowName
= (LPWSTR
)(Offset
);
146 /* move offset to the end of class string */
147 Offset
+= wcslen(WindowName
) + 1;
150 if (DialogItem
->id
== MAXWORD
)
152 /* id is not important */
153 wID
= DialogItem
->id
;
158 wID
= DialogItem
->id
* (DialogIdMultiplier
+ 1);
162 /* now create the window */
163 hwnd
= CreateWindowExW(DialogItem
->dwExtendedStyle
,
169 rect
.right
- rect
.left
,
170 rect
.bottom
- rect
.top
,
182 /* check if this the track bar */
183 if (!wcsicmp(ClassName
, L
"msctls_trackbar32"))
185 if (DialogItem
->style
& TBS_VERT
)
187 /* Vertical trackbar: Volume */
189 /* Disable the volume trackbar by default */
190 EnableWindow(hwnd
, FALSE
);
193 SendMessage(hwnd
, TBM_SETRANGE
, (WPARAM
)TRUE
, (LPARAM
)MAKELONG(VOLUME_MIN
, VOLUME_MAX
));
195 /* set up page size */
196 SendMessage(hwnd
, TBM_SETPAGESIZE
, 0, (LPARAM
)VOLUME_PAGE_SIZE
);
199 SendMessage(hwnd
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)0);
201 /* Calculate and set ticks */
202 nSteps
= (VOLUME_MAX
/ (VOLUME_TICKS
+ 1));
203 if (VOLUME_MAX
% (VOLUME_TICKS
+ 1) != 0)
205 for (i
= nSteps
; i
< VOLUME_MAX
; i
+= nSteps
)
206 SendMessage(hwnd
, TBM_SETTIC
, 0, (LPARAM
)i
);
210 /* Horizontal trackbar: Balance */
212 /* Disable the balance trackbar by default */
213 EnableWindow(hwnd
, FALSE
);
216 SendMessage(hwnd
, TBM_SETRANGE
, (WPARAM
)TRUE
, (LPARAM
)MAKELONG(0, BALANCE_STEPS
));
218 /* set up page size */
219 SendMessage(hwnd
, TBM_SETPAGESIZE
, 0, (LPARAM
)BALANCE_PAGE_SIZE
);
222 SendMessage(hwnd
, TBM_SETPOS
, (WPARAM
)TRUE
, (LPARAM
)BALANCE_STEPS
/ 2);
224 /* Calculate and set ticks */
225 nSteps
= (BALANCE_STEPS
/ (BALANCE_TICKS
+ 1));
226 if (BALANCE_STEPS
% (BALANCE_TICKS
+ 1) != 0)
228 for (i
= nSteps
; i
< BALANCE_STEPS
; i
+= nSteps
)
229 SendMessage(hwnd
, TBM_SETTIC
, 0, (LPARAM
)i
);
232 else if (!wcsicmp(ClassName
, L
"static"))
235 SendMessageW(hwnd
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
237 else if (!wcsicmp(ClassName
, L
"button"))
239 if (DialogItem
->id
== IDC_LINE_SWITCH
)
241 if (MixerId
== PLAY_MIXER
)
243 /* Disable checkboxes by default, if we are in play mode */
244 EnableWindow(hwnd
, FALSE
);
247 else if (DialogItem
->id
== IDC_LINE_ADVANCED
)
249 ShowWindow(hwnd
, SW_HIDE
);
253 SendMessageW(hwnd
, WM_SETFONT
, (WPARAM
)hFont
, TRUE
);
257 /* check if there is additional data */
260 /* no additional data */
265 /* FIXME: Determine whether this should be "Offset += 1 + *Offset" to explicitly skip the data count too. */
266 /* skip past additional data */
270 /* make sure next template is word-aligned */
271 Offset
= (LPWORD
)(((ULONG_PTR
)Offset
+ 3) & ~3);
279 IN PMIXER_WINDOW MixerWindow
,
282 PDLGITEMTEMPLATE DialogItem
,
283 DWORD DialogIdMultiplier
,
293 if (MixerWindow
->Window
)
294 MixerWindow
->Window
= (HWND
*)HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, MixerWindow
->Window
, (MixerWindow
->WindowCount
+ ItemCount
) * sizeof(HWND
));
296 MixerWindow
->Window
= (HWND
*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, ItemCount
* sizeof(HWND
));
297 if (!MixerWindow
->Window
)
303 /* enumerate now all controls */
304 for (Index
= 0; Index
< ItemCount
; Index
++)
307 Offset
= AddDialogControl(MixerWindow
->hWnd
,
308 &MixerWindow
->Window
[MixerWindow
->WindowCount
],
315 MixerWindow
->MixerId
);
320 /* move dialog item to new offset */
321 DialogItem
=(PDLGITEMTEMPLATE
)Offset
;
323 /* increment window count */
324 MixerWindow
->WindowCount
++;
331 IN PMIXER_WINDOW MixerWindow
,
332 IN LPCWSTR DialogResId
,
335 LPDLGTEMPLATE DlgTemplate
;
336 PDLGITEMTEMPLATE DlgItem
;
344 DWORD units
= GetDialogBaseUnits();
345 UINT xBaseUnit
= LOWORD(units
);
346 UINT yBaseUnit
= HIWORD(units
);
348 /* first load the dialog resource */
349 DlgTemplate
= (LPDLGTEMPLATE
)LoadDialogResource(hModule
, DialogResId
, NULL
);
352 /* failed to load resource */
356 /* Now walk past the dialog header */
357 Offset
= (LPWORD
)(DlgTemplate
+ 1);
359 /* FIXME: support menu */
360 assert(*Offset
== 0);
363 /* FIXME: support classes */
364 assert(*Offset
== 0);
367 /* FIXME: support titles */
368 assert(*Offset
== 0);
375 /* calculate font length */
376 Length
= wcslen((LPWSTR
)Offset
) + 1;
377 assert(Length
< (sizeof(FontName
) / sizeof(WCHAR
)));
380 wcscpy(FontName
, (LPWSTR
)Offset
);
382 if (DlgTemplate
->style
& DS_SETFONT
)
388 if (!MixerWindow
->hFont
)
390 int pixels
= MulDiv(FontSize
, GetDeviceCaps(hDC
, LOGPIXELSY
), 72);
391 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
);
394 if (MixerWindow
->hFont
)
399 hOldFont
= SelectObject(hDC
, MixerWindow
->hFont
);
400 charSize
.cx
= GdiGetCharDimensions(hDC
, NULL
, &charSize
.cy
);
403 xBaseUnit
= charSize
.cx
;
404 yBaseUnit
= charSize
.cy
;
406 SelectObject(hDC
, hOldFont
);
408 MixerWindow
->baseUnit
.cx
= charSize
.cx
;
409 MixerWindow
->baseUnit
.cy
= charSize
.cy
;
412 ReleaseDC(NULL
, hDC
);
415 // assert(MixerWindow->hFont);
417 /* move offset after font name */
420 /* offset is now at first dialog item control */
421 DlgItem
= (PDLGITEMTEMPLATE
)Offset
;
424 dialogRect
.right
= DlgTemplate
->cx
;
426 dialogRect
.bottom
= DlgTemplate
->cy
;
428 ConvertRect(&dialogRect
, xBaseUnit
, yBaseUnit
);
430 width
= dialogRect
.right
- dialogRect
.left
;
432 dialogRect
.left
+= MixerWindow
->rect
.right
;
433 dialogRect
.right
+= MixerWindow
->rect
.right
;
434 dialogRect
.top
+= MixerWindow
->rect
.top
;
435 dialogRect
.bottom
+= MixerWindow
->rect
.top
;
437 MixerWindow
->rect
.right
+= width
;
438 if ((dialogRect
.bottom
- dialogRect
.top
) > (MixerWindow
->rect
.bottom
- MixerWindow
->rect
.top
))
439 MixerWindow
->rect
.bottom
= MixerWindow
->rect
.top
+ dialogRect
.bottom
- dialogRect
.top
;
441 /* now add the controls */
442 LoadDialogControls(MixerWindow
, &dialogRect
, DlgTemplate
->cdit
, DlgItem
, Index
, xBaseUnit
, yBaseUnit
);
447 EnumConnectionsCallback(
453 WCHAR LineName
[MIXER_LONG_NAME_CHARS
];
456 UINT ControlCount
= 0, Index
;
457 LPMIXERCONTROL Control
= NULL
;
459 PMIXERCONTROLDETAILS_UNSIGNED pVolumeDetails
= NULL
;
460 PPREFERENCES_CONTEXT PrefContext
= (PPREFERENCES_CONTEXT
)Context
;
462 if (Line
->cControls
== 0)
466 if (SndMixerGetLineName(PrefContext
->MixerWindow
->Mixer
, PrefContext
->SelectedLine
, LineName
, MIXER_LONG_NAME_CHARS
, TRUE
) == -1)
468 /* failed to get line name */
472 pVolumeDetails
= HeapAlloc(GetProcessHeap(),
474 Line
->cChannels
* sizeof(MIXERCONTROLDETAILS_UNSIGNED
));
475 if (pVolumeDetails
== NULL
)
478 /* check if line is found in registry settings */
479 if (ReadLineConfig(PrefContext
->DeviceName
,
489 if ((Line
->dwComponentType
== MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
) ||
490 (Line
->dwComponentType
== MIXERLINE_COMPONENTTYPE_DST_HEADPHONES
))
491 dlgId
= (PrefContext
->MixerWindow
->Mode
== SMALL_MODE
) ? IDD_SMALL_MASTER
: IDD_NORMAL_MASTER
;
493 dlgId
= (PrefContext
->MixerWindow
->Mode
== SMALL_MODE
) ? IDD_SMALL_LINE
: IDD_NORMAL_LINE
;
495 /* load dialog resource */
496 LoadDialog(hAppInstance
, PrefContext
->MixerWindow
, MAKEINTRESOURCE(dlgId
), PrefContext
->MixerWindow
->DialogCount
);
499 wID
= (PrefContext
->MixerWindow
->DialogCount
+ 1) * IDC_LINE_NAME
;
502 SetDlgItemTextW(PrefContext
->MixerWindow
->hWnd
, wID
, Line
->szName
);
505 if (SndMixerQueryControls(Mixer
, &ControlCount
, Line
, &Control
) != FALSE
)
507 /* now go through all controls and update their states */
508 for (Index
= 0; Index
< Line
->cControls
; Index
++)
510 if (Control
[Index
].dwControlType
== MIXERCONTROL_CONTROLTYPE_MUTE
)
512 MIXERCONTROLDETAILS_BOOLEAN Details
;
514 /* get volume control details */
515 if (SndMixerGetVolumeControlDetails(Mixer
, Control
[Index
].dwControlID
, 1, sizeof(MIXERCONTROLDETAILS_BOOLEAN
), (LPVOID
)&Details
) != -1)
517 /* update dialog control */
518 wID
= (PrefContext
->MixerWindow
->DialogCount
+ 1) * IDC_LINE_SWITCH
;
520 /* get dialog control */
521 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, wID
);
523 if (hDlgCtrl
!= NULL
)
525 /* Enable the 'Mute' checkbox, if we are in play mode */
526 if (Mixer
->MixerId
== PLAY_MIXER
)
527 EnableWindow(hDlgCtrl
, TRUE
);
530 if (SendMessageW(hDlgCtrl
, BM_GETCHECK
, 0, 0) != Details
.fValue
)
532 /* update control state */
533 SendMessageW(hDlgCtrl
, BM_SETCHECK
, (WPARAM
)Details
.fValue
, 0);
538 else if (Control
[Index
].dwControlType
== MIXERCONTROL_CONTROLTYPE_VOLUME
)
540 /* get volume control details */
541 if (SndMixerGetVolumeControlDetails(Mixer
, Control
[Index
].dwControlID
, Line
->cChannels
, sizeof(MIXERCONTROLDETAILS_UNSIGNED
), (LPVOID
)pVolumeDetails
) != -1)
543 /* update dialog control */
544 DWORD volumePosition
, volumeStep
, maxVolume
, i
;
545 DWORD balancePosition
, balanceStep
;
547 volumeStep
= (Control
[Index
].Bounds
.dwMaximum
- Control
[Index
].Bounds
.dwMinimum
) / (VOLUME_MAX
- VOLUME_MIN
);
550 for (i
= 0; i
< Line
->cChannels
; i
++)
552 if (pVolumeDetails
[i
].dwValue
> maxVolume
)
553 maxVolume
= pVolumeDetails
[i
].dwValue
;
556 volumePosition
= (maxVolume
- Control
[Index
].Bounds
.dwMinimum
) / volumeStep
;
558 if (Line
->cChannels
== 1)
560 balancePosition
= BALANCE_CENTER
;
562 else if (Line
->cChannels
== 2)
564 if (pVolumeDetails
[0].dwValue
== pVolumeDetails
[1].dwValue
)
566 balancePosition
= BALANCE_CENTER
;
568 else if (pVolumeDetails
[0].dwValue
== Control
[Index
].Bounds
.dwMinimum
)
570 balancePosition
= BALANCE_RIGHT
;
572 else if (pVolumeDetails
[1].dwValue
== Control
[Index
].Bounds
.dwMinimum
)
574 balancePosition
= BALANCE_LEFT
;
578 balanceStep
= (maxVolume
- Control
[Index
].Bounds
.dwMinimum
) / (BALANCE_STEPS
/ 2);
580 if (pVolumeDetails
[0].dwValue
< pVolumeDetails
[1].dwValue
)
582 balancePosition
= (pVolumeDetails
[0].dwValue
- Control
[Index
].Bounds
.dwMinimum
) / balanceStep
;
583 balancePosition
= BALANCE_RIGHT
- balancePosition
;
585 else if (pVolumeDetails
[1].dwValue
< pVolumeDetails
[0].dwValue
)
587 balancePosition
= (pVolumeDetails
[1].dwValue
- Control
[Index
].Bounds
.dwMinimum
) / balanceStep
;
588 balancePosition
= BALANCE_LEFT
+ balancePosition
;
593 /* Set the volume trackbar */
594 wID
= (PrefContext
->MixerWindow
->DialogCount
+ 1) * IDC_LINE_SLIDER_VERT
;
596 /* get dialog control */
597 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, wID
);
599 if (hDlgCtrl
!= NULL
)
602 LRESULT OldPosition
= SendMessageW(hDlgCtrl
, TBM_GETPOS
, 0, 0);
604 /* Enable the volume trackbar */
605 EnableWindow(hDlgCtrl
, TRUE
);
607 if (OldPosition
!= (VOLUME_MAX
- volumePosition
))
609 /* update control state */
610 SendMessageW(hDlgCtrl
, TBM_SETPOS
, (WPARAM
)TRUE
, VOLUME_MAX
- volumePosition
);
614 if (Line
->cChannels
== 2)
616 /* Set the balance trackbar */
617 wID
= (PrefContext
->MixerWindow
->DialogCount
+ 1) * IDC_LINE_SLIDER_HORZ
;
619 /* get dialog control */
620 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, wID
);
622 if (hDlgCtrl
!= NULL
)
625 LRESULT OldPosition
= SendMessageW(hDlgCtrl
, TBM_GETPOS
, 0, 0);
627 /* Enable the balance trackbar */
628 EnableWindow(hDlgCtrl
, TRUE
);
630 if (OldPosition
!= balancePosition
)
632 /* update control state */
633 SendMessageW(hDlgCtrl
, TBM_SETPOS
, (WPARAM
)TRUE
, balancePosition
);
641 if (PrefContext
->MixerWindow
->Mode
== NORMAL_MODE
)
643 PrefContext
->MixerWindow
->bHasExtendedControls
= TRUE
;
645 wID
= (PrefContext
->MixerWindow
->DialogCount
+ 1) * IDC_LINE_ADVANCED
;
647 /* get dialog control */
648 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, wID
);
649 if (hDlgCtrl
!= NULL
)
652 PrefContext
->MixerWindow
->bShowExtendedControls
? SW_SHOWNORMAL
: SW_HIDE
);
659 HeapFree(GetProcessHeap(), 0, Control
);
662 /* increment dialog count */
663 PrefContext
->MixerWindow
->DialogCount
++;
668 /* Free the volume details */
670 HeapFree(GetProcessHeap(), 0, pVolumeDetails
);
677 PPREFERENCES_CONTEXT PrefContext
)
685 /* set dialog count to zero */
686 PrefContext
->MixerWindow
->DialogCount
= 0;
687 PrefContext
->MixerWindow
->bHasExtendedControls
= FALSE
;
688 SetRectEmpty(&PrefContext
->MixerWindow
->rect
);
690 /* enumerate controls */
691 SndMixerEnumConnections(PrefContext
->MixerWindow
->Mixer
, PrefContext
->SelectedLine
, EnumConnectionsCallback
, (PVOID
)PrefContext
);
693 /* Update the 'Advanced Controls' menu item */
694 EnableMenuItem(GetMenu(PrefContext
->MixerWindow
->hWnd
),
695 IDM_ADVANCED_CONTROLS
,
696 MF_BYCOMMAND
| (PrefContext
->MixerWindow
->bHasExtendedControls
? MF_ENABLED
: MF_GRAYED
));
698 /* Add some height for the status bar */
699 if (PrefContext
->MixerWindow
->hStatusBar
)
701 GetWindowRect(PrefContext
->MixerWindow
->hStatusBar
, &statusRect
);
702 PrefContext
->MixerWindow
->rect
.bottom
+= (statusRect
.bottom
- statusRect
.top
);
705 /* Add height of the 'Advanced' button */
706 dy
= MulDiv(ADVANCED_BUTTON_HEIGHT
, PrefContext
->MixerWindow
->baseUnit
.cy
, 8);
707 if (PrefContext
->MixerWindow
->bShowExtendedControls
&& PrefContext
->MixerWindow
->bHasExtendedControls
)
708 PrefContext
->MixerWindow
->rect
.bottom
+= dy
;
710 /* now move the window */
711 AdjustWindowRect(&PrefContext
->MixerWindow
->rect
, WS_DLGFRAME
| WS_CAPTION
| WS_MINIMIZEBOX
| WS_SYSMENU
| WS_CLIPCHILDREN
| WS_CLIPSIBLINGS
| WS_VISIBLE
, TRUE
);
712 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
);
714 /* Move the status bar */
715 if (PrefContext
->MixerWindow
->hStatusBar
)
717 SetWindowPos(PrefContext
->MixerWindow
->hStatusBar
,
720 PrefContext
->MixerWindow
->rect
.bottom
- (statusRect
.bottom
- statusRect
.top
),
721 PrefContext
->MixerWindow
->rect
.right
- PrefContext
->MixerWindow
->rect
.left
,
722 statusRect
.bottom
- statusRect
.top
,
726 if (PrefContext
->MixerWindow
->MixerId
== RECORD_MIXER
)
727 LoadStringW(hAppInstance
, IDS_SELECT
, szBuffer
, ARRAYSIZE(szBuffer
));
729 for (i
= 0; i
< PrefContext
->MixerWindow
->DialogCount
; i
++)
731 if (PrefContext
->MixerWindow
->MixerId
== RECORD_MIXER
)
733 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, (i
+ 1) * IDC_LINE_SWITCH
);
735 /* Turn the autocheckbox into a checkbox */
736 SetWindowLongPtr(hDlgCtrl
, GWL_STYLE
, (GetWindowLongPtr(hDlgCtrl
, GWL_STYLE
) & ~BS_AUTOCHECKBOX
) | BS_CHECKBOX
);
738 /* Change text from 'Mute' to 'Select' */
739 SetWindowTextW(hDlgCtrl
, szBuffer
);
742 /* Resize the vertical line separator */
743 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, (i
+ 1) * IDC_LINE_SEP
);
744 if (hDlgCtrl
!= NULL
)
746 GetWindowRect(hDlgCtrl
, &statusRect
);
747 if (PrefContext
->MixerWindow
->bShowExtendedControls
&& PrefContext
->MixerWindow
->bHasExtendedControls
)
748 statusRect
.bottom
+= dy
;
750 SetWindowPos(hDlgCtrl
,
754 statusRect
.right
- statusRect
.left
,
755 statusRect
.bottom
- statusRect
.top
,
756 SWP_NOMOVE
| SWP_NOZORDER
);
760 /* Hide the last line separator */
761 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, IDC_LINE_SEP
* PrefContext
->MixerWindow
->DialogCount
);
762 if (hDlgCtrl
!= NULL
)
764 ShowWindow(hDlgCtrl
, SW_HIDE
);
769 UpdateDialogLineSwitchControl(
770 PPREFERENCES_CONTEXT PrefContext
,
777 WCHAR LineName
[MIXER_LONG_NAME_CHARS
];
779 /* find the index of this line */
780 for (Index
= 0; Index
< PrefContext
->MixerWindow
->DialogCount
; Index
++)
783 wID
= (Index
+ 1) * IDC_LINE_NAME
;
785 if (GetDlgItemText(PrefContext
->MixerWindow
->hWnd
, wID
, LineName
, MIXER_LONG_NAME_CHARS
) == 0)
787 /* failed to retrieve id */
791 /* check if the line name matches */
792 if (!wcsicmp(LineName
, Line
->szName
))
794 /* found matching line name */
795 wID
= (Index
+ 1) * IDC_LINE_SWITCH
;
797 /* get dialog control */
798 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, wID
);
800 if (hDlgCtrl
!= NULL
)
803 if (SendMessageW(hDlgCtrl
, BM_GETCHECK
, 0, 0) != fValue
)
805 /* update control state */
806 SendMessageW(hDlgCtrl
, BM_SETCHECK
, (WPARAM
)fValue
, 0);
815 UpdateDialogLineSliderControl(
816 PPREFERENCES_CONTEXT PrefContext
,
824 WCHAR LineName
[MIXER_LONG_NAME_CHARS
];
826 /* find the index of this line */
827 for (Index
= 0; Index
< PrefContext
->MixerWindow
->DialogCount
; Index
++)
830 wID
= (Index
+ 1) * IDC_LINE_NAME
;
832 if (GetDlgItemText(PrefContext
->MixerWindow
->hWnd
, wID
, LineName
, MIXER_LONG_NAME_CHARS
) == 0)
834 /* failed to retrieve id */
838 /* check if the line name matches */
839 if (!wcsicmp(LineName
, Line
->szName
))
841 /* found matching line name */
842 wID
= (Index
+ 1) * dwDialogID
;
844 /* get dialog control */
845 hDlgCtrl
= GetDlgItem(PrefContext
->MixerWindow
->hWnd
, wID
);
847 if (hDlgCtrl
!= NULL
)
850 LRESULT OldPosition
= SendMessageW(hDlgCtrl
, TBM_GETPOS
, 0, 0);
851 if (OldPosition
!= Position
)
853 /* update control state */
854 SendMessageW(hDlgCtrl
, TBM_SETPOS
, (WPARAM
)TRUE
, Position
);