@@ -765,22 +765,18 @@ LoadDialogCtrls(
765765 }
766766}
767767
768- VOID
769- UpdateDialogLineSwitchControl (
768+ HWND
769+ GetLineDialogControl (
770770 PPREFERENCES_CONTEXT PrefContext ,
771771 LPMIXERLINE Line ,
772- LONG fValue )
772+ DWORD dwDialogID )
773773{
774- DWORD Index ;
775- DWORD wID ;
776- HWND hDlgCtrl ;
777- WCHAR LineName [MIXER_LONG_NAME_CHARS ];
778-
779774 /* find the index of this line */
780- for (Index = 0 ; Index < PrefContext -> MixerWindow -> DialogCount ; Index ++ )
775+ for (DWORD Index = 0 ; Index < PrefContext -> MixerWindow -> DialogCount ; Index ++ )
781776 {
782777 /* get id */
783- wID = (Index + 1 ) * IDC_LINE_NAME ;
778+ WCHAR LineName [MIXER_LONG_NAME_CHARS ];
779+ DWORD wID = (Index + 1 ) * IDC_LINE_NAME ;
784780
785781 if (GetDlgItemText (PrefContext -> MixerWindow -> hWnd , wID , LineName , MIXER_LONG_NAME_CHARS ) == 0 )
786782 {
@@ -792,69 +788,50 @@ UpdateDialogLineSwitchControl(
792788 if (!_wcsicmp (LineName , Line -> szName ))
793789 {
794790 /* found matching line name */
795- wID = (Index + 1 ) * IDC_LINE_SWITCH ;
796-
797- /* get dialog control */
798- hDlgCtrl = GetDlgItem (PrefContext -> MixerWindow -> hWnd , wID );
791+ wID = (Index + 1 ) * dwDialogID ;
799792
800- if (hDlgCtrl != NULL )
801- {
802- /* check state */
803- if (SendMessageW (hDlgCtrl , BM_GETCHECK , 0 , 0 ) != fValue )
804- {
805- /* update control state */
806- SendMessageW (hDlgCtrl , BM_SETCHECK , (WPARAM )fValue , 0 );
807- }
808- }
809- break ;
793+ return GetDlgItem (PrefContext -> MixerWindow -> hWnd , wID );
810794 }
811795 }
796+
797+ return NULL ;
812798}
813799
814800VOID
815- UpdateDialogLineSliderControl (
801+ UpdateDialogLineSwitchControl (
816802 PPREFERENCES_CONTEXT PrefContext ,
817803 LPMIXERLINE Line ,
818- DWORD dwDialogID ,
819- DWORD Position )
804+ LONG fValue )
820805{
821- DWORD Index ;
822- DWORD wID ;
823- HWND hDlgCtrl ;
824- WCHAR LineName [MIXER_LONG_NAME_CHARS ];
806+ HWND hDlgCtrl = GetLineDialogControl (PrefContext , Line , IDC_LINE_SWITCH );
825807
826- /* find the index of this line */
827- for (Index = 0 ; Index < PrefContext -> MixerWindow -> DialogCount ; Index ++ )
828- {
829- /* get id */
830- wID = (Index + 1 ) * IDC_LINE_NAME ;
808+ if (hDlgCtrl != NULL && SendMessageW (hDlgCtrl , BM_GETCHECK , 0 , 0 ) != fValue )
809+ SendMessageW (hDlgCtrl , BM_SETCHECK , (WPARAM )fValue , 0 );
810+ }
831811
832- if (GetDlgItemText (PrefContext -> MixerWindow -> hWnd , wID , LineName , MIXER_LONG_NAME_CHARS ) == 0 )
833- {
834- /* failed to retrieve id */
835- continue ;
836- }
812+ DWORD
813+ GetDialogLineSliderCurrentPosition (
814+ PPREFERENCES_CONTEXT PrefContext ,
815+ LPMIXERLINE Line ,
816+ DWORD dwDialogID )
817+ {
818+ HWND hDlgCtrl = GetLineDialogControl (PrefContext , Line , dwDialogID );
837819
838- /* check if the line name matches */
839- if (!_wcsicmp (LineName , Line -> szName ))
840- {
841- /* found matching line name */
842- wID = (Index + 1 ) * dwDialogID ;
820+ return hDlgCtrl != NULL
821+ ? SendMessageW (hDlgCtrl , TBM_GETPOS , 0 , 0 )
822+ : 0 ;
823+ }
843824
844- /* get dialog control */
845- hDlgCtrl = GetDlgItem (PrefContext -> MixerWindow -> hWnd , wID );
825+ VOID
826+ UpdateDialogLineSliderControl (
827+ PPREFERENCES_CONTEXT PrefContext ,
828+ LPMIXERLINE Line ,
829+ DWORD dwDialogID ,
830+ DWORD Position )
831+ {
832+ HWND hDlgCtrl = GetLineDialogControl (PrefContext , Line , dwDialogID );
833+ BOOL isPositionChanged = GetDialogLineSliderCurrentPosition (PrefContext , Line , dwDialogID ) != Position ;
846834
847- if (hDlgCtrl != NULL )
848- {
849- /* check state */
850- LRESULT OldPosition = SendMessageW (hDlgCtrl , TBM_GETPOS , 0 , 0 );
851- if (OldPosition != Position )
852- {
853- /* update control state */
854- SendMessageW (hDlgCtrl , TBM_SETPOS , (WPARAM )TRUE, Position );
855- }
856- }
857- break ;
858- }
859- }
860- }
835+ if (hDlgCtrl != NULL && isPositionChanged )
836+ SendMessageW (hDlgCtrl , TBM_SETPOS , (WPARAM )TRUE, Position );
837+ }
0 commit comments