![]() |
Office 2010 frame caption buttons |
Post Reply ![]() |
Author | |
Fredrik ![]() Senior Member ![]() Joined: 22 June 2005 Status: Offline Points: 235 |
![]() ![]() ![]() ![]() ![]() Posted: 06 March 2012 at 11:44am |
Hi,
How do I get the frame caption buttons look like Office 2010 when the MDI child window is maximized? ![]() Thanks, Fredrik
|
|
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
|
|
![]() |
|
TimurA ![]() Newbie ![]() Joined: 15 March 2012 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() |
Hi,
same problem in blue and silver office 2010 themes. In the black theme, the buttons are seen better, but their appearance is not exactly like in MSOffice 2010. Is there a solution? Regards, Timur
Windows 7, VS 2005, Toolkit Pro 15.0.1 and 15.2.1
|
|
![]() |
|
TimurA ![]() Newbie ![]() Joined: 15 March 2012 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() |
It seems to work for me with a workaround like this.
Derive the ribbonbar and override RefreshSysButtons(). Instead of CControlMDIButton, created in the CXTPMenuBar::RefreshSysButtons(), create your own buttons, which are a mix of CControlMDIButton and CXTPRibbonBarControlCaptionButton. CControlMDIButton is used by Toolkit to draw mdi buttons in menubar, they aren't overridden in CXTPRibbonBar, therefore we are getting the appearance which is not conform to office 2010. CXTPRibbonBarControlCaptionButton is used by Toolkit to draw frame buttons (right images on a false background). The Draw() method of my button combines both drawing methods. The code may be not optimal and not tested well, but I've got the desired appearance in the MDIRibbonSample. @Codejock: is there a better way? CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)pCommandBars->Add(_T("The Ribbon"), xtpBarTop, RUNTIME_CLASS(CHypRibbonBar)); #pragma once class CHypRibbonBar : public CXTPRibbonBar { DECLARE_XTP_COMMANDBAR(CHypRibbonBar) public: CHypRibbonBar(); ~CHypRibbonBar(); virtual void RefreshSysButtons(); protected: void AddSysButtonEx(int nId); }; //______________________________________________________________________________________ #include "stdafx.h" #include "HypRibbonBar.h" //______________________________________________________________________________________ class CHypControlMDIButton : public CXTPControlButton { public: CHypControlMDIButton(CXTPCommandBarsFrameHook* pFrame) { m_pFrame = pFrame; m_dwFlags |= xtpFlagRightAlign | xtpFlagSkipFocus | xtpFlagManualUpdate | xtpFlagNoMovable; } CSize GetSize(CDC* pDC) { CSize sz = __super::GetSize(pDC); int nSize = sz.cy; //return CSize(16, 16); return CSize(nSize, nSize); }; void SetBeginGroup(BOOL /*bBeginGroup*/) { } void Draw(CDC* pDC) { //GetPaintManager()->DrawControlMDIButton(pDC, this); // background of MDIButton GetPaintManager()->DrawControlEntry(pDC, this); // icon of CaptionButton, but without background! ((CXTPRibbonBar*)GetParent())->GetPaintManager()->GetFramePaintManager()-> DrawFrameCaptionButton(pDC, GetRect(), GetStdId(), FALSE/*GetSelected()*/, FALSE/*GetPressed()*/, m_bEnabled && m_pFrame->IsFrameActive()); } void OnExecute() { // we'll use some protected members class _MenuBar : public CXTPMenuBar { friend class CHypControlMDIButton; }; HWND hWndChild = ((_MenuBar*)(CXTPMenuBar*)m_pParent)->GetActiveMdiChildWnd(); ASSERT(hWndChild); UINT nId = GetStdId(); ::PostMessage(hWndChild, WM_SYSCOMMAND, nId, 0); } UINT GetStdId() const { UINT nId = m_nId == XTP_ID_MENUBAR_CLOSE ? SC_CLOSE : m_nId == XTP_ID_MENUBAR_RESTORE ? SC_RESTORE : SC_MINIMIZE; return nId; } protected: CXTPCommandBarsFrameHook* m_pFrame; }; //______________________________________________________________________________________ IMPLEMENT_XTP_COMMANDBAR(CHypRibbonBar, CXTPRibbonBar) //______________________________________________________________________________________ CHypRibbonBar::CHypRibbonBar() { } //______________________________________________________________________________________ CHypRibbonBar::~CHypRibbonBar() { } //______________________________________________________________________________________ void CHypRibbonBar::RefreshSysButtons() { //CXTPMenuBar::RefreshSysButtons(); BOOL bMax = FALSE; HWND hWndActiveChild = GetActiveMdiChildWnd(&bMax); DWORD dwStyle = hWndActiveChild ? GetWindowLong(hWndActiveChild, GWL_STYLE) : 0; CXTPControl* pButton = m_pControls->FindControl(XTP_ID_MENUBAR_SYSMENU); /* if (bMax && (m_dwFlags & xtpFlagAddMDISysPopup)) { HMENU hDocMenuButton = pButton ? ((CControlMDISysMenuPopup*)pButton)->m_hDocMenu : 0; HMENU hDocMenu = ::GetSystemMenu(hWndActiveChild, FALSE); if (hDocMenu && ::IsMenu(hDocMenu)) { if (hDocMenuButton != hDocMenu) { if (pButton) { ((CControlMDISysMenuPopup*)pButton)->SetMDISysMenu(hWndActiveChild, hDocMenu); DelayRedraw(); } else { AddSysButton(new CControlMDISysMenuPopup(hWndActiveChild, hDocMenu), XTP_ID_MENUBAR_SYSMENU, _T(""), 0); } } } else { if (pButton) m_pControls->Remove(pButton); } } else */if (pButton) m_pControls->Remove(pButton); pButton = m_pControls->FindControl(XTP_ID_MENUBAR_MINIMIZE); if (!pButton && bMax && (dwStyle & WS_MINIMIZEBOX) && (dwStyle & WS_SYSMENU) && (!(m_dwFlags & xtpFlagHideMinimizeBox))) //AddSysButton(new CHypControlMDIButton(), XTP_ID_MENUBAR_MINIMIZE, _T("0")); AddSysButtonEx(XTP_ID_MENUBAR_MINIMIZE); else if (pButton && !bMax) m_pControls->Remove(pButton); pButton = m_pControls->FindControl(XTP_ID_MENUBAR_RESTORE); if (!pButton && bMax && (dwStyle & WS_MAXIMIZEBOX) && (dwStyle & WS_SYSMENU) && (!(m_dwFlags & xtpFlagHideMaximizeBox))) //AddSysButton(new CHypControlMDIButton(), XTP_ID_MENUBAR_RESTORE, _T("2")); AddSysButtonEx(XTP_ID_MENUBAR_RESTORE); else if (pButton && !bMax) m_pControls->Remove(pButton); pButton = m_pControls->FindControl(XTP_ID_MENUBAR_CLOSE); if (!pButton && bMax && (dwStyle & WS_SYSMENU) && (!(m_dwFlags & xtpFlagHideClose))) //AddSysButton(new CHypControlMDIButton(), XTP_ID_MENUBAR_CLOSE, _T("r")); AddSysButtonEx(XTP_ID_MENUBAR_CLOSE); else if (pButton && !bMax) m_pControls->Remove(pButton); if (IsFrameThemeEnabled()) { CString strWindowText; GetSite()->GetWindowText(strWindowText); if (strWindowText != m_strCaptionText) DelayLayout(); } } //______________________________________________________________________________________ void CHypRibbonBar::AddSysButtonEx(int nId) { CHypControlMDIButton* pButton = new CHypControlMDIButton(GetFrameHook()); m_pControls->Add(pButton, nId); UINT nStdId = pButton->GetStdId(); // XTP_ID_MENUBAR_CLOSE -> SC_CLOSE CString strCaption; CMenu* pMenu = GetSite()->GetSystemMenu(FALSE); if (pMenu) { pMenu->GetMenuString(nStdId, strCaption, MF_BYCOMMAND); int nIndex = strCaption.Find(_T('\t')); if (nIndex > 0) { strCaption = strCaption.Left(nIndex); } } if (pButton->GetAction()) { pButton->GetAction()->SetCaption(_T("")); pButton->GetAction()->SetDescription(NULL); } pButton->SetDescription(NULL); pButton->SetCaption(_T("")); pButton->SetTooltip(strCaption); } //______________________________________________________________________________________ |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |