OSDN Git Service

Add MergeFrameCommon.*
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Wed, 5 Jun 2019 15:46:56 +0000 (00:46 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Wed, 5 Jun 2019 15:46:56 +0000 (00:46 +0900)
16 files changed:
Src/DirFrame.cpp
Src/DirFrame.h
Src/HexMergeFrm.cpp
Src/HexMergeFrm.h
Src/ImgMergeFrm.cpp
Src/ImgMergeFrm.h
Src/Merge.vs2017.vcxproj
Src/Merge.vs2017.vcxproj.filters
Src/Merge.vs2019.vcxproj
Src/Merge.vs2019.vcxproj.filters
Src/MergeEditFrm.cpp
Src/MergeEditFrm.h
Src/MergeFrameCommon.cpp [new file with mode: 0644]
Src/MergeFrameCommon.h [new file with mode: 0644]
Src/OpenFrm.cpp
Src/OpenFrm.h

index 005d56d..747b589 100644 (file)
@@ -77,11 +77,10 @@ static UINT RO_PANEL_WIDTH = 30;
 /////////////////////////////////////////////////////////////////////////////
 // CDirFrame
 
-IMPLEMENT_DYNCREATE(CDirFrame, CMDIChildWnd)
+IMPLEMENT_DYNCREATE(CDirFrame, CMergeFrameCommon)
 
 CDirFrame::CDirFrame()
-: m_hIdentical(nullptr)
-, m_hDifferent(nullptr)
+: CMergeFrameCommon(IDI_EQUALFOLDER, IDI_NOTEQUALFOLDER)
 {
 }
 
@@ -90,13 +89,12 @@ CDirFrame::~CDirFrame()
 }
 
 
-BEGIN_MESSAGE_MAP(CDirFrame, CMDIChildWnd)
+BEGIN_MESSAGE_MAP(CDirFrame, CMergeFrameCommon)
        //{{AFX_MSG_MAP(CDirFrame)
        ON_WM_CREATE()
        ON_WM_CLOSE()
        ON_WM_SIZE()
        ON_WM_MDIACTIVATE()
-       ON_WM_GETMINMAXINFO()
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -142,9 +140,6 @@ int CDirFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        m_wndStatusBar.SetPaneText(PANE_MIDDLE_RO, sText.c_str(), TRUE); 
        m_wndStatusBar.SetPaneText(PANE_RIGHT_RO, sText.c_str(), TRUE);
 
-       m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALFOLDER);
-       m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALFOLDER);
-
        return 0;
 }
 
@@ -190,18 +185,7 @@ void CDirFrame::ActivateFrame(int nCmdShow)
        CDockState dockState;
        dockState.LoadState(_T("Settings-DirFrame"));
        SetDockState(dockState);
-       // get the active child frame, and a flag whether it is maximized
-       BOOL bMaximized = FALSE;
-       CMDIChildWnd * oldActiveFrame = GetMDIFrame()->MDIGetActive(&bMaximized);
-       if (oldActiveFrame == nullptr)
-               // for the first frame, get the restored/maximized state from the registry
-               bMaximized = GetOptionsMgr()->GetBool(OPT_ACTIVE_FRAME_MAX);
-       if (bMaximized)
-               nCmdShow = SW_SHOWMAXIMIZED;
-       else
-               nCmdShow = SW_SHOWNORMAL;
-
-       CMDIChildWnd::ActivateFrame(nCmdShow);
+       CMergeFrameCommon::ActivateFrame(nCmdShow);
 }
 
 /**
@@ -211,34 +195,6 @@ void CDirFrame::UpdateResources()
 {
 }
 
-/**
-* @brief Reflect comparison result in window's icon.
-* @param nResult [in] Last comparison result which the application returns.
-*/
-void CDirFrame::SetLastCompareResult(int nResult)
-{
-       HICON hCurrent = GetIcon(FALSE);
-       HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
-
-       if (hCurrent != hReplace)
-       {
-               SetIcon(hReplace, TRUE);
-
-               BOOL bMaximized;
-               GetMDIFrame()->MDIGetActive(&bMaximized);
-
-               // When MDI maximized the window icon is drawn on the menu bar, so we
-               // need to notify it that our icon has changed.
-               if (bMaximized)
-               {
-                       GetMDIFrame()->DrawMenuBar();
-               }
-               GetMDIFrame()->OnUpdateFrameTitle(FALSE);
-       }
-
-       theApp.SetLastCompareResult(nResult);
-}
-
 void CDirFrame::OnClose() 
 {      
        CMDIChildWnd::OnClose();
@@ -249,20 +205,11 @@ void CDirFrame::OnClose()
  */
 BOOL CDirFrame::DestroyWindow() 
 {
-       // If we are active, save the restored/maximized state
-       // If we are not, do nothing and let the active frame do the job.
-       if (this->GetParentFrame()->GetActiveFrame() == (CFrameWnd*)this)
-       {
-               WINDOWPLACEMENT wp;
-               wp.length = sizeof(WINDOWPLACEMENT);
-               GetWindowPlacement(&wp);
-               GetOptionsMgr()->SaveOption(OPT_ACTIVE_FRAME_MAX, (wp.showCmd == SW_MAXIMIZE));
-               // save docking positions and sizes
-               CDockState dockState;
-               GetDockState(dockState);
-               dockState.SaveState(_T("Settings-DirFrame"));
-       }
-
+       // save docking positions and sizes
+       CDockState dockState;
+       GetDockState(dockState);
+       dockState.SaveState(_T("Settings-DirFrame"));
+       SaveWindowState();
        return CMDIChildWnd::DestroyWindow();
 }
 
@@ -273,13 +220,3 @@ void CDirFrame::OnSize(UINT nType, int cx, int cy)
        m_wndFilePathBar.Resize();
 }
 
