Sync TortoiseIDiff and TortoiseUDiff from TortoiseSVN
[TortoiseGit.git] / src / Utils / MiscUI / StandAloneDlg.cpp
blob735234ccaee266ba13bf84603c6a6e2ee05481c3
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008,2011 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "Resource.h"
21 #include "StandAloneDlg.h"
23 const UINT TaskBarButtonCreated = RegisterWindowMessage(L"TaskbarButtonCreated");
25 BEGIN_TEMPLATE_MESSAGE_MAP(CStandAloneDialogTmpl, BaseType, BaseType)
26 ON_REGISTERED_MESSAGE(TaskBarButtonCreated, OnTaskbarButtonCreated)
27 END_MESSAGE_MAP()
29 IMPLEMENT_DYNAMIC(CStandAloneDialog, CStandAloneDialogTmpl<CDialog>)
30 CStandAloneDialog::CStandAloneDialog(UINT nIDTemplate, CWnd* pParentWnd /*= NULL*/)
31 : CStandAloneDialogTmpl<CDialog>(nIDTemplate, pParentWnd)
34 BEGIN_MESSAGE_MAP(CStandAloneDialog, CStandAloneDialogTmpl<CDialog>)
35 END_MESSAGE_MAP()
37 IMPLEMENT_DYNAMIC(CStateStandAloneDialog, CStandAloneDialogTmpl<CStateDialog>)
38 CStateStandAloneDialog::CStateStandAloneDialog(UINT nIDTemplate, CWnd* pParentWnd /*= NULL*/)
39 : CStandAloneDialogTmpl<CStateDialog>(nIDTemplate, pParentWnd)
42 BEGIN_MESSAGE_MAP(CStateStandAloneDialog, CStandAloneDialogTmpl<CStateDialog>)
43 END_MESSAGE_MAP()
45 IMPLEMENT_DYNAMIC(CResizableStandAloneDialog, CDialog)
46 CResizableStandAloneDialog::CResizableStandAloneDialog(UINT nIDTemplate, CWnd* pParentWnd /*= NULL*/)
47 : CStandAloneDialogTmpl<CResizableDialog>(nIDTemplate, pParentWnd)
48 , m_bVertical(false)
49 , m_bHorizontal(false)
53 BEGIN_MESSAGE_MAP(CResizableStandAloneDialog, CStandAloneDialogTmpl<CResizableDialog>)
54 ON_WM_SIZING()
55 ON_WM_MOVING()
56 ON_WM_NCMBUTTONUP()
57 ON_WM_NCRBUTTONUP()
58 ON_BN_CLICKED(IDHELP, OnHelp)
59 END_MESSAGE_MAP()
61 void CResizableStandAloneDialog::OnSizing(UINT fwSide, LPRECT pRect)
63 m_bVertical = m_bVertical && (fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT);
64 m_bHorizontal = m_bHorizontal && (fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM);
65 CStandAloneDialogTmpl<CResizableDialog>::OnSizing(fwSide, pRect);
68 void CResizableStandAloneDialog::OnMoving(UINT fwSide, LPRECT pRect)
70 m_bVertical = m_bHorizontal = false;
71 CStandAloneDialogTmpl<CResizableDialog>::OnMoving(fwSide, pRect);
74 void CResizableStandAloneDialog::OnNcMButtonUp(UINT nHitTest, CPoint point)
76 WINDOWPLACEMENT windowPlacement;
77 if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)
79 CRect rcWorkArea, rcWindowRect;
80 GetWindowRect(&rcWindowRect);
81 if (m_bVertical)
83 rcWindowRect.top = m_rcOrgWindowRect.top;
84 rcWindowRect.bottom = m_rcOrgWindowRect.bottom;
86 else if (SystemParametersInfo(SPI_GETWORKAREA, 0U, &rcWorkArea, 0U))
88 m_rcOrgWindowRect.top = rcWindowRect.top;
89 m_rcOrgWindowRect.bottom = rcWindowRect.bottom;
90 rcWindowRect.top = rcWorkArea.top;
91 rcWindowRect.bottom = rcWorkArea.bottom;
93 m_bVertical = !m_bVertical;
94 MoveWindow(&rcWindowRect);
96 CStandAloneDialogTmpl<CResizableDialog>::OnNcMButtonUp(nHitTest, point);
99 void CResizableStandAloneDialog::OnNcRButtonUp(UINT nHitTest, CPoint point)
101 WINDOWPLACEMENT windowPlacement;
102 if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)
104 CRect rcWorkArea, rcWindowRect;
105 GetWindowRect(&rcWindowRect);
106 if (m_bHorizontal)
108 rcWindowRect.left = m_rcOrgWindowRect.left;
109 rcWindowRect.right = m_rcOrgWindowRect.right;
111 else if (SystemParametersInfo(SPI_GETWORKAREA, 0U, &rcWorkArea, 0U))
113 m_rcOrgWindowRect.left = rcWindowRect.left;
114 m_rcOrgWindowRect.right = rcWindowRect.right;
115 rcWindowRect.left = rcWorkArea.left;
116 rcWindowRect.right = rcWorkArea.right;
118 m_bHorizontal = !m_bHorizontal;
119 MoveWindow(&rcWindowRect);
120 // WORKAROUND
121 // for some reasons, when the window is resized horizontally, its menu size is not get adjusted.
122 // so, we force it to happen.
123 SetMenu(GetMenu());
125 CStandAloneDialogTmpl<CResizableDialog>::OnNcRButtonUp(nHitTest, point);
128 BEGIN_MESSAGE_MAP(CStateDialog, CDialog)
129 END_MESSAGE_MAP()