BOOL CCalcFrameDlg::OnInitDialog() { CDialog::OnInitDialog(); // 将“关于...”菜单项添加到系统菜单中。 // IDM_ABOUTBOX 必须在系统命令范围内。 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); } } // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 CheckDlgButton(IDC_JIAODU,BST_CHECKED); CWnd *pWnd = NULL; CRect rcControl(0,0,0,0); //统计所有控件的位置,存入map中 for (UINT i=IDC_BT_MC;i<=IDC_STATIC_JIAOHU;i++) { pWnd = GetDlgItem(i); if( pWnd == NULL )continue; pWnd->GetWindowRect(&rcControl); m_Position.insert(std::pair<UINT,CPoint>(i,CPoint(rcControl.left,rcControl.top))); } CRect rcClient; GetClientRect(&rcClient); RectifyControl(rcClient.Width(),rcClient.Height()); //CString str; //str.Format("%c",ITOA(1)); //MessageBox(str); return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }
BOOL CSyncDirSet::OnInitDialog() { CMyDialog::OnInitDialog(); CRect rcControl(0, 0, 0, 0); m_btClose.Create(NULL, WS_CHILD | WS_VISIBLE, rcControl, this, IDCANCEL); m_btClose.SetBackImage(_T("res\\close1.png"), _T("res\\close2.png"), _T("res\\close3.png"), _T("res\\close4.png")); m_btClose.SetButtonType(BT_PUSHBUTTON); m_btClose.SetParentBack(GetBackDC()); m_btClose.SetSize(18, 18); CRect rcCleint; GetClientRect(&rcCleint); SetControlPos(rcCleint.Width(), rcCleint.Height()); OnInitButton(); OnInitListCtrl(); return TRUE; }