-void CDirFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
-{
-       CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
-       // [Fix for MFC 8.0 MDI Maximizing Child Window bug on Vista]
-       // https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/iajCdW5DzTM
-#if _MFC_VER >= 0x0800
-       lpMMI->ptMaxTrackSize.x = max(lpMMI->ptMaxTrackSize.x, lpMMI->ptMaxSize.x);
-       lpMMI->ptMaxTrackSize.y = max(lpMMI->ptMaxTrackSize.y, lpMMI->ptMaxSize.y);
-#endif
-}
index 3e43fd8..4168e99 100644 (file)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "EditorFilepathBar.h"
+#include "MergeFrameCommon.h"
 
 /////////////////////////////////////////////////////////////////////////////
 // CDirFrame frame
@@ -33,7 +34,7 @@
 /**
  * @brief Frame window for Directory Compare window
  */
-class CDirFrame : public CMDIChildWnd
+class CDirFrame : public CMergeFrameCommon
 {
        DECLARE_DYNCREATE(CDirFrame)
 protected:
@@ -43,8 +44,6 @@ protected:
 public:
 
 private:
-       HICON m_hIdentical;
-       HICON m_hDifferent;
 
 // Operations
 public:
@@ -54,8 +53,6 @@ public:
        CStatusBar  m_wndStatusBar;
        IHeaderBar * GetHeaderInterface();
        void UpdateResources();
-       void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
-       void SetLastCompareResult(int nResult);
 
 // Overrides
        // ClassWizard generated virtual function overrides
@@ -74,7 +71,6 @@ protected:
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        afx_msg void OnClose();
        afx_msg void OnSize(UINT nType, int cx, int cy);
-       afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
index 69502bf..851496d 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
 // CHexMergeFrame
 
-IMPLEMENT_DYNCREATE(CHexMergeFrame, CMDIChildWnd)
+IMPLEMENT_DYNCREATE(CHexMergeFrame, CMergeFrameCommon)
 
-BEGIN_MESSAGE_MAP(CHexMergeFrame, CMDIChildWnd)
+BEGIN_MESSAGE_MAP(CHexMergeFrame, CMergeFrameCommon)
        //{{AFX_MSG_MAP(CHexMergeFrame)
        ON_WM_CREATE()
        ON_WM_CLOSE()
        ON_WM_SIZE()
-       ON_WM_GETMINMAXINFO()
        ON_MESSAGE_VOID(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
        ON_UPDATE_COMMAND_UI(ID_VIEW_DETAIL_BAR, OnUpdateControlBarMenu)
        ON_COMMAND_EX(ID_VIEW_DETAIL_BAR, OnBarCheck)
@@ -74,10 +73,8 @@ enum
 // CHexMergeFrame construction/destruction
 
 CHexMergeFrame::CHexMergeFrame()
-: m_hIdentical(nullptr)
-, m_hDifferent(nullptr)
+       : CMergeFrameCommon(IDI_EQUALBINARY, IDI_BINARYDIFF)
 {
-       std::fill_n(m_nLastSplitPos, 2, 0);
        m_pMergeDoc = 0;
 }
 
@@ -155,9 +152,6 @@ BOOL CHexMergeFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
        CSize size = m_wndStatusBar[0].CalcFixedLayout(TRUE, TRUE);
        m_rectBorder.bottom = size.cy;
 
-       m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALBINARY);
-       m_hDifferent = AfxGetApp()->LoadIcon(IDI_BINARYDIFF);
-
        // get the IHexEditorWindow interfaces
        IHexEditorWindow *pif[3];
        for (nPane = 0; nPane < m_pMergeDoc->m_nBuffers; nPane++)
@@ -196,11 +190,7 @@ BOOL CHexMergeFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
 
 void CHexMergeFrame::ActivateFrame(int nCmdShow) 
 {
-       if (!GetMDIFrame()->MDIGetActive() && GetOptionsMgr()->GetBool(OPT_ACTIVE_FRAME_MAX))
-       {
-               nCmdShow = SW_SHOWMAXIMIZED;
-       }
-       CMDIChildWnd::ActivateFrame(nCmdShow);
+       CMergeFrameCommon::ActivateFrame(nCmdShow);
 }
 
 /**
@@ -209,16 +199,7 @@ void CHexMergeFrame::ActivateFrame(int nCmdShow)
 BOOL CHexMergeFrame::DestroyWindow() 
 {
        SavePosition();
-       // If we are active, save the restored/maximized state
-       // If we are not, do nothing and let the active frame do the job.
-       if (GetParentFrame()->GetActiveFrame() == this)
-       {
-               WINDOWPLACEMENT wp;
-               wp.length = sizeof(WINDOWPLACEMENT);
-               GetWindowPlacement(&wp);
-               GetOptionsMgr()->SaveOption(OPT_ACTIVE_FRAME_MAX, (wp.showCmd == SW_MAXIMIZE));
-       }
-
+       SaveWindowState();
        return CMDIChildWnd::DestroyWindow();
 }
 
@@ -232,9 +213,6 @@ void CHexMergeFrame::SavePosition()
 {
        if (CWnd *pLeft = m_wndSplitter.GetPane(0,0))
        {
-               CRect rc;
-               pLeft->GetWindowRect(&rc);
-               theApp.WriteProfileInt(_T("Settings"), _T("WLeft"), rc.Width());
                GetOptionsMgr()->SaveOption(OPT_ACTIVE_PANE, GetActivePane());
        }
 }
@@ -255,17 +233,6 @@ void CHexMergeFrame::OnSize(UINT nType, int cx, int cy)
        UpdateHeaderSizes();
 }
 
-void CHexMergeFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
-{
-       CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
-       // [Fix for MFC 8.0 MDI Maximizing Child Window bug on Vista]
-       // https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/iajCdW5DzTM
-#if _MFC_VER >= 0x0800
-       lpMMI->ptMaxTrackSize.x = max(lpMMI->ptMaxTrackSize.x, lpMMI->ptMaxSize.x);
-       lpMMI->ptMaxTrackSize.y = max(lpMMI->ptMaxTrackSize.y, lpMMI->ptMaxSize.y);
-#endif
-}
-
 /// update splitting position for panels 1/2 and headerbar and statusbar 
 void CHexMergeFrame::UpdateHeaderSizes()
 {
@@ -308,33 +275,6 @@ IHeaderBar *CHexMergeFrame::GetHeaderInterface()
        return &m_wndFilePathBar;
 }
 
-/**
- * @brief Reflect comparison result in window's icon.
- * @param nResult [in] Last comparison result which the application returns.
- */
-void CHexMergeFrame::SetLastCompareResult(int nResult)
-{
-       HICON hCurrent = GetIcon(FALSE);
-       HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
-
-       if (hCurrent != hReplace)
-       {
-               SetIcon(hReplace, TRUE);
-
-               BOOL bMaximized;
-               GetMDIFrame()->MDIGetActive(&bMaximized);
-
-               // When MDI maximized the window icon is drawn on the menu bar, so we
-               // need to notify it that our icon has changed.
-               if (bMaximized)
-               {
-                       GetMDIFrame()->DrawMenuBar();
-               }
-               GetMDIFrame()->OnUpdateFrameTitle(FALSE);
-       }
-
-       theApp.SetLastCompareResult(nResult);
-}
 
 void CHexMergeFrame::UpdateAutoPaneResize()
 {
index d59460a..7b02e76 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "SplitterWndEx.h"
 #include "EditorFilepathBar.h"
+#include "MergeFrameCommon.h"
 
 #define HEKSEDIT_INTERFACE_VERSION 2
 #include "heksedit.h"
@@ -36,7 +37,7 @@ class CHexMergeDoc;
 /** 
  * @brief Frame class for file compare, handles panes, statusbar etc.
  */
-class CHexMergeFrame : public CMDIChildWnd
+class CHexMergeFrame : public CMergeFrameCommon
 {
        DECLARE_DYNCREATE(CHexMergeFrame)
 public:
@@ -47,9 +48,7 @@ public:
        void UpdateResources();
        void CloseNow();
        IHeaderBar * GetHeaderInterface();
-       void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
        CHexMergeDoc * GetMergeDoc() { return m_pMergeDoc; }
-       void SetLastCompareResult(int nResult);
 
        void UpdateAutoPaneResize();
        void UpdateSplitter();
@@ -79,18 +78,14 @@ private:
        void CreateHexWndStatusBar(CStatusBar &, CWnd *);
 // Generated message map functions
 private:
-       int m_nLastSplitPos[2];
        void UpdateHeaderSizes();
        CHexMergeDoc * m_pMergeDoc;
-       HICON m_hIdentical;
-       HICON m_hDifferent;
 
        //{{AFX_MSG(CHexMergeFrame)
        afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnIdleUpdateCmdUI();
        afx_msg LRESULT OnStorePaneSizes(WPARAM wParam, LPARAM lParam);
-       afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
index c2c310c..770399a 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
 // CImgMergeFrame
 
-IMPLEMENT_DYNCREATE(CImgMergeFrame, CMDIChildWnd)
+IMPLEMENT_DYNCREATE(CImgMergeFrame, CMergeFrameCommon)
 
-BEGIN_MESSAGE_MAP(CImgMergeFrame, CMDIChildWnd)
+BEGIN_MESSAGE_MAP(CImgMergeFrame, CMergeFrameCommon)
        //{{AFX_MSG_MAP(CImgMergeFrame)
        ON_WM_CREATE()
        ON_WM_CLOSE()
        ON_WM_MDIACTIVATE()
        ON_WM_SIZE()
-       ON_WM_GETMINMAXINFO()
        ON_COMMAND(ID_FILE_SAVE, OnFileSave)
        ON_UPDATE_COMMAND_UI(ID_VIEW_LOCATION_BAR, OnUpdateControlBarMenu)
        ON_COMMAND_EX(ID_VIEW_LOCATION_BAR, OnBarCheck)
@@ -158,14 +157,12 @@ CMenu CImgMergeFrame::menu;
 // CImgMergeFrame construction/destruction
 
 CImgMergeFrame::CImgMergeFrame()
-: m_hIdentical(nullptr)
-, m_hDifferent(nullptr)
+: CMergeFrameCommon(IDI_EQUALIMAGE, IDI_NOTEQUALIMAGE)
 , m_pDirDoc(nullptr)
 , m_bAutoMerged(false)
 , m_pImgMergeWindow(nullptr)
 , m_pImgToolWindow(nullptr)
 {
-       std::fill_n(m_nLastSplitPos, 2, 0);
        std::fill_n(m_nBufferType, 3, BUFFER_NORMAL);
        std::fill_n(m_bRO, 3, false);
 }
@@ -516,9 +513,6 @@ int CImgMergeFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        CSize size = m_wndStatusBar[0].CalcFixedLayout(TRUE, TRUE);
        m_rectBorder.bottom = size.cy;
 
-       m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALIMAGE);
-       m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALIMAGE);
-
        return 0;
 }
 
