zoukankan      html  css  js  c++  java
  • mydialog.cpp

    // mydialog2.cpp : implementation file
    //
    
    #include "stdafx.h"
    #include "My.h"
    #include "mydialog2.h"
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif
    
    /////////////////////////////////////////////////////////////////////////////
    // Cmydialog2 dialog
    
    
    Cmydialog2::Cmydialog2(CWnd* pParent /*=NULL*/)
       : CDialog(Cmydialog2::IDD, pParent)
    {
    	//{{AFX_DATA_INIT(Cmydialog2)
    	m_strName = _T("zhangsan");
    	m_strID="";
    	m_strScore = _T("");
    	//}}AFX_DATA_INIT
    }
    
    
    void Cmydialog2::DoDataExchange(CDataExchange* pDX)
    {
    	CDialog::DoDataExchange(pDX);
    	//{{AFX_DATA_MAP(Cmydialog2)
    	DDX_Control(pDX, IDC_EDIT2, m_EditID);
    	DDX_Text(pDX, IDC_EDIT1, m_strName);
    	DDX_Text(pDX, IDC_EDIT3, m_strScore);
    	//}}AFX_DATA_MAP
    }
    
    
    BEGIN_MESSAGE_MAP(Cmydialog2, CDialog)
    	//{{AFX_MSG_MAP(Cmydialog2)
    	//}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    /////////////////////////////////////////////////////////////////////////////
    // Cmydialog2 message handlers
    
    void Cmydialog2::OnOK() 
    {
    	// TODO: Add extra validation here
    //2.绑定控件	
    //	m_EditID.GetWindowText(m_strID);
    
    
    //3.绑定由ID决定
    	CWnd *pW=GetDlgItem(IDC_EDIT3);
    	pW->GetWindowText(m_strScore);//获得文本
    	pW=GetDlgItem(IDC_EDIT2);
    	pW->GetWindowText(m_strID);
    	pW=GetDlgItem(IDC_EDIT1);
    	pW->GetWindowText(m_strName);
    
    
    //4.用成员函数
    //	this->GetDlgItem(IDC_EDIT1, m_strName);
    	
    	CDialog::OnOK();
    
    
    }
    
    
    //控件消息第一个被调用的是InitDialog() ,所以在其中赋初值
    BOOL Cmydialog2::OnInitDialog() 
    {
    	CDialog::OnInitDialog();
    	
    	// TODO: Add extra initialization here
    ///使有初值
    	//绑定的值类型必须用一个函数UpdateData()区分
    	this->UpdateData(true);//读进去,在最上边
    //	m_strName="zhangsan";
    //	this->UpdateData(false);//先赋值再刷新,然后再显示出来
    
    
    	CWnd *pW=GetDlgItem(IDC_EDIT2);
    	pW->SetWindowText("00001");//set 赋值
    	pW=this->GetDlgItem(IDC_EDIT1);
    	pW->SetWindowText("张三");
    	pW=this->GetDlgItem(IDC_EDIT3);
    	pW->SetWindowText("100");
    
    	return TRUE;  // return TRUE unless you set the focus to a control
    	              // EXCEPTION: OCX Property Pages should return FALSE
    }
    

  • 相关阅读:
    leetcode 763. Partition Labels
    JS字符串格式化~欢迎来搂~~
    手把手教你在pycharm上上传项目至GitHub
    手把手教你用原始方式上传项目至GitHub
    python3.7环境下创建app、运行Django1.11版本项目报错Generator expression must be parenthesized
    在学习python的DjangoFlaskTornado前你需要知道的,what is web?
    python手撸桌面计算器
    jQuery之克隆事件--clone()与clone(true)区别
    前端之jQuery基础
    通过案例来剖析JQuery与原生JS
  • 原文地址:https://www.cnblogs.com/IT-hexiang/p/4084629.html
Copyright © 2011-2022 走看看