MFC学习笔记

1.DoDataExchange函数其实是一项数据动态绑定技术,在此处我们定义了 CStatic m_Static,m_Static1;  分别来绑定IDC_STATIC1和IDC_STATIC2,然后来传递参数

void CLesson22Dlg::DoDataExchange(CDataExchange* pDX)

{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_STATIC1, m_Static);
DDX_Control(pDX, IDC_STATIC2, m_Static1);

}


// CLesson22Dlg message handlers
BOOL CLesson22Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog.  The framework does this automatically
//  when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
m_Static.SetWindowText("使用函数显示静态文本控件");   //通过变量m_Static传递的参数
m_Static1.SetWindowText("DoDataExchange是用来传递变量与静态文本的数据交换的!");//通过变量m_Static1传递的参数

return TRUE;  // return TRUE  unless you set the focus to a control
}




你可能感兴趣的:(mfc)