测试用例
#include "MyEdit.h"
class CDlgTest10Dlg : public CDialog
{
protected:
CMyEdit m_MyEdit;
virtual void OnOK();
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
……
//子类化控件
void CDlgTest10Dlg:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, m_MyEdit);
}
//处理IDOK
void CDlgTest10Dlg::OnOK()
{
CString szInput;
m_MyEdit.GetWindowText(szInput);
AfxMessageBox(szInput);
//CDialog::OnOK();
}
//消息方式接收数据
LRESULT CDlgTest10Dlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
if(message == WM_MYINPUT_MSG)
{
UINT uID = (UINT)wParam;
HWND hEdit = (HWND)lParam;
CString szInput;
::GetWindowText(hEdit, szInput.GetBuffer(1024), 1024);
szInput.ReleaseBuffer();
TRACE(_T("%u = %s\n"), uID, (LPCTSTR)szInput);
}
return CDialog::WindowProc(message, wParam, lParam);
} |