Fixed blame crash at XP system
[TortoiseGit.git] / src / TortoiseProc / RelocateDlg.cpp
blobbb433998e01d3013e71ab6430f1ba5308041d1a5
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - 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 "TortoiseProc.h"
21 #include "RelocateDlg.h"
22 #include "RepositoryBrowser.h"
23 #include "BrowseFolder.h"
24 #include "AppUtils.h"
26 IMPLEMENT_DYNAMIC(CRelocateDlg, CResizableStandAloneDialog)
27 CRelocateDlg::CRelocateDlg(CWnd* pParent /*=NULL*/)
28 : CResizableStandAloneDialog(CRelocateDlg::IDD, pParent)
29 , m_sToUrl(_T(""))
30 , m_sFromUrl(_T(""))
34 CRelocateDlg::~CRelocateDlg()
38 void CRelocateDlg::DoDataExchange(CDataExchange* pDX)
40 CResizableStandAloneDialog::DoDataExchange(pDX);
41 DDX_Control(pDX, IDC_TOURL, m_URLCombo);
45 BEGIN_MESSAGE_MAP(CRelocateDlg, CResizableStandAloneDialog)
46 ON_BN_CLICKED(IDC_BROWSE, OnBnClickedBrowse)
47 ON_BN_CLICKED(IDHELP, OnBnClickedHelp)
48 ON_WM_SIZING()
49 END_MESSAGE_MAP()
51 BOOL CRelocateDlg::OnInitDialog()
53 CResizableStandAloneDialog::OnInitDialog();
55 m_URLCombo.SetURLHistory(TRUE);
56 m_URLCombo.LoadHistory(_T("Software\\TortoiseGit\\History\\repoURLS"), _T("url"));
57 m_URLCombo.SetCurSel(0);
59 RECT rect;
60 GetWindowRect(&rect);
61 m_height = rect.bottom - rect.top;
63 AddAnchor(IDC_TOURL, TOP_LEFT, TOP_RIGHT);
64 AddAnchor(IDC_BROWSE, TOP_RIGHT);
65 AddAnchor(IDOK, BOTTOM_RIGHT);
66 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
67 AddAnchor(IDHELP, BOTTOM_RIGHT);
69 SetDlgItemText(IDC_FROMURL, m_sFromUrl);
70 m_URLCombo.SetWindowText(m_sFromUrl);
71 if ((m_pParentWnd==NULL)&&(hWndExplorer))
72 CenterWindow(CWnd::FromHandle(hWndExplorer));
73 EnableSaveRestore(_T("RelocateDlg"));
74 return TRUE;
77 void CRelocateDlg::OnBnClickedBrowse()
79 SVNRev rev(SVNRev::REV_HEAD);
80 CAppUtils::BrowseRepository(m_URLCombo, this, rev);
83 void CRelocateDlg::OnOK()
85 UpdateData(TRUE);
86 m_URLCombo.SaveHistory();
87 m_sToUrl = m_URLCombo.GetString();
88 UpdateData(FALSE);
90 CResizableStandAloneDialog::OnOK();
93 void CRelocateDlg::OnBnClickedHelp()
95 OnHelp();
98 void CRelocateDlg::OnSizing(UINT fwSide, LPRECT pRect)
100 // don't allow the dialog to be changed in height
101 switch (fwSide)
103 case WMSZ_BOTTOM:
104 case WMSZ_BOTTOMLEFT:
105 case WMSZ_BOTTOMRIGHT:
106 pRect->bottom = pRect->top + m_height;
107 break;
108 case WMSZ_TOP:
109 case WMSZ_TOPLEFT:
110 case WMSZ_TOPRIGHT:
111 pRect->top = pRect->bottom - m_height;
112 break;
114 CResizableStandAloneDialog::OnSizing(fwSide, pRect);