zoukankan      html  css  js  c++  java
  • MFC编辑框的使用

    编辑框的提取

    在使用是控件时,设置属性为多行垂直滚动,这样可避免文字的滚动

    1.在void CDialogDlg::OnChangeEdit1()

    void CDialogDlg::DoDataExchange(CDataExchange* pDX)
    {
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CDialogDlg)
            // NOTE: the ClassWizard will add DDX and DDV calls here
        //}}AFX_DATA_MAP
    
        DDX_CBString(pDX,IDC_EDIT1,m_edite1);
    }

    2.在此编辑框的消息响应函数中读取

    void CDialogDlg::OnChangeEdit1() 
    {
        // TODO: If this is a RICHEDIT control, the control will not
        // send this notification unless you override the CDialog::OnInitDialog()
        // function and call CRichEditCtrl().SetEventMask()
        // with the ENM_CHANGE flag ORed into the mask.
        
        // TODO: Add your control notification handler code here
        //获取编辑框内容方式1 
    //        GetDlgItem(IDC_EDIT1)->GetWindowText(m_edite1);   
        //获取编辑框内容方式2
    //    GetDlgItemText(IDC_EDIT1,m_edite1);
    }

    2.如何给编辑框关联变量,如何让编辑框显示文本

    //获得EDIT
    
    CEdit* pBoxOne;
    
    pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);
    
    //付值
    
    pBoxOne->SetWindowText( _T"FOO" );
    
    //取值
    
    CString str;
    
    pBoxOne->GetWindowText(str);
    
    GetDlgItem(IDC_EDIT1)->SetWindowText( _T"FOO" );
    
    也可以
    
    //取值
    
    CString str;
    
    GetDlgItem(IDC_EDIT1)->GetWindowText(str);
  • 相关阅读:
    bzoj2733: [HNOI2012]永无乡
    bzoj3141: [Hnoi2013]旅行
    bzoj3144: [Hnoi2013]切糕
    bzoj3140: [Hnoi2013]消毒
    bzoj3139: [Hnoi2013]比赛
    bzoj3142: [Hnoi2013]数列
    bzoj3572: [Hnoi2014]世界树
    bzoj2286: [Sdoi2011]消耗战
    bzoj3611: [Heoi2014]大工程
    The Unsolvable Problem
  • 原文地址:https://www.cnblogs.com/yuqilihualuo/p/3579797.html
Copyright © 2011-2022 走看看