fix some dialog can't show after resize and close and open again
[TortoiseGit.git] / src / TortoiseProc / CreateBranchTagDlg.cpp
blobd7b56f156087b2bed47ef994dc7ffdc256504361
1 // CreateBranchTagDlg.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "Git.h"
6 #include "TortoiseProc.h"
7 #include "CreateBranchTagDlg.h"
9 #include "Messagebox.h"
11 // CCreateBranchTagDlg dialog
13 IMPLEMENT_DYNAMIC(CCreateBranchTagDlg, CResizableStandAloneDialog)
15 CCreateBranchTagDlg::CCreateBranchTagDlg(CWnd* pParent /*=NULL*/)
16 : CResizableStandAloneDialog(CCreateBranchTagDlg::IDD, pParent),
17 CChooseVersion(this)
19 m_bIsTag=0;
20 m_bSwitch = 0; // default switch to checkbox not selected
23 CCreateBranchTagDlg::~CCreateBranchTagDlg()
27 void CCreateBranchTagDlg::DoDataExchange(CDataExchange* pDX)
29 CDialog::DoDataExchange(pDX);
31 CHOOSE_VERSION_DDX;
33 DDX_Text(pDX, IDC_BRANCH_TAG, this->m_BranchTagName);
34 DDX_Check(pDX,IDC_CHECK_FORCE,this->m_bForce);
35 DDX_Check(pDX,IDC_CHECK_TRACK,this->m_bTrack);
36 DDX_Check(pDX,IDC_CHECK_SWITCH,this->m_bSwitch);
41 BEGIN_MESSAGE_MAP(CCreateBranchTagDlg, CResizableStandAloneDialog)
42 CHOOSE_VERSION_EVENT
43 ON_BN_CLICKED(IDOK, &CCreateBranchTagDlg::OnBnClickedOk)
44 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH, &CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch)
45 END_MESSAGE_MAP()
47 BOOL CCreateBranchTagDlg::OnInitDialog()
49 CResizableStandAloneDialog::OnInitDialog();
51 CHOOSE_VERSION_ADDANCHOR;
53 AddAnchor(IDC_GROUP_BRANCH, TOP_LEFT, TOP_RIGHT);
55 AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);
57 AddAnchor(IDOK,BOTTOM_RIGHT);
58 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
60 this->AddOthersToAnchor();
62 if(m_Base.IsEmpty())
64 this->SetDefaultChoose(IDC_RADIO_HEAD);
66 }else
68 this->SetDefaultChoose(IDC_RADIO_VERSION);
69 this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Base);
72 Init();
74 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);
76 if(this->m_bIsTag)
78 this->SetWindowTextW(_T("Create Tag"));
79 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Tag"));
81 else
83 this->SetWindowTextW(_T("Create Branch"));
84 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Branch"));
86 // show the switch checkbox if we are a create branch dialog
87 this->GetDlgItem(IDC_CHECK_SWITCH)->ShowWindow( !m_bIsTag );
88 CWnd* pHead = GetDlgItem(IDC_RADIO_HEAD);
89 CString HeadText;
90 pHead->GetWindowText( HeadText );
91 pHead->SetWindowText( HeadText + " (" + g_Git.GetCurrentBranch() + ")");
92 EnableSaveRestore(_T("BranchTagDlg"));
93 return TRUE;
97 // CCreateBranchTagDlg message handlers
99 void CCreateBranchTagDlg::OnBnClickedOk()
101 // TODO: Add your control notification handler code here
102 this->UpdateData(TRUE);
104 this->m_BranchTagName.Trim();
105 if(this->m_BranchTagName.IsEmpty() || this->m_BranchTagName.Find(' ') >= 0 )
107 CMessageBox::Show(NULL, IDS_B_T_NOTEMPTY, IDS_TORTOISEGIT, MB_OK);
108 return;
110 this->UpdateRevsionName();
111 OnOK();
114 void CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch()
116 // TODO: Add your control notification handler code here
118 if(this->m_ChooseVersioinBranch.GetString().Left(6)==_T("origin"))
119 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);
120 else
121 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);
123 if(this->m_bIsTag)
124 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);