@@ -561,16 +555,7 @@ BOOL CImgMergeFrame::DestroyWindow()
 {
        SavePosition();
        SaveOptions();
-       // If we are active, save the restored/maximized state
-       // If we are not, do nothing and let the active frame do the job.
-       if (GetParentFrame()->GetActiveFrame() == this)
-       {
-               WINDOWPLACEMENT wp;
-               wp.length = sizeof(WINDOWPLACEMENT);
-               GetWindowPlacement(&wp);
-               GetOptionsMgr()->SaveOption(OPT_ACTIVE_FRAME_MAX, (wp.showCmd == SW_MAXIMIZE));
-       }
-
+       SaveWindowState();
        return CMDIChildWnd::DestroyWindow();
 }
 
@@ -1032,34 +1017,6 @@ void CImgMergeFrame::SetTitle(LPCTSTR lpszTitle)
                SetWindowText(sTitle.c_str());
 }
 
-/**
- * @brief Reflect comparison result in window's icon.
- * @param nResult [in] Last comparison result which the application returns.
- */
-void CImgMergeFrame::SetLastCompareResult(int nResult)
-{
-       HICON hCurrent = GetIcon(FALSE);
-       HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
-
-       if (hCurrent != hReplace)
-       {
-               SetIcon(hReplace, TRUE);
-
-               BOOL bMaximized;
-               GetMDIFrame()->MDIGetActive(&bMaximized);
-
-               // When MDI maximized the window icon is drawn on the menu bar, so we
-               // need to notify it that our icon has changed.
-               if (bMaximized)
-               {
-                       GetMDIFrame()->DrawMenuBar();
-               }
-               GetMDIFrame()->OnUpdateFrameTitle(FALSE);
-       }
-
-       theApp.SetLastCompareResult(nResult);
-}
-
 void CImgMergeFrame::UpdateLastCompareResult()
 {
        SetLastCompareResult(m_pImgMergeWindow->GetDiffCount() > 0 ? 1 : 0);
@@ -1305,17 +1262,6 @@ void CImgMergeFrame::OnSize(UINT nType, int cx, int cy)
        UpdateHeaderSizes();
 }
 
