文本框输入信息

#if !defined(AFX_MYDIALOG_H__2BF8FD18_5E95_402F_899C_0B436D48FF77__INCLUDED_)
#define AFX_MYDIALOG_H__2BF8FD18_5E95_402F_899C_0B436D48FF77__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyDialog.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// MyDialog dialog

class MyDialog : public CDialog
{
// Construction
public:
	MyDialog(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
	//{{AFX_DATA(MyDialog)
	enum { IDD = IDD_DIALOG1 };
	CEdit	m_EditEnglish;
	CEdit	m_EditID;
	CString	m_strName;
	//}}AFX_DATA
   CString m_strID;
   CString m_strEnglish;

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(MyDialog)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(MyDialog)
	virtual void OnOK();
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MYDIALOG_H__2BF8FD18_5E95_402F_899C_0B436D48FF77__INCLUDED_)



// MyDialog.cpp : implementation file
//

#include "stdafx.h"
#include "wenben.h"
#include "MyDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// MyDialog dialog


MyDialog::MyDialog(CWnd* pParent /*=NULL*/)
	: CDialog(MyDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(MyDialog)
	m_strName = _T("");
	//}}AFX_DATA_INIT
}


void MyDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(MyDialog)
	DDX_Control(pDX, IDC_EDIT3, m_EditEnglish);
	DDX_Control(pDX, IDC_EDIT2, m_EditID);
	DDX_Text(pDX, IDC_EDIT1, m_strName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(MyDialog, CDialog)
	//{{AFX_MSG_MAP(MyDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MyDialog message handlers

void MyDialog::OnOK() 
{
	// TODO: Add extra validation here
/*	m_EditID.GetWindowText(m_strID);//第一种方法
    m_EditEnglish.GetWindowText(m_strEnglish);*/

/*	this->GetDlgItemText(IDC_EDIT2,m_strID);//第二种方法
	this->GetDlgItemText(IDC_EDIT3,m_strEnglish);*/

	CWnd *pW=GetDlgItem(IDC_EDIT2);//第三种方法
	pW->GetWindowText(m_strID);
	pW=this->GetDlgItem(IDC_EDIT3);
    pW->GetWindowText(m_strEnglish);
	CDialog::OnOK();
}

BOOL MyDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	//this->UpdateData(true);
	 CWnd *pW=GetDlgItem(IDC_EDIT2);
	 pW->SetWindowText("0001");
	 m_strName="zhangsan";
	 this->UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


// wenbenView.cpp : implementation of the CWenbenView class
//

#include "stdafx.h"
#include "wenben.h"
#include "MyDialog.h"
#include "wenbenDoc.h"
#include "wenbenView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWenbenView

IMPLEMENT_DYNCREATE(CWenbenView, CView)

BEGIN_MESSAGE_MAP(CWenbenView, CView)
	//{{AFX_MSG_MAP(CWenbenView)
	ON_COMMAND(ID_MENUITEM32771, OnMenuitem32771)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWenbenView construction/destruction

CWenbenView::CWenbenView()
{
	// TODO: add construction code here
strName = ("");
}

CWenbenView::~CWenbenView()
{
}

BOOL CWenbenView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CWenbenView drawing

void CWenbenView::OnDraw(CDC* pDC)
{
	CWenbenDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	pDC->TextOut(10,10,strName);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CWenbenView printing

BOOL CWenbenView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CWenbenView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CWenbenView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CWenbenView diagnostics

#ifdef _DEBUG
void CWenbenView::AssertValid() const
{
	CView::AssertValid();
}

void CWenbenView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CWenbenDoc* CWenbenView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWenbenDoc)));
	return (CWenbenDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CWenbenView message handlers

void CWenbenView::OnMenuitem32771() 
{
	MyDialog my;
 if(	my.DoModal()==IDOK)
 {
	strName=my.m_strName+" "+my.m_strID+" "+my.m_strEnglish;
	Invalidate();
	}
	// TODO: Add your command handler code here
	
}


你可能感兴趣的:(文本框输入信息)