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);
  • 相关阅读:
    codevs 1569 最佳绿草

    luogu P3378 【模板】堆
    cogs 762. [USACO Open09] 奶牛队列
    各种 Python 实现的简单介绍与比较
    与 的区别
    Python3 print()函数sep,end,file参数用法练习
    python基础
    servlet篇 之 跳转问题
    servlet篇 之 servlet的访问
  • 原文地址:https://www.cnblogs.com/yuqilihualuo/p/3579797.html
Copyright © 2011-2022 走看看