MFC学习记录 4.CListCtrl续
增强上节程序的易用性
代码摘要1.列表视图随窗口大小变化a.在对话框编辑器中设置对话框属性Border:Resizingb.在ClassWizard中为窗口添加WM_SIZE消息映射注:在OnSize中MoveWindow必须确保控件已经初始化,用IsWindow来判断示例代码:void CMfc2Dlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: Add your message handler code here if (nType==SIZE_MINIMIZED) return; if (!::IsWindow(m_List.m_hWnd)) return; RECT rect; rect.left=3; rect.top=40; rect.right=cx-3; rect.bottom=cy-5; m_List.MoveWindow(&rect);}
2.添加菜单a.在Resource中添加菜单,在菜单编辑器中编辑b.到对话框属性中设置Menuc.ClassWizard中为菜单添加消息映射函数示例代码:void CMfc2Dlg::OnMenuitemAbout() { // TODO: Add your command handler code here CAboutDlg dlg; dlg.DoModal();}
源代码mfc_study_3.zip(37KB)http://atlab.cn/down/mfc_study_3.zip