1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "Resource.h"
\r
21 #include "StandAloneDlg.h"
\r
23 IMPLEMENT_DYNAMIC(CResizableStandAloneDialog, CDialog)
\r
24 CResizableStandAloneDialog::CResizableStandAloneDialog(UINT nIDTemplate, CWnd* pParentWnd /*= NULL*/)
\r
25 : CStandAloneDialogTmpl<CResizableDialog>(nIDTemplate, pParentWnd)
\r
26 , m_bVertical(false)
\r
27 , m_bHorizontal(false)
\r
31 BEGIN_MESSAGE_MAP(CResizableStandAloneDialog, CStandAloneDialogTmpl<CResizableDialog>)
\r
38 void CResizableStandAloneDialog::OnSizing(UINT fwSide, LPRECT pRect)
\r
40 m_bVertical = m_bVertical && (fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT);
\r
41 m_bHorizontal = m_bHorizontal && (fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM);
\r
42 CStandAloneDialogTmpl<CResizableDialog>::OnSizing(fwSide, pRect);
\r
45 void CResizableStandAloneDialog::OnMoving(UINT fwSide, LPRECT pRect)
\r
47 m_bVertical = m_bHorizontal = false;
\r
48 CStandAloneDialogTmpl<CResizableDialog>::OnMoving(fwSide, pRect);
\r
51 void CResizableStandAloneDialog::OnNcMButtonUp(UINT nHitTest, CPoint point)
\r
53 WINDOWPLACEMENT windowPlacement;
\r
54 if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)
\r
56 CRect rcWorkArea, rcWindowRect;
\r
57 GetWindowRect(&rcWindowRect);
\r
60 rcWindowRect.top = m_rcOrgWindowRect.top;
\r
61 rcWindowRect.bottom = m_rcOrgWindowRect.bottom;
\r
63 else if (SystemParametersInfo(SPI_GETWORKAREA, 0U, &rcWorkArea, 0U))
\r
65 m_rcOrgWindowRect.top = rcWindowRect.top;
\r
66 m_rcOrgWindowRect.bottom = rcWindowRect.bottom;
\r
67 rcWindowRect.top = rcWorkArea.top;
\r
68 rcWindowRect.bottom = rcWorkArea.bottom;
\r
70 m_bVertical = !m_bVertical;
\r
71 m_bHorizontal = m_bHorizontal;
\r
72 MoveWindow(&rcWindowRect);
\r
74 CStandAloneDialogTmpl<CResizableDialog>::OnNcMButtonUp(nHitTest, point);
\r
77 void CResizableStandAloneDialog::OnNcRButtonUp(UINT nHitTest, CPoint point)
\r
79 WINDOWPLACEMENT windowPlacement;
\r
80 if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)
\r
82 CRect rcWorkArea, rcWindowRect;
\r
83 GetWindowRect(&rcWindowRect);
\r
86 rcWindowRect.left = m_rcOrgWindowRect.left;
\r
87 rcWindowRect.right = m_rcOrgWindowRect.right;
\r
89 else if (SystemParametersInfo(SPI_GETWORKAREA, 0U, &rcWorkArea, 0U))
\r
91 m_rcOrgWindowRect.left = rcWindowRect.left;
\r
92 m_rcOrgWindowRect.right = rcWindowRect.right;
\r
93 rcWindowRect.left = rcWorkArea.left;
\r
94 rcWindowRect.right = rcWorkArea.right;
\r
96 m_bVertical = m_bVertical;
\r
97 m_bHorizontal = !m_bHorizontal;
\r
98 MoveWindow(&rcWindowRect);
\r
100 // for some reasons, when the window is resized horizontally, its menu size is not get adjusted.
\r
101 // so, we force it to happen.
\r
102 SetMenu(GetMenu());
\r
104 CStandAloneDialogTmpl<CResizableDialog>::OnNcRButtonUp(nHitTest, point);
\r