OSDN Git Service

Add Help button handle and add Anchor at format patch for refbrowse button
[tortoisegit/TortoiseGitJp.git] / src / Utils / MiscUI / StandAloneDlg.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #include "stdafx.h"\r
20 #include "Resource.h"\r
21 #include "StandAloneDlg.h"\r
22 \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
28 {\r
29 }\r
30 \r
31 BEGIN_MESSAGE_MAP(CResizableStandAloneDialog, CStandAloneDialogTmpl<CResizableDialog>)\r
32         ON_WM_SIZING()\r
33         ON_WM_MOVING()\r
34         ON_WM_NCMBUTTONUP()\r
35         ON_WM_NCRBUTTONUP()\r
36         ON_BN_CLICKED(IDHELP, OnHelp)\r
37 END_MESSAGE_MAP()\r
38 \r
39 void CResizableStandAloneDialog::OnSizing(UINT fwSide, LPRECT pRect)\r
40 {\r
41         m_bVertical = m_bVertical && (fwSide == WMSZ_LEFT || fwSide == WMSZ_RIGHT);\r
42         m_bHorizontal = m_bHorizontal && (fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM);\r
43         CStandAloneDialogTmpl<CResizableDialog>::OnSizing(fwSide, pRect);\r
44 }\r
45 \r
46 void CResizableStandAloneDialog::OnMoving(UINT fwSide, LPRECT pRect)\r
47 {\r
48         m_bVertical = m_bHorizontal = false;\r
49         CStandAloneDialogTmpl<CResizableDialog>::OnMoving(fwSide, pRect);\r
50 }\r
51 \r
52 void CResizableStandAloneDialog::OnNcMButtonUp(UINT nHitTest, CPoint point) \r
53 {\r
54         WINDOWPLACEMENT windowPlacement;\r
55         if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)\r
56         {\r
57                 CRect rcWorkArea, rcWindowRect;\r
58                 GetWindowRect(&rcWindowRect);\r
59                 if (m_bVertical)\r
60                 {\r
61                         rcWindowRect.top = m_rcOrgWindowRect.top;\r
62                         rcWindowRect.bottom = m_rcOrgWindowRect.bottom;\r
63                 }\r
64                 else if (SystemParametersInfo(SPI_GETWORKAREA, 0U, &rcWorkArea, 0U))\r
65                 {\r
66                         m_rcOrgWindowRect.top = rcWindowRect.top;\r
67                         m_rcOrgWindowRect.bottom = rcWindowRect.bottom;\r
68                         rcWindowRect.top = rcWorkArea.top;\r
69                         rcWindowRect.bottom = rcWorkArea.bottom;\r
70                 }\r
71                 m_bVertical = !m_bVertical;\r
72                 m_bHorizontal = m_bHorizontal;\r
73                 MoveWindow(&rcWindowRect);\r
74         }\r
75         CStandAloneDialogTmpl<CResizableDialog>::OnNcMButtonUp(nHitTest, point);\r
76 }\r
77 \r
78 void CResizableStandAloneDialog::OnNcRButtonUp(UINT nHitTest, CPoint point) \r
79 {\r
80         WINDOWPLACEMENT windowPlacement;\r
81         if ((nHitTest == HTMAXBUTTON) && GetWindowPlacement(&windowPlacement) && windowPlacement.showCmd == SW_SHOWNORMAL)\r
82         {\r
83                 CRect rcWorkArea, rcWindowRect;\r
84                 GetWindowRect(&rcWindowRect);\r
85                 if (m_bHorizontal)\r
86                 {\r
87                         rcWindowRect.left = m_rcOrgWindowRect.left;\r
88                         rcWindowRect.right = m_rcOrgWindowRect.right;\r
89                 }\r
90                 else if (SystemParametersInfo(SPI_GETWORKAREA, 0U, &rcWorkArea, 0U))\r
91                 {\r
92                         m_rcOrgWindowRect.left = rcWindowRect.left;\r
93                         m_rcOrgWindowRect.right = rcWindowRect.right;\r
94                         rcWindowRect.left = rcWorkArea.left;\r
95                         rcWindowRect.right = rcWorkArea.right;\r
96                 }\r
97                 m_bVertical = m_bVertical;\r
98                 m_bHorizontal = !m_bHorizontal;\r
99                 MoveWindow(&rcWindowRect);\r
100                 // WORKAROUND\r
101                 // for some reasons, when the window is resized horizontally, its menu size is not get adjusted.\r
102                 // so, we force it to happen.\r
103                 SetMenu(GetMenu());\r
104         }\r
105         CStandAloneDialogTmpl<CResizableDialog>::OnNcRButtonUp(nHitTest, point);\r
106 }\r