-void CImgMergeFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
-{
-       CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
-       // [Fix for MFC 8.0 MDI Maximizing Child Window bug on Vista]
-       // https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/iajCdW5DzTM
-#if _MFC_VER >= 0x0800
-       lpMMI->ptMaxTrackSize.x = max(lpMMI->ptMaxTrackSize.x, lpMMI->ptMaxSize.x);
-       lpMMI->ptMaxTrackSize.y = max(lpMMI->ptMaxTrackSize.y, lpMMI->ptMaxSize.y);
-#endif
-}
-
 /**
  * @brief Synchronize control and status bar placements with splitter position,
  * update mod indicators, synchronize scrollbars
index 71d028e..98c2c3e 100644 (file)
 #include "WinIMergeLib.h"
 #include "LocationBar.h"
 #include "FileLocation.h"
+#include "MergeFrameCommon.h"
 
 class CDirDoc;
 
 /** 
  * @brief Frame class for file compare, handles panes, statusbar etc.
  */
-class CImgMergeFrame : public CMDIChildWnd, public IMergeDoc
+class CImgMergeFrame : public IMergeDoc, public CMergeFrameCommon
 {
        private:
        enum BUFFERTYPE
@@ -65,8 +66,6 @@ public:
        void UpdateResources();
        bool CloseNow();
        void DirDocClosing(CDirDoc * pDirDoc) { m_pDirDoc = nullptr; }
-       void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
-       void SetLastCompareResult(int nResult);
        void UpdateLastCompareResult();
        void UpdateAutoPaneResize();
        void UpdateSplitter();
@@ -116,9 +115,6 @@ private:
        bool MergeModeKeyDown(MSG* pMsg);
        static void OnChildPaneEvent(const IImgMergeWindow::Event& evt);
        void OnDropFiles(int pane, const std::vector<String>& files);
-       int m_nLastSplitPos[2];
-       HICON m_hIdentical;
-       HICON m_hDifferent;
        CLocationBar m_wndLocationBar;
        IImgMergeWindow *m_pImgMergeWindow;
        IImgToolWindow *m_pImgToolWindow;
@@ -133,7 +129,6 @@ private:
        //{{AFX_MSG(CImgMergeFrame)
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
-       afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
        afx_msg void OnClose();
        afx_msg void OnFileSave();
        afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI);
