/////////////////////////////////////////////////////////////////////////////
// CDirFrame
-IMPLEMENT_DYNCREATE(CDirFrame, CMDIChildWnd)
+IMPLEMENT_DYNCREATE(CDirFrame, CMergeFrameCommon)
CDirFrame::CDirFrame()
-: m_hIdentical(nullptr)
-, m_hDifferent(nullptr)
+: CMergeFrameCommon(IDI_EQUALFOLDER, IDI_NOTEQUALFOLDER)
{
}
}
-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()
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;
}
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);
}
/**
{
}
-/**
-* @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();
*/
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();
}
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
-}
#pragma once
#include "EditorFilepathBar.h"
+#include "MergeFrameCommon.h"
/////////////////////////////////////////////////////////////////////////////
// CDirFrame frame
/**
* @brief Frame window for Directory Compare window
*/
-class CDirFrame : public CMDIChildWnd
+class CDirFrame : public CMergeFrameCommon
{
DECLARE_DYNCREATE(CDirFrame)
protected:
public:
private:
- HICON m_hIdentical;
- HICON m_hDifferent;
// Operations
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
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()
};
/////////////////////////////////////////////////////////////////////////////
// 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)
// 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;
}
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++)
void CHexMergeFrame::ActivateFrame(int nCmdShow)
{
- if (!GetMDIFrame()->MDIGetActive() && GetOptionsMgr()->GetBool(OPT_ACTIVE_FRAME_MAX))
- {
- nCmdShow = SW_SHOWMAXIMIZED;
- }
- CMDIChildWnd::ActivateFrame(nCmdShow);
+ CMergeFrameCommon::ActivateFrame(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();
}
{
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());
}
}
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()
{
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()
{
#include "SplitterWndEx.h"
#include "EditorFilepathBar.h"
+#include "MergeFrameCommon.h"
#define HEKSEDIT_INTERFACE_VERSION 2
#include "heksedit.h"
/**
* @brief Frame class for file compare, handles panes, statusbar etc.
*/
-class CHexMergeFrame : public CMDIChildWnd
+class CHexMergeFrame : public CMergeFrameCommon
{
DECLARE_DYNCREATE(CHexMergeFrame)
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();
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()
};
/////////////////////////////////////////////////////////////////////////////
// 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)
// 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);
}
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;
}
{
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();
}
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);
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
#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
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();
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;
//{{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);
<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
<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
<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
<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
/////////////////////////////////////////////////////////////////////////////
// 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)
* @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;
}
return -1; // fail to create
}
- m_hIdentical = AfxGetApp()->LoadIcon(IDI_EQUALTEXTFILE);
- m_hDifferent = AfxGetApp()->LoadIcon(IDI_NOTEQUALTEXTFILE);
-
return 0;
}
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();
}
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);
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);
#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:
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:
// 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);
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()
};
--- /dev/null
+/** \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
--- /dev/null
+/** \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
#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()
}
}
-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;
*/
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();
}
// OpenFrm.h : interface of the COpenFrame class
//
-
-
#pragma once
+#include "MergeFrameCommon.h"
-class COpenFrame : public CMDIChildWnd
+class COpenFrame : public CMergeFrameCommon
{
DECLARE_DYNCREATE(COpenFrame)
public:
// Operations
public:
void UpdateResources();
- void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; };
// Overrides
// ClassWizard generated virtual function overrides
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()
};