void CXTPCustomizeToolbarsPage::OnSelectionChanged() { int nIndex = m_checkList.GetCurSel(); if (nIndex != LB_ERR) { CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i >= 0 && i < pCommandBars->GetCount()) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); BOOL bBuiltIn = pToolBar->IsBuiltIn(); m_btnReset.EnableWindow(bBuiltIn); m_btnRename.EnableWindow(!bBuiltIn); m_btnDelete.EnableWindow(!bBuiltIn); } } else { m_btnReset.EnableWindow(FALSE); m_btnRename.EnableWindow(FALSE); m_btnDelete.EnableWindow(FALSE); } }
void CXTPCustomizeToolbarsPage::OnDeleteToolbar() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i < 0 || i >= pCommandBars->GetCount()) return; CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (pToolBar->IsBuiltIn()) return; CString strMessage; CString strDelete; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strDelete, XTP_IDS_CONFIRM_DELETE)); strMessage.Format(strDelete, (LPCTSTR)pToolBar->GetTitle()); if (m_pSheet->MessageBox(strMessage, MB_ICONWARNING | MB_OKCANCEL) == IDOK) { pCommandBars->GetSite()->SendMessage(WM_XTP_CUSTOMIZATION_DELETETOOLBAR, 0, (LPARAM)pToolBar); pCommandBars->Remove(pToolBar); RefreshToolbarsList(); } }
void CXTPCustomizeToolbarsPage::OnRenameToolbar() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i < 0 || i >= pCommandBars->GetCount()) return; CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (pToolBar->IsBuiltIn()) return; CXTPNewToolbarDlg dlg(m_pSheet, pCommandBars, pToolBar); if (dlg.DoModal() == IDOK) { pToolBar->SetTitle(dlg.m_strToolbar); m_checkList.DeleteString(nIndex); nIndex = m_checkList.InsertString(nIndex, pToolBar->GetTitle()); m_checkList.SetCheck(nIndex, pToolBar->IsVisible()); m_checkList.SetItemData(nIndex, i); m_checkList.SetCurSel(nIndex); } }
void CXTPNewToolbarDlg::SetSuggestedName() { CString szMsg; XTPResourceManager()->LoadString(&szMsg, XTP_IDS_CUSTOM_BAR); int iNewID = 1; CString strCustom; strCustom.Format(szMsg, iNewID); int nCount = m_pCommandBars->GetCount(); int nIndex = 0; while (nIndex < nCount) { CXTPToolBar* pBar = m_pCommandBars->GetAt(nIndex); ASSERT(pBar != NULL); if (pBar && strCustom.Compare(pBar->GetTitle()) == 0) { strCustom.Format(szMsg, iNewID++); nIndex = 0; continue; } nIndex++; } m_strToolbar = strCustom; UpdateData(FALSE); }
void CXTPNewToolbarDlg::OnOK() { UpdateData(); // If no text was entered, alert user. if (m_strToolbar.IsEmpty()) { XTPResourceManager()->ShowMessageBox(XTP_IDS_ERROR_BLANKNAME, MB_ICONSTOP); return; } m_nNewID = AFX_IDW_CONTROLBAR_FIRST; // Loop through all of the existing control bars to find // an available ID to use. int nCount = m_pCommandBars->GetCount(); int nIndex = 0; while (nIndex < nCount) { CXTPToolBar* pBar = m_pCommandBars->GetAt(nIndex); ASSERT(pBar != NULL); // We found a control bar with the same ID as m_nNewID, increment // m_nNewID and reset the position back to the head. if (pBar && m_pCommandBar == NULL && pBar->GetBarID() == m_nNewID) { m_nNewID++; // If m_nNewID is greater than the maximum number of allowed // custom commands, alert the user and abort. if ((int)m_nNewID >= AFX_IDW_CONTROLBAR_LAST) { XTPResourceManager()->ShowMessageBox(XTP_IDS_ERROR_LIMIT, MB_ICONSTOP); CDialog::OnCancel(); return; } nIndex = 0; continue; } // Now check to see if the title for the toolbar has already // been used, if so, alert the user and return. if (pBar && m_pCommandBar != pBar && m_strToolbar.Compare(pBar->GetTitle()) == 0) { CString strName, strError; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strError, XTP_IDS_ERROR_EXISTS)); strName.Format(strError, (LPCTSTR)m_strToolbar); XTPResourceManager()->ShowMessageBox(strName, MB_ICONSTOP); return; } nIndex++; } CDialog::OnOK(); // success! }
void CXTPCustomizeToolbarsPage::OnResetToolbar() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i < 0 || i >= pCommandBars->GetCount()) return; CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (!pToolBar->IsBuiltIn()) return; CString strMessage, strTitle = pToolBar->GetTitle(), strReset; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strReset, XTP_IDS_CONFIRM_RESET)); strMessage.Format(strReset, (LPCTSTR)strTitle); if (m_pSheet->MessageBox(strMessage, MB_ICONWARNING | MB_OKCANCEL) != IDOK) return; pToolBar->Reset(FALSE); RefreshToolbarsList(); }
void CXTPDockBar::GetVisibleToolbars(int nPos, CToolBarArray& arrBars) { ASSERT(nPos != -1); ASSERT(m_arrBars[nPos]); while (m_arrBars[nPos] != NULL && nPos > 0) { nPos--; } nPos++; CDockInfoArray arrInfo; while (m_arrBars[nPos] != NULL) { CXTPToolBar* pBar = m_arrBars[nPos++]; if (pBar->IsVisible()) { DOCK_INFO dockInfo(pBar, CXTPWindowRect(pBar), nPos); arrInfo.Add(dockInfo); } } if (m_dwStyle & CBRS_LEFT || m_dwStyle & CBRS_RIGHT) arrInfo.InvertRects(); arrInfo.Sort(); for (int i = 0; i < arrInfo.GetSize(); i++) { arrBars.Add(arrInfo[i].pBar); } }
void CXTPCustomizeToolbarsPage::OnChkChange() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i >= 0 && i < pCommandBars->GetCount()) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (!pToolBar->IsCloseable()) { m_checkList.SetCheck(nIndex, 1); MessageBeep(0); } else { BOOL bVisible = m_checkList.GetCheck(nIndex); pToolBar->SetVisible(bVisible); } } RefreshToolbarsList(); }
CSize CXTPDockBar::CalcDynamicLayout(int nLength, DWORD nMode, AFX_SIZEPARENTPARAMS* lpLayout) { BOOL bHorz = nMode & LM_HORZ; BOOL bStretch = nMode & LM_STRETCH; CSize sizeFixed (bStretch && bHorz ? 32767 : 0, bStretch && !bHorz ? 32767 : 0); BOOL bLayoutQuery = (lpLayout->hDWP == NULL); // prepare for layout AFX_SIZEPARENTPARAMS layout; layout.hDWP = bLayoutQuery ? 0 : ::BeginDeferWindowPos((int)m_arrBars.GetSize()); CPoint pt(0, 0); // layout all the control bars for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++) { CToolBarArray lst; CXTPToolBar* pBar = GetDockedCommandBar(nPos); while (pBar) { if (pBar->IsVisible()) lst.Add(pBar); pBar = GetDockedCommandBar(++nPos); } int nWidth = 0; if (lst.GetSize() != 0) { nWidth = AdjustRow(lst, pt, nLength, bHorz, &layout); lst.RemoveAll(); } if (pBar == NULL && nWidth != 0) { // end of row because pBar == NULL if (bHorz) { pt.y += nWidth; sizeFixed.cy = max(sizeFixed.cy, pt.y); } else { pt.x += nWidth; sizeFixed.cx = max(sizeFixed.cx, pt.x); } } } if (!bLayoutQuery) { // move and resize all the windows at once! if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP)) TRACE0("Warning: DeferWindowPos failed - low system resources.\n"); } return sizeFixed; }
int CXTPDockBar::GetDockedVisibleCount() const { int nCount = 0; for (int i = 0; i < m_arrBars.GetSize(); i++) { CXTPToolBar* pBar = GetDockedCommandBar(i); if (pBar != NULL && pBar->IsVisible()) nCount++; } return nCount; }
int CXTPDockBar::Insert(CXTPToolBar* pBarIns, CRect /*rect*/, CPoint ptMid) { ASSERT_VALID(this); ASSERT(pBarIns != NULL); int nPos = 0; int nPosInsAfter = 0; int nWidth = 0; int nTotalWidth = 0; //int nPosInsBefore = 0; BOOL bHorz = m_dwStyle & CBRS_ORIENT_HORZ; BOOL bAllowTopMost = pBarIns->IsRibbonBar() || m_pCommandBars->GetMenuBar() == NULL || !m_pCommandBars->GetMenuBar()->IsRibbonBar() || FindBar(m_pCommandBars->GetMenuBar()) == -1; for (nPos = 0; nPos < m_arrBars.GetSize(); nPos++) { CXTPToolBar* pBar = GetDockedCommandBar(nPos); if (pBar && !pBar->IsVisible()) continue; if (pBar != NULL) { CRect rectBar; pBar->GetWindowRect(&rectBar); ScreenToClient(&rectBar); nWidth = max(nWidth, bHorz ? rectBar.bottom : rectBar.right); } else // end of row because pBar == NULL { if ((bHorz ? ptMid.y : ptMid.x) < nWidth && (bAllowTopMost || nPosInsAfter > 1)) { if (nPos == 0 || ((bHorz ? ptMid.y : ptMid.x) == nTotalWidth)) // first section m_arrBars.InsertAt(nPosInsAfter + 1, (CXTPToolBar*)NULL); m_arrBars.InsertAt(nPosInsAfter + 1, pBarIns); return nPosInsAfter + 1; } nTotalWidth = nWidth; nWidth = 0; nPosInsAfter = nPos; } } // create a new row m_arrBars.InsertAt(nPosInsAfter + 1, (CXTPToolBar*)NULL); m_arrBars.InsertAt(nPosInsAfter + 1, pBarIns); return nPosInsAfter + 1; }
CWnd* CXTPControlCustom::FindChildWindow(CXTPCommandBars* pCommandBars, UINT nID) { CWnd* pWndSite = pCommandBars->GetSite(); if (pWndSite->GetDlgItem(nID) != NULL) return pWndSite->GetDlgItem(nID); for (int i = 0; i < pCommandBars->GetCount(); i++) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (pToolBar->GetDlgItem(nID) != NULL) return pToolBar->GetDlgItem(nID); } return NULL; }
void CXTPDockBar::AdjustStretchBars() { for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++) { CXTPToolBar* pBar = GetDockedCommandBar(nPos); if (pBar && pBar->GetFlags() & xtpFlagStretched) { if (nPos > 0 && GetDockedCommandBar(nPos - 1) != NULL) { m_arrBars.InsertAt(nPos, (CXTPToolBar*)NULL); nPos++; } if (nPos < m_arrBars.GetSize() -1 && GetDockedCommandBar(nPos + 1) != NULL) { m_arrBars.InsertAt(nPos + 1, (CXTPToolBar*)NULL); nPos++; } } } }
void gkToolBarPaneBase::InitToolBar( const TCHAR* toolbarname, DWORD nId ) { ////////////////////////////////////////////////////////////////////////// // ToolBar Initilizing VERIFY(InitCommandBars()); CXTPCommandBars* pCommandBars = GetCommandBars(); pCommandBars->GetImageManager()->SetIcons(nId); pCommandBars->SetTheme(xtpThemeWhidbey); //pCommandBars->SetQuickCustomizeMode(FALSE); //TCHAR toolbarname = CXTPToolBar* pToolBar = pCommandBars->Add(toolbarname, xtpBarTop); pToolBar->SetDefaultButtonStyle(xtpButtonIcon); pToolBar->LoadToolBar(nId); pToolBar->SetCloseable(FALSE); pToolBar->EnableCustomization(); pToolBar->GetControls()->CreateOriginalControls(); pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipOffice2007); RecalcLayout(); ////////////////////////////////////////////////////////////////////////// }
void CAlphaIconsPage::OnActivate() { CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd(); CXTPCommandBars* pCommandBars = pFrame->GetCommandBars(); ASSERT(pCommandBars); CXTPToolBar* pToolBar = pCommandBars->GetAt(1); ASSERT(pToolBar->GetTitle() == _T("Standard")); XTPImageManager()->RemoveAll(); pToolBar->LoadToolBar(IDR_ICONS_MENU_32); XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo(); pIconsInfo->bUseDisabledIcons = TRUE; CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); pOptions->szIcons = CSize(16, 16); pOptions->szLargeIcons = CSize (42, 35); pOptions->bLargeIcons = FALSE; XTPImageManager()->SetIcons(IDR_ICONS_TOOLBAR_32); if (!XTPImageManager()->IsAlphaIconsSupported()) { m_bResample = TRUE; GetDlgItem(IDC_CHECK_RESAMPLE)->EnableWindow(FALSE); UpdateData(FALSE); } ResampleImages(); UpdateContent(); }
void CXTPCustomizeToolbarsPage::RefreshToolbarsList() { int nIndexSel = 0; int nIndex = m_checkList.GetCurSel(); if (nIndex != LB_ERR) { nIndexSel = (int)m_checkList.GetItemData(nIndex); } int nTopIndex = m_checkList.GetTopIndex(); m_checkList.ResetContent(); CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int nCount = pCommandBars->GetCount(); for (int i = 0; i < nCount; i++) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (!pToolBar->IsCustomizeDialogPresent()) continue; if (!pToolBar->IsCloseable() && !pToolBar->IsVisible()) continue; nIndex = m_checkList.AddString(pToolBar->GetTitle()); m_checkList.SetCheck(nIndex, pToolBar->IsVisible()); m_checkList.SetItemData(nIndex, i); if (i == nIndexSel) m_checkList.SetCurSel(nIndex); } if (m_checkList.GetTopIndex() != nTopIndex) m_checkList.SetTopIndex(nTopIndex); OnSelectionChanged(); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { AfxGetApp()->m_nCmdShow = SW_HIDE; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; this->CenterWindow(CWnd::GetDesktopWindow()); if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } if (!InitCommandBars()) return -1; CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; // fail to create } //设置下面状态栏 m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL); m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, 250); m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, 120); m_wndStatusBar.SetPaneInfo(3, m_wndStatusBar.GetItemID(3), SBPS_NORMAL, 120); /* m_wndStatusBar.EnableCustomization(); if (!m_TrayIcon.Create(_T(""), // Toolktip text this, // Parent window IDR_MAINFRAME, // Icon resource ID IDR_MINIMIZE, // Resource ID of popup menu IDM_SHOW, // Default menu item for popup menu false)) // True if default menu item is located by position { TRACE0("Failed to create tray icon\n"); return -1; } */ if (!InitCommandBars()) { return -1; } // CXTPCommandBars* pCommandBars = GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); pMenuBar->SetFlags(xtpFlagAddMDISysPopup); /* CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) { TRACE0("Failed to create toolbar\n"); return -1; }; */ CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("工具栏(T)"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) // { TRACE0("Failed to create toolbar\n"); return -1; } pCommandBars->GetCommandBarsOptions()->bShowTextBelowIcons = TRUE; pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); /* // Create ToolBar CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("工具栏(T)"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) // { TRACE0("Failed to create toolbar\n"); return -1; } // LoadIcons(); CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); pOptions->bShowExpandButtonAlways= FALSE; pOptions->bShowTextBelowIcons = true; pOptions->bLargeIcons = TRUE; pCommandBar->GetImageManager()->SetIcons(IDR_TOOLBAR3,IDB_BITMAP1); RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN); GetCommandBars()->GetPaintManager()->RefreshMetrics(); ModifyStyle(WS_THICKFRAME, 0); ModifyStyle(0, WS_THICKFRAME); pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowNever); */ m_paneManager.InstallDockingPanes(this); m_paneManager.SetTheme(xtpPaneThemeVisualStudio2010); // 设置主题 CXTPDockingPane* pwndPaneLog = CreatePane(235, 150, RUNTIME_CLASS(CLogView), _T("日志信息"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneNum = CreatePane(58, 150, RUNTIME_CLASS(CShowNum), _T("主机统计"), xtpPaneDockRight, pwndPaneLog); // CXTPDockingPane* pwndPaneChoose = CreatePane(235, 150, RUNTIME_CLASS(CMoreChoose), _T("筛选主机"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneUPDATEIP = CreatePane(235, 150, RUNTIME_CLASS(CUPDATEIP), _T("域名更新"), xtpPaneDockBottom); // CXTPDockingPane* pwndPaneBatch = CreatePane(235, 150, RUNTIME_CLASS(CBatch), _T("批量命令"), xtpPaneDockBottom); // CXTPDockingPane* pwndPaneplay = CreatePane(260, 145, RUNTIME_CLASS(CBuildServer), _T("整蛊娱乐"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneproxy = CreatePane(235, 150, RUNTIME_CLASS(CProxy), _T("远程连接"), xtpPaneDockBottom); // m_paneManager.AttachPane( pwndPaneChoose, pwndPaneLog ); m_paneManager.AttachPane( pwndPaneUPDATEIP, pwndPaneLog); // m_paneManager.AttachPane( pwndPaneBatch, pwndPaneChoose); m_paneManager.AttachPane( pwndPaneproxy, pwndPaneUPDATEIP ); pwndPaneLog->Select(); pwndPaneLog->SetOptions(xtpPaneNoCaption); pwndPaneNum->SetOptions(xtpPaneNoCaption); // pwndPaneChoose->SetOptions(xtpPaneNoCaption); pwndPaneUPDATEIP->SetOptions(xtpPaneNoCaption); // pwndPaneBatch->SetOptions(xtpPaneNoCaption); // pwndPaneplay->SetOptions(xtpPaneNoCaption); pwndPaneproxy->SetOptions(xtpPaneNoCaption); /* XTPColorManager()->DisableLunaColors(TRUE); CXTPPaintManager::SetTheme(xtpThemeOffice2003); LoadCommandBars(_T("CommandBars")); SetTimer(1,1000,NULL); */ m_hDrawIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_hEmptyIcon = AfxGetApp()->LoadIcon(IDI_SYSTRAY1); m_NotifyIcon.cbSize = sizeof(NOTIFYICONDATA); m_NotifyIcon.hWnd = this->GetSafeHwnd(); CString Lineips = Onlinetips(); CString Lineips1 = OnVoicepromptsm(); wsprintf(m_NotifyIcon.szTip,"主机数量: %d台\n语音: %s\n消息提示: %s",Zjshulian,Lineips1,Lineips); m_NotifyIcon.uCallbackMessage = WM_ICONMESSAGE; m_NotifyIcon.uFlags = NIF_MESSAGE|NIF_TIP|NIF_ICON; m_NotifyIcon.hIcon = m_hDrawIcon; m_NotifyIcon.uID = IDR_MAINFRAME; Shell_NotifyIcon(NIM_ADD, &m_NotifyIcon); //初始化记录值 // m_nCurrent = 0; // SetTimer(1, 500, NULL); //开启定时器 1 return 0; }
void CXTPCustomizeMenusPage::OnButtonResetAppMenu() { CXTPToolBar* pMenuBar = m_pSheet->GetCommandBars()->GetMenuBar(); pMenuBar->Reset(TRUE); }
void CXTPCustomizeMenusPage::OnSelectionChangedContextmenus() { CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); CommitContextMenu(); int nSel = m_cmbContextMenus.GetCurSel(); if (nSel < 1) { GetDlgItem(XTP_IDC_BUTTON_RESETCONTEXT)->EnableWindow(FALSE); return; } GetDlgItem(XTP_IDC_BUTTON_RESETCONTEXT)->EnableWindow(TRUE); CXTPPopupBar* pPopupBar = (CXTPPopupBar*)m_cmbContextMenus.GetItemData(nSel); CXTPToolBar* pContextMenu = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop, RUNTIME_CLASS(CXTPFloatingPopupBar)); if (!pContextMenu) { TRACE0("Failed to create toolbar\n"); return; } CXTPControls* pControls = pPopupBar->GetControls()->Duplicate(); pContextMenu->SetControls(pControls); pContextMenu->SetBarID(pPopupBar->GetBarID()); pContextMenu->SetTitle(pPopupBar->GetTitle()); pContextMenu->SetCustomizeDialogPresent(FALSE); pContextMenu->SetPosition(xtpBarFloating); pContextMenu->EnableDocking(xtpFlagFloating); pContextMenu->OnRecalcLayout(); CXTPWindowRect rcContext(pContextMenu); CXTPWindowRect rcParent(GetParent()); CPoint pt = m_ptContextMenu; if (pt == CPoint(0, 0)) pt = CPoint(rcParent.left - rcContext.Width(), rcParent.top); pContextMenu->MoveWindow(pt.x, pt.y, rcContext.Width(), rcContext.Height()); m_pContextMenu = pContextMenu; pContextMenu->SetCommandBarData((DWORD_PTR)pPopupBar); pContextMenu->OnUpdateCmdUI(); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { AfxGetApp()->m_nCmdShow = SW_HIDE; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; //界面居中显示 this ->CenterWindow(CWnd::GetDesktopWindow()); if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL); m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, 180); m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, 100); m_wndStatusBar.SetPaneInfo(3, m_wndStatusBar.GetItemID(3), SBPS_NORMAL, 100); m_wndStatusBar.SetPaneInfo(4, m_wndStatusBar.GetItemID(4), SBPS_NORMAL, NULL); m_wndStatusBar.SetPaneInfo(5, m_wndStatusBar.GetItemID(5), SBPS_NORMAL, NULL); m_wndStatusBar.SetPaneInfo(6, m_wndStatusBar.GetItemID(6), SBPS_NORMAL, NULL); /////////////////////////////////////////////////////////////////////////////////////// m_wndStatusBar.EnableCustomization(); if (!m_TrayIcon.Create(_T(""), // Toolktip text this, // Parent window IDR_MAINFRAME, // Icon resource ID IDR_MINIMIZE, // Resource ID of popup menu IDM_SHOW, // Default menu item for popup menu false)) // True if default menu item is located by position { TRACE0("Failed to create tray icon\n"); return -1; } if (!InitCommandBars()) { return -1; } CXTPCommandBars* pCommandBars = GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); pMenuBar->SetFlags(xtpFlagAddMDISysPopup); CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) { TRACE0("Failed to create toolbar\n"); return -1; }; pCommandBars->GetCommandBarsOptions()->bShowTextBelowIcons = TRUE; pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); m_paneManager.InstallDockingPanes(this); m_paneManager.SetTheme(xtpPaneThemeWinExplorer); CXTPDockingPane* pwndPaneLog = CreatePane(300, 141, RUNTIME_CLASS(CLogView), _T("日志信息"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneShortcuts = CreatePane(200, 145, RUNTIME_CLASS(CShortcuts), _T("快捷功能"), xtpPaneDockRight,pwndPaneLog); CXTPDockingPane* pwndPaneIPUP = CreatePane(200, 145, RUNTIME_CLASS(CIPUpdate), _T("域名更新"), xtpPaneDockRight,pwndPaneLog); pwndPaneIPUP->Select(); m_paneManager.AttachPane( pwndPaneIPUP ,pwndPaneShortcuts ); pwndPaneShortcuts->SetOptions(xtpPaneNoCaption); pwndPaneIPUP->SetOptions(xtpPaneNoCaption); XTPColorManager()->DisableLunaColors(TRUE); CXTPPaintManager::SetTheme(xtpThemeOffice2003); LoadCommandBars(_T("CommandBars")); SetTimer(1,1000,NULL); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } if (!InitCommandBars()) return -1; CXTPPaintManager::SetTheme(xtpThemeOffice2003); CXTPCommandBars* pCommandBars = GetCommandBars(); pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; } pCommandBars->GetImageManager()->SetIcons(IDR_MAINFRAME, IDR_TOOLBAR_ALPHA); pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME); // Load the previous state for command bars. LoadCommandBars(_T("CommandBars")); EnableDocking(CBRS_ALIGN_ANY); SetOfficeTheme(xtpCalendarThemeOffice2007); // Initialize dialog bar if (!m_dlgDatePicker.Create(this, IDD_DATEPICKER, CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE, ID_VIEW_DATEPICKER)) return -1; // fail to create // Initialize dialog bar if (!m_dlgOptions.Create(this, IDD_CALENDAR_DEMO_VIEW, CBRS_ALIGN_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE, ID_VIEW_PROPERTIES)) return -1; // fail to create //m_dlgOptions.EnableDocking(CBRS_ALIGN_ANY); m_dlgOptions.EnableDocking(0); m_dlgOptions.SetWindowText(_T("Options")); ShowControlBar(&m_dlgOptions, FALSE, FALSE); FloatControlBar(&m_dlgOptions, CPoint(100, 200)); // docking for DatePicker m_dlgDatePicker.EnableDocking(CBRS_ALIGN_LEFT); m_dlgDatePicker.SetWindowText(_T("Date Picker")); ShowControlBar(&m_dlgDatePicker, TRUE, FALSE); //FloatControlBar(&m_dlgDatePicker, CPoint(100, GetSystemMetrics(SM_CYSCREEN) / 3)); return 0; }
int CXTPDockBar::_AdjustRow(CToolBarArray& arrRow, CPoint pt, int nLength, BOOL bHorz, AFX_SIZEPARENTPARAMS* lpLayout, int& nRemove) { CDockInfoArray arrInfo; int nPos; // Step 1. Getting maximum available size; for (nPos = 0; nPos < arrRow.GetSize(); nPos++) { CXTPToolBar* pBar = arrRow[nPos]; CSize sizeBar = pBar->CalcDockingLayout(nLength, _GetMode(bHorz, pBar)); CPoint p = bHorz ? CPoint(pBar->m_pDockContext->m_rectMRUDockPos.left, pt.y) : CPoint(pt.x, pBar->m_pDockContext->m_rectMRUDockPos.top); DOCK_INFO dockInfo(pBar, CRect(p, sizeBar), nPos); arrInfo.Add(dockInfo); } ASSERT(arrInfo.GetSize() == arrRow.GetSize()); if (!bHorz) arrInfo.InvertRects(); arrInfo.Sort(); // Step 2. if Total length is more than available, fill empty area. int nIndex = -1; int nLen = 0; BOOL bMove = TRUE; for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CRect& rect = arrInfo[nPos].rcBar; bMove = (rect.left < nLen && (nIndex < arrInfo[nPos].nIndex || bMove)); if (bMove) rect.OffsetRect(nLen - rect.left, 0); nLen = rect.right; nIndex = arrInfo[nPos].nIndex; } nLen = nLength; nIndex = -1; bMove = TRUE; for (nPos = (int)arrInfo.GetSize() - 1; nPos >= 0; nPos--) { CRect& rect = arrInfo[nPos].rcBar; bMove = (rect.right - nLen > 0 && (nIndex < arrInfo[nPos].nIndex || bMove)); if (bMove) rect.OffsetRect(nLen - rect.right, 0); nLen = rect.left; nIndex = arrInfo[nPos].nIndex; } nLen = 0; for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CRect& rect = arrInfo[nPos].rcBar; if (rect.left < nLen) rect.OffsetRect(nLen - rect.left, 0); nLen = rect.left + rect.Width(); } // Step 3. if Total length is more than available, make it expandable. if (nLen > nLength) { int nSum = 0; for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CXTPToolBar* pBar = arrInfo[nPos].pBar; if (!(_GetMode(bHorz, pBar) & LM_HIDEWRAP)) arrInfo[nPos].nMinWidth = nLength; else { CSize sz = pBar->CalcDockingLayout(1, _GetMode(bHorz, pBar)); arrInfo[nPos].nMinWidth = bHorz ? sz.cx : sz.cy; } arrInfo[nPos].nTotlaMinWidth = nSum; nSum += arrInfo[nPos].nMinWidth; } nLen = nLength; for (nPos = (int)arrInfo.GetSize() - 1; nPos >= 0; nPos--) { CRect& rect = arrInfo[nPos].rcBar; int nLeft = bHorz ? arrInfo[nPos].rcMRUPos.left : arrInfo[nPos].rcMRUPos.top; if (nLeft > rect.left) nLeft = rect.left; if (nLeft < nLen - rect.Width()) nLeft = nLen - rect.Width(); if (nLeft < arrInfo[nPos].nTotlaMinWidth) nLeft = arrInfo[nPos].nTotlaMinWidth; if (nLen - nLeft < arrInfo[nPos].nMinWidth) nLeft = nLen - arrInfo[nPos].nMinWidth; if ((nLen - nLeft < arrInfo[nPos].nMinWidth || nLeft < arrInfo[nPos].nTotlaMinWidth) && arrInfo.GetSize() != 1) { nRemove = arrInfo[arrInfo.GetSize() - 1].nIndex; return -1; } rect.right = nLen; nLen = rect.left = max(0, nLeft); } } if (!bHorz) arrInfo.InvertRects(); int nWidth = 0; // Calculate total width for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CXTPToolBar* pBar = arrInfo[nPos].pBar; CRect& rect = arrInfo[nPos].rcBar; CSize sizeBar = pBar->CalcDockingLayout(bHorz ? rect.Width() : rect.Height(), _GetMode(bHorz, pBar)); nWidth = max(nWidth, bHorz ? sizeBar.cy : sizeBar.cx); } if (lpLayout->hDWP == 0) return nWidth; // Step 4. Move it. for (nPos = 0; nPos < arrInfo.GetSize(); nPos++) { CXTPToolBar* pBar = arrInfo[nPos].pBar; CRect& rect = arrInfo[nPos].rcBar; int nMode = _GetMode(bHorz, pBar) | LM_COMMIT; if (pBar->GetFlags() & xtpFlagStretchedShared) { if (bHorz) { rect.right = nPos == arrInfo.GetSize() - 1 ? nLength : arrInfo[nPos + 1].rcBar.left; rect.left = nPos == 0 ? 0 : min(arrInfo[nPos - 1].rcBar.right, rect.left); } else { rect.bottom = nPos == arrInfo.GetSize() - 1 ? nLength : arrInfo[nPos + 1].rcBar.top; rect.top = nPos == 0 ? 0 : min(arrInfo[nPos - 1].rcBar.bottom, rect.top); } nMode |= LM_STRETCH; } CSize sz = pBar->CalcDockingLayout(bHorz ? rect.Width() : rect.Height(), nMode, nWidth); rect = CRect(rect.TopLeft(), sz); pBar->m_pDockContext->m_uMRUDockPosition = GetPosition(); CXTPWindowRect rectOld(pBar); ScreenToClient(&rectOld); if (!::EqualRect(rectOld, rect)) { AfxRepositionWindow(lpLayout, pBar->m_hWnd, &rect); pBar->Redraw(); } } return nWidth; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // Initialize the command bars if (!InitCommandBars()) return -1; // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; // fail to create } // Add the menu bar CXTPCommandBar* pMenuBar = pCommandBars->SetMenu( _T("Menu Bar"), IDR_MAINFRAME); if(pMenuBar == NULL) { TRACE0("Failed to create menu bar.\n"); return -1; // fail to create } // Create ToolBar CXTPToolBar* pToolBar = (CXTPToolBar*) pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; } // Set Windows XP Theme CXTPPaintManager::SetTheme(xtpThemeNativeWinXP); // Hide array of commands pCommandBars->HideCommands(uHideCmds, _countof(uHideCmds)); // Set "Always Show Full Menus" option to the FALSE pCommandBars->GetCommandBarsOptions()->bAlwaysShowFullMenus = FALSE; pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME); // Load the previous state for toolbars and menus. LoadCommandBars(_T("CommandBars")); // Initialize the docking pane manager and set the // initial them for the docking panes. Do this only after all // control bars objects have been created and docked. m_paneManager.InstallDockingPanes(this); // Set Windows XP Theme m_paneManager.SetTheme(xtpPaneThemeWinNative); // Create docking panes. CXTPDockingPane* pwndPane1 = m_paneManager.CreatePane( IDR_PANE_OPTIONS, CRect(0, 0,200, 120), xtpPaneDockLeft); CXTPDockingPane* pwndPane2 = m_paneManager.CreatePane( IDR_PANE_PROPERTIES, CRect(0, 0,200, 120), xtpPaneDockBottom, pwndPane1); // Set the icons for the docking pane tabs. int nIDIcons[] = {IDR_PANE_OPTIONS, IDR_PANE_PROPERTIES}; m_paneManager.SetIcons(IDB_BITMAP_ICONS, nIDIcons, _countof(nIDIcons), RGB(0, 255, 0)); // Load the previous state for docking panes. CXTPDockingPaneLayout layoutNormal(&m_paneManager); if (layoutNormal.Load(_T("NormalLayout"))) { m_paneManager.SetLayout(&layoutNormal); } return 0; }