index 7e96ec1..0d9d8b9 100644 (file)
     <ClCompile Include="charsets.c">\r
       <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
+    <ClCompile Include="MergeFrameCommon.cpp" />\r
     <ClCompile Include="MergeEditFrm.cpp" />\r
     <ClCompile Include="Common\ClipBoard.cpp">\r
       <PrecompiledHeader>Use</PrecompiledHeader>\r
     <ClInclude Include="Common\BCMenu.h" />\r
     <ClInclude Include="Common\Bitmap.h" />\r
     <ClInclude Include="charsets.h" />\r
+    <ClInclude Include="MergeFrameCommon.h" />\r
     <ClInclude Include="MergeEditFrm.h" />\r
     <ClInclude Include="Common\ClipBoard.h" />\r
     <ClInclude Include="Common\CMoveConstraint.h" />\r
index 7e3f7da..9b10184 100644 (file)
     <ClCompile Include="xdiff_gnudiff_compat.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="MergeFrameCommon.cpp">\r
+      <Filter>MFCGui\Source Files</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="charsets.h">\r
     <ClInclude Include="xdiff_gnudiff_compat.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="MergeFrameCommon.h">\r
+      <Filter>MFCGui\Header Files</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="res\binarydiff.ico">\r
index c7e81b5..2280a69 100644 (file)
     <ClCompile Include="charsets.c">\r
       <PrecompiledHeader>NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
+    <ClCompile Include="MergeFrameCommon.cpp" />\r
     <ClCompile Include="MergeEditFrm.cpp" />\r
     <ClCompile Include="Common\ClipBoard.cpp">\r
       <PrecompiledHeader>Use</PrecompiledHeader>\r
     <ClInclude Include="Common\BCMenu.h" />\r
     <ClInclude Include="Common\Bitmap.h" />\r
     <ClInclude Include="charsets.h" />\r
+    <ClInclude Include="MergeFrameCommon.h" />\r
     <ClInclude Include="MergeEditFrm.h" />\r
     <ClInclude Include="Common\ClipBoard.h" />\r
     <ClInclude Include="Common\CMoveConstraint.h" />\r
index 7e3f7da..9b10184 100644 (file)
     <ClCompile Include="xdiff_gnudiff_compat.cpp">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="MergeFrameCommon.cpp">\r
+      <Filter>MFCGui\Source Files</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="charsets.h">\r
     <ClInclude Include="xdiff_gnudiff_compat.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="MergeFrameCommon.h">\r
+      <Filter>MFCGui\Header Files</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="res\binarydiff.ico">\r
index 2280bd6..7c6c696 100644 (file)
 /////////////////////////////////////////////////////////////////////////////
 // CMergeEditFrame
 
-IMPLEMENT_DYNCREATE(CMergeEditFrame, CMDIChildWnd)
+IMPLEMENT_DYNCREATE(CMergeEditFrame, CMergeFrameCommon)
 
-BEGIN_MESSAGE_MAP(CMergeEditFrame, CMDIChildWnd)
+BEGIN_MESSAGE_MAP(CMergeEditFrame, CMergeFrameCommon)
        //{{AFX_MSG_MAP(CMergeEditFrame)
        ON_WM_CREATE()
        ON_WM_CLOSE()
        ON_WM_MDIACTIVATE()
        ON_WM_TIMER()
-       ON_WM_GETMINMAXINFO()
        ON_UPDATE_COMMAND_UI(ID_VIEW_DETAIL_BAR, OnUpdateControlBarMenu)
        ON_COMMAND_EX(ID_VIEW_DETAIL_BAR, OnBarCheck)
        ON_UPDATE_COMMAND_UI(ID_VIEW_LOCATION_BAR, OnUpdateControlBarMenu)
@@ -75,11 +74,8 @@ END_MESSAGE_MAP()
  * @brief Constructor.
  */
 CMergeEditFrame::CMergeEditFrame()
-: m_hIdentical(nullptr)
-, m_hDifferent(nullptr)
+: CMergeFrameCommon(IDI_EQUALTEXTFILE, IDI_NOTEQUALTEXTFILE)
 {
-       m_bActivated = false;
-       std::fill_n(m_nLastSplitPos, 2, 0);
        m_pMergeDoc = 0;
 }
 
@@ -218,9 +214,6 @@ int CMergeEditFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
                return -1;      // fail to create
        }       
 
-       m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALTEXTFILE);
-       m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALTEXTFILE);
-
        return 0;
 }
 
