MFC click to change the text addition timer scaling form, mfc Timer

Source: Internet
Author: User

MFC click to change the text addition timer scaling form, mfc Timer

1. Add the required control, Set ID: labNum1, txtNum1, txtNum2, txtNum3, and btnAdd, and convert labNum1 property to Y-> true (the control can send messages when clicked or double-clicked)

2. Double-click the labNum1 control and add the response function of labNum1. Click the text and switch the text.

Void CMFCTestDlg: OnStnClickedlabnum1 () {// TODO: add the control notification handler code CString labNum1Str; GetDlgItem (labNum1)-> GetWindowText (labNum1Str ); if (labNum1Str = TEXT ("Num1") {GetDlgItem (labNum1)-> SetWindowText (TEXT ("Number 1");} else {GetDlgItem (labNum1) -> SetWindowText (TEXT ("Num1 "));}}

3. Implement the addition Timer

① Add the variables m_num1, m_num2, and m_num3 for the controls respectively (you can set constraints if needed)

  

② Add a response function for btnAdd

Void CMFCTestDlg: OnBnClickedbtnadd () {// TODO: add the control notification handler code UpdateData () here; // call the environment variable m_num3 = m_num1 + m_num2; UpdateData (FALSE ); // update environment variable}

4. Form Scaling

① Add the control btnFlex and set the text to "Open> ". Add the control picSplit, set visible to false, and sunken to true (change the control style to a concave edge)

  

② Add Global static variables rectBig, rectSmall, rectSplit

static CRect rectBig;static CRect rectSmall;static CRect rectSlit;

③ Add the response code in OnInitDialog () in order to make the form appear after loading.

// TODO: add the additional initialization code GetWindowRect (& rectBig); GetDlgItem (picSplit)-> GetWindowRect (& rectSlit); rectSmall. top = rectBig. top; rectSmall. bottom = rectBig. bottom; rectSmall. left = rectBig. left; rectSmall. right = rectSlit. right; SetWindowPos (NULL, 0, 0, rectSmall. width (), rectSmall. height (), SWP_NOMOVE | SWP_NOZORDER );

④ Add a response function for btnSplit

Void CMFCTestDlg: OnBnClickedbtnflex () {// TODO: add the control notification handler code CString btnFlexStr; GetDlgItemText (btnFlex, btnFlexStr) here ); if (btnFlexStr = TEXT ("contract <") {SetDlgItemText (btnFlex, TEXT ("Open>"); SetWindowPos (NULL, 0, 0, rectSmall. width (), rectSmall. height (), SWP_NOMOVE | SWP_NOZORDER);} else {SetDlgItemText (btnFlex, TEXT ("contract <"); SetWindowPos (NULL, rectBig. width (), rectBig. height (), SWP_NOMOVE | SWP_NOZORDER );}}

 

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.