Home > Software engineering >  Questions about VS13 MFC inside the volume setting function
Questions about VS13 MFC inside the volume setting function

Time:09-27

Read a piece of code about the music playing, try to run, found that when playback volume that module volume will not change when sliding the slider, studying the next don't know what problem, consult the great god, thank mua,
 
//start time interface
BOOL Cmfc_music_playerDlg: : OnInitDialog ()
{
CDialogEx: : OnInitDialog ();

//will "about... "Menu item added to the system menu,

//IDM_ABOUTBOX must be in the system command range,
ASSERT ((IDM_ABOUTBOX & amp; 0==IDM_ABOUTBOX xfff0));
ASSERT (IDM_ABOUTBOX & lt; 0 xf000);

CMenu * pSysMenu=GetSystemMenu (FALSE);
If (pSysMenu!=NULL)
{
BOOL bNameValid;
Cstrings strAboutMenu;
BNameValid=strAboutMenu. LoadString (IDS_ABOUTBOX);
ASSERT (bNameValid);
if (! StrAboutMenu. IsEmpty ())
{
PSysMenu - & gt; The AppendMenu (MF_SEPARATOR);
PSysMenu - & gt; AppendMenu (MF_STRING IDM_ABOUTBOX, strAboutMenu);
}
}

//set this dialog ICONS, when the application is the main window is not a dialog, the framework will automatically
//do this
SetIcon (m_hIcon, TRUE);//set the large icon
SetIcon (m_hIcon, FALSE);//set the small icon
M_slider. SetRange (0, 100);//the movement of the slider range is 0 ~ 1000
M_slider. SetPos (50);//slider pointer disposal location for 500, on behalf of the first volume of 500
GetDlgItem (IDC_play) - & gt; The EnableWindow (false);//file didn't read all buttons we don't choose
GetDlgItem (IDC_pause) - & gt; The EnableWindow (false);
GetDlgItem (IDC_stop) - & gt; The EnableWindow (false);
//TODO: add additional initialization code in the

return TRUE;//unless set focus to the control, return TRUE
}

//set the volume
DWORD setVolume (DWORD vol)
{
MCI_DGV_SETAUDIO_PARMS setvolume;//set the volume parameter
Setvolume. DwCallback=NULL;//
Setvolume. DwItem=MCI_DGV_SETAUDIO_VOLUME;//action is to set the volume
Setvolume. The dwValue=https://bbs.csdn.net/topics/vol;//the volume value is vol
The McISendCommand (DeviceId MCI_SETAUDIO, MCI_DGV_SETAUDIO_ITEM | MCI_DGV_SETAUDIO_VALUE, (DWORD) (LPVOID) & amp; Setvolume);
return 0;
}

//slider corresponding function
Void Cmfc_music_playerDlg: : OnCustomdrawSlider (NMHDR * pNMHDR, LRESULT * pResult)
{
The UpdateData (true);
M_int=m_slider. GetPos ();
SetVolume (m_slider GetPos ());
The UpdateData (false);
//LPNMCUSTOMDRAW pNMCD=reinterpret_cast & lt; LPNMCUSTOMDRAW> (pNMHDR);
//TODO: add the control notification handler code
* pResult=0;
}


CodePudding user response:

Need MCI_DGV_SETAUDIO_VOLUME

CodePudding user response:

reference 1st floor cutmelon response:
need MCI_DGV_SETAUDIO_VOLUME.

Uh-huh, I try

CodePudding user response:

The UpdateData (true);
M_int=m_slider. GetPos ();
M_play. Setvolume (m_int);
The UpdateData (false);
  • Related