@@ -267,38 +260,13 @@ void CMergeEditFrame::ActivateFrame(int nCmdShow)
        m_wndLocationBar.LoadState(_T("Settings"));
        m_wndDetailBar.LoadState(_T("Settings"));
 
-       if (!m_bActivated) 
-       {
-               m_bActivated = true;
-
-               // get the active child frame, and a flag whether it is maximized
-               BOOL bMaximized = FALSE;
-               CMDIChildWnd * oldActiveFrame = GetMDIFrame()->MDIGetActive(&bMaximized);
-               if (oldActiveFrame == nullptr)
-                       // for the first frame, get the restored/maximized state from the registry
-                       bMaximized = GetOptionsMgr()->GetBool(OPT_ACTIVE_FRAME_MAX);
-               if (bMaximized)
-                       nCmdShow = SW_SHOWMAXIMIZED;
-               else
-                       nCmdShow = SW_SHOWNORMAL;
-       }
-
-       CMDIChildWnd::ActivateFrame(nCmdShow);
+       CMergeFrameCommon::ActivateFrame(nCmdShow);
 }
 
 BOOL CMergeEditFrame::DestroyWindow() 
 {
        SavePosition();
-       // If we are active, save the restored/maximized state
-       // If we are not, do nothing and let the active frame do the job.
-       if (this->GetParentFrame()->GetActiveFrame() == (CFrameWnd*)this)
-       {
-               WINDOWPLACEMENT wp;
-               wp.length = sizeof(WINDOWPLACEMENT);
-               GetWindowPlacement(&wp);
-               GetOptionsMgr()->SaveOption(OPT_ACTIVE_FRAME_MAX, (wp.showCmd == SW_MAXIMIZE));
-       }
-
+       SaveWindowState();
        return CMDIChildWnd::DestroyWindow();
 }
 
@@ -386,34 +354,6 @@ IHeaderBar * CMergeEditFrame::GetHeaderInterface()
        return &m_wndFilePathBar;
 }
 
-/**
-* @brief Reflect comparison result in window's icon.
-* @param nResult [in] Last comparison result which the application returns.
-*/
-void CMergeEditFrame::SetLastCompareResult(int nResult)
-{
-       HICON hCurrent = GetIcon(FALSE);
-       HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;
-
-       if (hCurrent != hReplace)
-       {
-               SetIcon(hReplace, TRUE);
-
-               BOOL bMaximized;
-               GetMDIFrame()->MDIGetActive(&bMaximized);
-
-               // When MDI maximized the window icon is drawn on the menu bar, so we
-               // need to notify it that our icon has changed.
-               if (bMaximized)
-               {
-                       GetMDIFrame()->DrawMenuBar();
-               }
-               GetMDIFrame()->OnUpdateFrameTitle(FALSE);
-       }
-
-       theApp.SetLastCompareResult(nResult);
-}
-
 void CMergeEditFrame::UpdateAutoPaneResize()
 {
        auto& wndSplitter = GetMergeEditSplitterWnd(0);
@@ -451,17 +391,6 @@ void CMergeEditFrame::OnTimer(UINT_PTR nIDEvent)
        CMDIChildWnd::OnTimer(nIDEvent);
 }
 
