From: Kimmo Varis Date: Tue, 8 Mar 2005 16:29:52 +0000 (+0000) Subject: PATCH: [ 1158456 ] Fix setting font for headerbar editcontrols X-Git-Tag: 2.16.5~6140 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=6526756db61f057554cd5b70247d23db579b9382;p=winmerge-jp%2Fwinmerge-jp.git PATCH: [ 1158456 ] Fix setting font for headerbar editcontrols --- diff --git a/Src/EditorFilepathBar.cpp b/Src/EditorFilepathBar.cpp index 00863f66f..87591a7d5 100644 --- a/Src/EditorFilepathBar.cpp +++ b/Src/EditorFilepathBar.cpp @@ -35,6 +35,17 @@ static char THIS_FILE[] = __FILE__; ///////////////////////////////////////////////////////////////////////////// // CEditorFilePathBar construction destruction +CEditorFilePathBar::CEditorFilePathBar() +: m_pFont(NULL) +{ +} + +CEditorFilePathBar::~CEditorFilePathBar() +{ + delete m_pFont; +} + + BOOL CEditorFilePathBar::Create(CWnd* pParentWnd) { if (! CDialogBar::Create(pParentWnd, CEditorFilePathBar::IDD, @@ -53,16 +64,37 @@ BOOL CEditorFilePathBar::Create(CWnd* pParentWnd) ///////////////////////////////////////////////////////////////////////////// - - -// return TRUE if parent must recompute layout -BOOL CEditorFilePathBar::LookLikeThisWnd(CWnd * pWnd) +/** + * @brief Set look of headerbars similar to other window. + * + * @param [in] pWnd Pointer to window we want to imitate + * @return TRUE if parent must recompute layout + */ +BOOL CEditorFilePathBar::LookLikeThisWnd(const CWnd * pWnd) { - // same font + // Update font. Note that we must delete previous font + // before creating a new one. CFont * pFont = pWnd->GetFont(); - m_EditLeft.SetFont(pFont); - m_EditRight.SetFont(pFont); - // and same dimensions + if (pFont) + { + if (m_pFont != NULL) + delete m_pFont; + + m_pFont = new CFont(); + + if (m_pFont != NULL) + { + LOGFONT lfFont = {0}; + if (pFont->GetLogFont(&lfFont)) + { + m_pFont->CreateFontIndirect(&lfFont); + m_EditLeft.SetFont(m_pFont); + m_EditRight.SetFont(m_pFont); + } + } + } + + // Set same dimensions (than window we imitate) CRect rectNew; pWnd->GetWindowRect(rectNew); CRect rectCurrent; diff --git a/Src/EditorFilepathBar.h b/Src/EditorFilepathBar.h index 87275c22c..d6428325d 100644 --- a/Src/EditorFilepathBar.h +++ b/Src/EditorFilepathBar.h @@ -48,12 +48,15 @@ public: class CEditorFilePathBar : public CDialogBar, public IHeaderBar { public : + CEditorFilePathBar(); + ~CEditorFilePathBar(); + BOOL Create( CWnd* pParentWnd); // Dialog Data enum { IDD = IDD_EDITOR_HEADERBAR }; - BOOL LookLikeThisWnd(CWnd * pWnd); + BOOL LookLikeThisWnd(const CWnd * pWnd); void Resize(); void Resize(int leftWidth, int rightWidth); @@ -68,6 +71,7 @@ protected: private: // this dialog uses custom edit boxes CFilepathEdit m_EditLeft, m_EditRight; + CFont * m_pFont; /**< Font for editcontrols */ }; diff --git a/Src/readme.txt b/Src/readme.txt index 1832118ab..6413538d2 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -1,3 +1,7 @@ +2005-03-08 Kimmo + PATCH: [ 1158456 ] Fix setting font for headerbar editcontrols + Src: EditorFilepathBar.cpp EditorFilepathBar.h + 2005-03-07 Perry PATCH: [ 1157859 ] Add LVS_SHOWSELALWAYS style to dirview Postlude: Alter WindowStyle_Add to call CWnd::ModifyStyle.