When you edit an MFC interface, you can set or modify the interface to control a parameter. You need to use a slider at this time.
Step 1: add the slider and edit box on the dialog box interface, and set properties.
If the slide bar is Vertical, The Orientatin attribute is found on the attribute panel and changed to Vertical.
Create a control variable m_sd_oil for the slider.
Assume that the ID of the edit box is IDC_ET_OIL.
Step 2: Initialize and set the slider bar range and start position
[Cpp]
BOOL CAVPage: OnInitDialog ()
{
CDialogEx: OnInitDialog ();
// TODO: Add extra initialization here
// Oil volume
M_sd_oil.SetRange (0, 10 );
M_sd_oil.SetPos (0 );
M_oil = 10;
Str. Format ("% d L", m_oil );
(CEdit *) GetDlgItem (IDC_ET_OIL)-> SetWindowText (str );
Return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages shold return FALSE
}
Step 3: Respond to the drag event
[Cpp]
Void CAVPage: OnNMCustomdrawSdOil (NMHDR * pNMHDR, LRESULT * pResult)
{
LPNMCUSTOMDRAW pNMCD = reinterpret_cast <LPNMCUSTOMDRAW> (pNMHDR );
// TODO: Add your control notification handler code here
Int nPos = m_sd_oil.GetPos ();
// Display
CString str;
M_oil = 10-nPos;
Str. Format ("% d L", m_oil );
SetDlgItemText (IDC_ET_OIL, str );
* PResult = 0;
}