From 5037e764c81fcef249356f3d7b83ce91c85f0c4d Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 18 Aug 2005 19:52:48 +0000 Subject: [PATCH] PATCH: [ 1262428 ] Fix toolbar problems with XP theming --- Src/Common/ToolBarXPThemes.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++ Src/Common/ToolbarXPThemes.h | 45 ++++++++++++++++++++ Src/MainFrm.h | 3 +- Src/Merge.dsp | 8 ++++ Src/readme.txt | 3 ++ 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 Src/Common/ToolBarXPThemes.cpp create mode 100644 Src/Common/ToolbarXPThemes.h diff --git a/Src/Common/ToolBarXPThemes.cpp b/Src/Common/ToolBarXPThemes.cpp new file mode 100644 index 000000000..84bae420f --- /dev/null +++ b/Src/Common/ToolBarXPThemes.cpp @@ -0,0 +1,94 @@ +/** + * @file ToolBarXPThemes.cpp + * + * @brief Implementation of the ToolBarXPThemes class + */ +// RCS ID line follows -- this is updated by CVS +// $Id$ + +#include "stdafx.h" +#include "ToolBarXPThemes.h" + +BEGIN_MESSAGE_MAP(ToolBarXPThemes, CToolBar) + //{{AFX_MSG_MAP(ToolBarXPThemes) + ON_WM_NCPAINT() + ON_WM_RBUTTONUP() + ON_WM_RBUTTONDOWN() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +/** + * @brief Called when non-client area is to be drawn. + */ +void ToolBarXPThemes::OnNcPaint() +{ + EraseNonClient(); +} + +/** + * @brief Toolbar Erase non-client area and draw gripper. + */ +void ToolBarXPThemes::EraseNonClient() +{ + + // Get window DC that is clipped to the non-client area. + CWindowDC dc(this); + CRect rectClient; + GetClientRect(rectClient); + CRect rectWindow; + GetWindowRect(rectWindow); + ScreenToClient(rectWindow); + rectClient.OffsetRect(-rectWindow.left, -rectWindow.top); + dc.ExcludeClipRect(rectClient); + + // Draw the borders in the non-client area. + rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top); + DrawBorders(&dc, rectWindow); + + // Erase the parts that are not drawn. + dc.IntersectClipRect(rectWindow); + SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC); + + // Draw the gripper in the non-client area. + DrawGripper(&dc, rectWindow); +} + +/** + * @brief Toolbar paint function. + */ +void ToolBarXPThemes::DoPaint(CDC* pDC) +{ + ASSERT_VALID(this); + ASSERT_VALID(pDC); + + // Paint inside the client area. + CRect rect; + GetClientRect(rect); + DrawBorders(pDC, rect); + DrawGripper(pDC, rect); +} + +/** + * @brief Draws gripper. + */ +void ToolBarXPThemes::DrawGripper(CDC* pDC, const CRect& rect) +{ + pDC->FillSolidRect( &rect, ::GetSysColor(COLOR_BTNFACE)); // Fill in the background. + CToolBar::DrawGripper(pDC,rect); +} + +/** + * @brief Dismiss right-mousebutton-up event. + */ +void ToolBarXPThemes::OnRButtonUp(UINT nFlags, CPoint point) +{ + // Empty: just dismiss righ-mouseclick for toolbar +} + +/** + * @brief Dismiss right-mousebutton-up event. + */ +void ToolBarXPThemes::OnRButtonDown(UINT nFlags, CPoint point) +{ + // Empty: just dismiss righ-mouseclick for toolbar +} diff --git a/Src/Common/ToolbarXPThemes.h b/Src/Common/ToolbarXPThemes.h new file mode 100644 index 000000000..b0bc927a6 --- /dev/null +++ b/Src/Common/ToolbarXPThemes.h @@ -0,0 +1,45 @@ +/** + * @file ToolBarXPThemes.h + * + * @brief Declaration file for ToolBarXPThemes + * + */ +// RCS ID line follows -- this is updated by CVS +// $Id$ + +#ifndef _TOOLBAR_XPTHEMES_H_ +#define _TOOLBAR_XPTHEMES_H_ + +/** + * @brief Toolbar class supporting XP themes. + * + * When XP themes are enabled using manifest files there seems to be + * two problems: + * - toolbar grippers don't get drawn correctly + * - if both mousebuttons are clicked simultanously, application hangs + * This toolbar class overrides toolbar drawing to fix drawing issue. + * Also overrides right-mousebutton up- and down-events with empty functions + * so they don't get delivered to actual toolbar class. + * + * Drawing issue is described in MSDN KB article 843490: + * http://support.microsoft.com/default.aspx?scid=kb;en-us;843490 + */ +class ToolBarXPThemes : public CToolBar +{ +public: + void DrawGripper(CDC* pDC, const CRect& rect); + void EraseNonClient(); + virtual void DoPaint(CDC* pDC); + +protected: + + //{{AFX_MSG(ToolBarXPThemes) + afx_msg void OnNcPaint(); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +#endif // _TOOLBAR_XPTHEMES_H_ diff --git a/Src/MainFrm.h b/Src/MainFrm.h index 8f1c64829..248cf414a 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -29,6 +29,7 @@ #if !defined(AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_) #define AFX_MAINFRM_H__BBCD4F8C_34E4_11D1_BAA6_00A024706EDC__INCLUDED_ +#include "ToolBarXPThemes.h" #include "OptionsMgr.h" #include "VSSHelper.h" @@ -176,7 +177,7 @@ public: protected: // control bar embedded members CStatusBar m_wndStatusBar; - CToolBar m_wndToolBar; + ToolBarXPThemes m_wndToolBar; enum { diff --git a/Src/Merge.dsp b/Src/Merge.dsp index 6cb16cf4a..8f1317e31 100644 --- a/Src/Merge.dsp +++ b/Src/Merge.dsp @@ -800,6 +800,10 @@ SOURCE=.\Common\textfile.cpp # End Source File # Begin Source File +SOURCE=.\Common\ToolBarXPThemes.cpp +# End Source File +# Begin Source File + SOURCE=.\Common\unicoder.cpp # End Source File # Begin Source File @@ -1301,6 +1305,10 @@ SOURCE=.\Common\textfile.h # End Source File # Begin Source File +SOURCE=.\Common\ToolbarXPThemes.h +# End Source File +# Begin Source File + SOURCE=.\Common\unicoder.h # End Source File # Begin Source File diff --git a/Src/readme.txt b/Src/readme.txt index 399166279..e4d7adf43 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -2,6 +2,9 @@ PATCH: [ 1261220 ] Add Compare item for dirview menus Src: DirActions.cpp DirView.cpp DirView.h Merge.rc resource.h Src/Languages: *.rc resource.h + PATCH: [ 1262428 ] Fix toolbar problems with XP theming + Src: MainFrm.cpp Merge.dsp + Src/Common new files: ToolBarXPThemes.cpp ToolBarXPThemes.h 2005-08-17 Kimmo PATCH: [ 1260244 ] Initialization of non-existing struct-members in editor -- 2.11.0