BOOL CXTPCustomizeMenusPage::OnInitDialog() { CXTPPropertyPage::OnInitDialog(); CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); CString strDefaultMenu; GetDlgItemText(XTP_IDC_STATIC_DESCRIPTION, strDefaultMenu); if (_tcschr(strDefaultMenu, _T('\n')) != NULL) { AfxExtractSubString(m_strDefaultMenuDesc, strDefaultMenu, 1); AfxExtractSubString(m_strDefaultMenu, strDefaultMenu, 0); } else { m_strDefaultMenu = m_strDefaultMenuDesc = strDefaultMenu; } int nIndex = m_cmbAppMenus.AddString(m_strDefaultMenu); m_cmbAppMenus.SetItemData(nIndex, 0); int nCurSel = 0; if (pCommandBars->GetMenuBar() && ((pCommandBars->GetMenuBar()->GetFlags() & xtpFlagIgnoreSetMenuMessage) == 0)) { CXTPMenuBar* pMenuBar = pCommandBars->GetMenuBar(); CXTPMenuBarMDIMenus* pMDIControls = pMenuBar->GetMDIMenus(); POSITION pos = pMDIControls->GetStartPosition(); CXTPMenuBarMDIMenuInfo* pInfo; while (pos) { pMDIControls->GetNextMenu(pos, pInfo); if (pInfo->m_nIDResource == pMenuBar->GetDefaultMenuResource()) continue; if (!pInfo->m_strTitle.IsEmpty()) { nIndex = m_cmbAppMenus.AddString(pInfo->m_strTitle); m_cmbAppMenus.SetItemData(nIndex, (DWORD_PTR)pInfo); if (pInfo->m_nIDResource == pMenuBar->GetCurrentMenuResource()) { nCurSel = nIndex; } } } } m_cmbAppMenus.SetCurSel(nCurSel); OnSelectionChangedAppmenus(); nIndex = m_cmbContextMenus.AddString(_T("")); m_cmbContextMenus.SetItemData(nIndex, 0); for (int i = 0; i < pCommandBars->GetContextMenus()->GetCount(); i++) { CXTPPopupBar* pPopupBar = (CXTPPopupBar*)pCommandBars->GetContextMenus()->GetAt(i); nIndex = m_cmbContextMenus.AddString(pPopupBar->GetTitle()); m_cmbContextMenus.SetItemData(nIndex, (DWORD_PTR)pPopupBar); } m_cmbContextMenus.SetCurSel(0); OnSelectionChangedContextmenus(); SetResize(XTP_IDC_STATIC_APPLICATIONMENUS, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); SetResize(XTP_IDC_STATIC_CONTEXTMENUS, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }