OSDN Git Service

Fix crash when registry is set to an unexpected value
[winmerge-jp/winmerge-jp.git] / Src / PropArchive.cpp
1 /** 
2  * @file  PropArchive.cpp
3  *
4  * @brief Implementation of PropArchive propertysheet
5  */
6
7 #include "stdafx.h"
8 #include "PropArchive.h"
9 #include "OptionsDef.h"
10 #include "OptionsMgr.h"
11 #include "OptionsPanel.h"
12
13 #ifdef _DEBUG
14 #define new DEBUG_NEW
15 #endif
16
17 // PropArchive dialog
18
19 PropArchive::PropArchive(COptionsMgr *optionsMgr)
20 : OptionsPanel(optionsMgr, PropArchive::IDD)
21 , m_bEnableSupport(false)
22 , m_bProbeType(false)
23 {
24 }
25
26 /** 
27  * @brief Sets update handlers for dialog controls.
28  */
29 void PropArchive::DoDataExchange(CDataExchange* pDX)
30 {
31         CPropertyPage::DoDataExchange(pDX);
32         DDX_Check(pDX, IDC_ARCHIVE_ENABLE, m_bEnableSupport);
33         DDX_Check(pDX, IDC_ARCHIVE_DETECTTYPE, m_bProbeType);
34         UpdateControls();
35 }
36
37
38 BEGIN_MESSAGE_MAP(PropArchive, OptionsPanel)
39         ON_BN_CLICKED(IDC_ARCHIVE_ENABLE, OnEnableClicked)
40 END_MESSAGE_MAP()
41
42 /** 
43  * @brief Reads options values from storage to UI.
44  */
45 void PropArchive::ReadOptions()
46 {
47         int enable = GetOptionsMgr()->GetBool(OPT_ARCHIVE_ENABLE);
48         m_bEnableSupport = enable > 0;
49         m_bProbeType = GetOptionsMgr()->GetBool(OPT_ARCHIVE_PROBETYPE);
50 }
51
52 /** 
53  * @brief Writes options values from UI to storage.
54  */
55 void PropArchive::WriteOptions()
56 {
57         GetOptionsMgr()->SaveOption(OPT_ARCHIVE_ENABLE, m_bEnableSupport);
58         GetOptionsMgr()->SaveOption(OPT_ARCHIVE_PROBETYPE, m_bProbeType);
59 }
60
61 /** 
62  * @brief Called when archive support is enabled or disabled.
63  */
64 void PropArchive::OnEnableClicked()
65 {
66         UpdateControls();
67 }
68
69 /** 
70  * @brief Called Updates controls enabled/disables state.
71  */
72 void PropArchive::UpdateControls()
73 {
74         EnableDlgItem(IDC_ARCHIVE_DETECTTYPE, IsDlgButtonChecked(IDC_ARCHIVE_ENABLE) == 1);
75 }