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);
  • 相关阅读:
    http协议
    三次握手四次挥手的原理
    mmap
    I/O多路复用之poll
    I/O多路转接之select
    自旋锁、文件锁、大内核锁
    网络基础(一)
    线程同步之(信号量)
    进程与线程的简单理解
    内存溢出——程序员必备网站
  • 原文地址:https://www.cnblogs.com/yuqilihualuo/p/3579797.html
Copyright © 2011-2022 走看看