-void CMergeEditFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
-{
-       CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
-       // [Fix for MFC 8.0 MDI Maximizing Child Window bug on Vista]
-       // https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/iajCdW5DzTM
-#if _MFC_VER >= 0x0800
-       lpMMI->ptMaxTrackSize.x = max(lpMMI->ptMaxTrackSize.x, lpMMI->ptMaxSize.x);
-       lpMMI->ptMaxTrackSize.y = max(lpMMI->ptMaxTrackSize.y, lpMMI->ptMaxSize.y);
-#endif
-}
-
 void CMergeEditFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
 {
        CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
index 314f6cc..4b1d155 100644 (file)
 #include "EditorFilepathBar.h"
 #include "DiffViewBar.h"
 #include "LocationBar.h"
+#include "MergeFrameCommon.h"
 
 class CMergeDoc;
 
 /** 
  * @brief Frame class for file compare, handles panes, statusbar etc.
  */
-class CMergeEditFrame : public CMDIChildWnd
+class CMergeEditFrame : public CMergeFrameCommon
 {
        DECLARE_DYNCREATE(CMergeEditFrame)
 public:
@@ -48,14 +49,11 @@ public:
        void UpdateResources();
        void CloseNow();
        IHeaderBar * GetHeaderInterface();
-       void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
        CMergeDoc * GetMergeDoc() { return m_pMergeDoc; }
-       void SetLastCompareResult(int nResult);
 
        void UpdateAutoPaneResize();
        void UpdateSplitter();
        CSplitterWndEx& GetSplitter() { return m_wndSplitter; };
-       bool IsActivated() const { return m_bActivated; }
 
 // Attributes
 protected:
@@ -87,12 +85,8 @@ private:
 
 // Generated message map functions
 private:
-       int m_nLastSplitPos[2];
        void UpdateHeaderSizes();
-       bool m_bActivated;
        CMergeDoc * m_pMergeDoc;
-       HICON m_hIdentical;
-       HICON m_hDifferent;
 
        //{{AFX_MSG(CMergeEditFrame)
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
@@ -104,7 +98,6 @@ private:
        afx_msg LRESULT OnStorePaneSizes(WPARAM wParam, LPARAM lParam);
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnIdleUpdateCmdUI();
-       afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };
diff --git a/Src/MergeFrameCommon.cpp b/Src/MergeFrameCommon.cpp
new file mode 100644 (file)
index 0000000..1aa3a4c
--- /dev/null
@@ -0,0 +1,101 @@
+/** \r
+ * @file  MergeFrameCommon.cpp\r
+ *\r
+ * @brief Implementation file for CMergeFrameCommon\r
+ *\r
+ */\r
+#include "StdAfx.h"\r
+#include "MergeFrameCommon.h"\r
+#include "OptionsDef.h"\r
+#include "OptionsMgr.h"\r
+#include "Merge.h"\r
+\r
+IMPLEMENT_DYNCREATE(CMergeFrameCommon, CMDIChildWnd)\r
+\r
+BEGIN_MESSAGE_MAP(CMergeFrameCommon, CMDIChildWnd)\r
+       //{{AFX_MSG_MAP(CMergeFrameCommon)\r
+       ON_WM_GETMINMAXINFO()\r
+       //}}AFX_MSG_MAP\r
+END_MESSAGE_MAP()\r
+\r
+CMergeFrameCommon::CMergeFrameCommon(int nIdenticalIcon, int nDifferentIcon)\r
+       : m_hIdentical(nIdenticalIcon < 0 ? nullptr : AfxGetApp()->LoadIcon(nIdenticalIcon))\r
+       , m_hDifferent(nDifferentIcon < 0 ? nullptr : AfxGetApp()->LoadIcon(nDifferentIcon))\r
+       , m_bActivated(false)\r
+       , m_nLastSplitPos{0}\r
+{\r
+}\r
+\r
+void CMergeFrameCommon::ActivateFrame(int nCmdShow)\r
+{\r
+       if (!m_bActivated) \r
+       {\r
+               m_bActivated = true;\r
+\r
+               // get the active child frame, and a flag whether it is maximized\r
+               BOOL bMaximized = FALSE;\r
+               CMDIChildWnd * oldActiveFrame = GetMDIFrame()->MDIGetActive(&bMaximized);\r
+               if (oldActiveFrame == nullptr)\r
+                       // for the first frame, get the restored/maximized state from the registry\r
+                       bMaximized = GetOptionsMgr()->GetBool(OPT_ACTIVE_FRAME_MAX);\r
+               if (bMaximized)\r
+                       nCmdShow = SW_SHOWMAXIMIZED;\r
+               else\r
+                       nCmdShow = SW_SHOWNORMAL;\r
+       }\r
+\r
+       CMDIChildWnd::ActivateFrame(nCmdShow);\r
+}\r
+\r
+void CMergeFrameCommon::SaveWindowState()\r
+{\r
+       // If we are active, save the restored/maximized state\r
+       // If we are not, do nothing and let the active frame do the job.\r
+       if (GetParentFrame()->GetActiveFrame() == this)\r
+       {\r
+               WINDOWPLACEMENT wp;\r
+               wp.length = sizeof(WINDOWPLACEMENT);\r
+               GetWindowPlacement(&wp);\r
+               GetOptionsMgr()->SaveOption(OPT_ACTIVE_FRAME_MAX, (wp.showCmd == SW_MAXIMIZE));\r
+       }\r
+}\r
+\r
+/**\r
+ * @brief Reflect comparison result in window's icon.\r
+ * @param nResult [in] Last comparison result which the application returns.\r
+ */\r
+void CMergeFrameCommon::SetLastCompareResult(int nResult)\r
+{\r
+       HICON hCurrent = GetIcon(FALSE);\r
+       HICON hReplace = (nResult == 0) ? m_hIdentical : m_hDifferent;\r
+\r
+       if (hCurrent != hReplace)\r
+       {\r
+               SetIcon(hReplace, TRUE);\r
+\r
+               BOOL bMaximized;\r
+               GetMDIFrame()->MDIGetActive(&bMaximized);\r
+\r
+               // When MDI maximized the window icon is drawn on the menu bar, so we\r
+               // need to notify it that our icon has changed.\r
+               if (bMaximized)\r
+               {\r
+                       GetMDIFrame()->DrawMenuBar();\r
+               }\r
+               GetMDIFrame()->OnUpdateFrameTitle(FALSE);\r
+       }\r
+\r
+       theApp.SetLastCompareResult(nResult);\r
+}\r
+\r
+void CMergeFrameCommon::OnGetMinMaxInfo(MINMAXINFO* lpMMI)\r
+{\r
+       CMDIChildWnd::OnGetMinMaxInfo(lpMMI);\r
+       // [Fix for MFC 8.0 MDI Maximizing Child Window bug on Vista]\r
+       // https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/iajCdW5DzTM\r
+#if _MFC_VER >= 0x0800\r
+       lpMMI->ptMaxTrackSize.x = max(lpMMI->ptMaxTrackSize.x, lpMMI->ptMaxSize.x);\r
+       lpMMI->ptMaxTrackSize.y = max(lpMMI->ptMaxTrackSize.y, lpMMI->ptMaxSize.y);\r
+#endif\r
+}\r
+\r
diff --git a/Src/MergeFrameCommon.h b/Src/MergeFrameCommon.h
new file mode 100644 (file)
index 0000000..b29562f
--- /dev/null
@@ -0,0 +1,30 @@
+/** \r
+ * @file  MergeFrameCommon.h\r
+ *\r
+ * @brief interface of the CMergeFrameCommon class\r
+ *\r
+ */\r
+#pragma once\r
+\r
+class CMergeFrameCommon: public CMDIChildWnd\r
+{\r
+       DECLARE_DYNCREATE(CMergeFrameCommon)\r
+public:\r
+       CMergeFrameCommon::CMergeFrameCommon(int nIdenticalIcon  = -1, int nDifferentIcon = -1);\r
+       bool IsActivated() const { return m_bActivated; }\r
+       void ActivateFrame(int nCmdShow);\r
+       void SetLastCompareResult(int nResult);\r
+       void SaveWindowState();\r
+       void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };\r
+protected:\r
+       int m_nLastSplitPos[2];\r
+private:\r
+       bool m_bActivated;\r
+       HICON m_hIdentical;\r
+       HICON m_hDifferent;\r
+\r
+       //{{AFX_MSG(CMergeFrameCommon)\r
+       afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);\r
+       //}}AFX_MSG\r
+       DECLARE_MESSAGE_MAP()\r
+};\r
index 5dab894..7ef34cb 100644 (file)
@@ -4,6 +4,7 @@
 #include "OpenFrm.h"
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
+#include "MergeFrameCommon.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
 
 // COpenFrame
 
