Use correct length for buffer
[TortoiseGit.git] / src / TortoiseProc / LogOrdering.cpp
blob5b876a981e8698ed5c294b72d067b7746fe23d2c
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2013-2016 - TortoiseGit
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 "LogOrdering.h"
21 #include "Git.h"
22 #include "registry.h"
24 IMPLEMENT_DYNAMIC(CLogOrdering, CDialog)
25 CLogOrdering::CLogOrdering(CWnd* pParent /*=nullptr*/)
26 : CDialog(CLogOrdering::IDD, pParent)
30 CLogOrdering::~CLogOrdering()
34 void CLogOrdering::DoDataExchange(CDataExchange* pDX)
36 CDialog::DoDataExchange(pDX);
37 DDX_Control(pDX, IDC_COMBOBOXEX_ORDERING, m_cLogOrdering);
40 BEGIN_MESSAGE_MAP(CLogOrdering, CDialog)
41 END_MESSAGE_MAP()
43 BOOL CLogOrdering::OnInitDialog()
45 CDialog::OnInitDialog();
47 int ind = m_cLogOrdering.AddString(CString(MAKEINTRESOURCE(IDS_LOG_CHRONOLOGICALREVERSEDORDER)));
48 m_cLogOrdering.SetItemData(ind, CGit::LOG_ORDER_CHRONOLOGIALREVERSED);
49 ind = m_cLogOrdering.AddString(_T("--topo-order ") + CString(MAKEINTRESOURCE(IDS_TORTOISEGITDEFAULT)));
50 m_cLogOrdering.SetItemData(ind, CGit::LOG_ORDER_TOPOORDER);
51 ind = m_cLogOrdering.AddString(_T("--date-order"));
52 m_cLogOrdering.SetItemData(ind, CGit::LOG_ORDER_DATEORDER);
54 DWORD curOrder = CRegDWORD(_T("Software\\TortoiseGit\\LogOrderBy"), CGit::LOG_ORDER_TOPOORDER);
55 for (int i = 0; i < m_cLogOrdering.GetCount(); ++i)
56 if (m_cLogOrdering.GetItemData(i) == curOrder)
57 m_cLogOrdering.SetCurSel(i);
59 return TRUE;
62 void CLogOrdering::OnOK()
64 if (m_cLogOrdering.GetCurSel() != CB_ERR)
65 CRegDWORD(_T("Software\\TortoiseGit\\LogOrderBy")) = (DWORD)m_cLogOrdering.GetItemData(m_cLogOrdering.GetCurSel());
67 __super::OnOK();