Slide BAR + edit box used to set USER Parameters

Source: Internet
Author: User

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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.