-IMPLEMENT_DYNCREATE(COpenFrame, CMDIChildWnd)
+IMPLEMENT_DYNCREATE(COpenFrame, CMergeFrameCommon)
 
-BEGIN_MESSAGE_MAP(COpenFrame, CMDIChildWnd)
+BEGIN_MESSAGE_MAP(COpenFrame, CMergeFrameCommon)
        //{{AFX_MSG_MAP(COpenFrame)
        ON_WM_ERASEBKGND()
        ON_WM_NCHITTEST()
        ON_WM_WINDOWPOSCHANGING()
-       ON_WM_GETMINMAXINFO()
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -87,24 +87,9 @@ void COpenFrame::OnWindowPosChanging(WINDOWPOS* lpwndpos)
        }
 }
 
-void COpenFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
-{
-       CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
-       // [Fix for MFC 8.0 MDI Maximizing Child Window bug on Vista]
-       // https://groups.google.com/forum/#!topic/microsoft.public.vc.mfc/iajCdW5DzTM
-#if _MFC_VER >= 0x0800
-       lpMMI->ptMaxTrackSize.x = max(lpMMI->ptMaxTrackSize.x, lpMMI->ptMaxSize.x);
-       lpMMI->ptMaxTrackSize.y = max(lpMMI->ptMaxTrackSize.y, lpMMI->ptMaxSize.y);
-#endif
-}
-
 void COpenFrame::ActivateFrame(int nCmdShow) 
 {
-       if (!GetMDIFrame()->MDIGetActive() && GetOptionsMgr()->GetBool(OPT_ACTIVE_FRAME_MAX))
-       {
-               nCmdShow = SW_SHOWMAXIMIZED;
-       }
-       CMDIChildWnd::ActivateFrame(nCmdShow);
+       CMergeFrameCommon::ActivateFrame(nCmdShow);
        if (CView *const pView = GetActiveView())
        {
                WINDOWPLACEMENT wp;
@@ -132,16 +117,7 @@ void COpenFrame::UpdateResources()
  */
 BOOL COpenFrame::DestroyWindow() 
 {
-       // If we are active, save the restored/maximized state
-       // If we are not, do nothing and let the active frame do the job.
-       if (GetParentFrame()->GetActiveFrame() == this)
-       {
-               WINDOWPLACEMENT wp;
-               wp.length = sizeof(WINDOWPLACEMENT);
-               GetWindowPlacement(&wp);
-               GetOptionsMgr()->SaveOption(OPT_ACTIVE_FRAME_MAX, (wp.showCmd == SW_MAXIMIZE));
-       }
-
+       SaveWindowState();
        return CMDIChildWnd::DestroyWindow();
 }
 
index 909df8f..dd2027c 100644 (file)
@@ -1,11 +1,10 @@
 // OpenFrm.h : interface of the COpenFrame class
 //
-
-
 #pragma once
 
+#include "MergeFrameCommon.h"
 
-class COpenFrame : public CMDIChildWnd
+class COpenFrame : public CMergeFrameCommon
 {
        DECLARE_DYNCREATE(COpenFrame)
 public:
@@ -17,7 +16,6 @@ public:
 // Operations
 public:
        void UpdateResources();
-       void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
 
 // Overrides
        // ClassWizard generated virtual function overrides
@@ -39,7 +37,6 @@ protected:
        afx_msg BOOL OnEraseBkgnd(CDC* pDC);
        afx_msg LRESULT OnNcHitTest(CPoint point);
        afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos);
-       afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 };