Garmin Fleet Management Controller  2.19.0
CHosSettingDlg.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * CHosSettingDlg.cpp
5 *
6 * Copyright 2014 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 
11 #include "stdafx.h"
12 #include "CHosSettingDlg.h"
13 
14 #if( FMI_SUPPORT_A615 )
15 
16 // CHosSettingDlg dialog
17 
18 IMPLEMENT_DYNAMIC(CHosSettingDlg, CDialog)
19 
20 UINT CHosSettingDlg::CaptureSetting(
21  CWnd* pParent,
22  UINT titleStringId,
23  UINT valueLabelStringId,
24  UINT valueUnitStringId,
25  long valueLowerLimit,
26  long valueUpperLimit,
27  BOOL & enabled,
28  uint16 & value
29  )
30 {
31  CHosSettingDlg dlg( pParent );
32  dlg.mTitleStringId = titleStringId;
33  dlg.mValueLabelStringId = valueLabelStringId;
34  dlg.mValueUnitStringId = valueUnitStringId;
35  dlg.mValueLowerLimit = valueLowerLimit;
36  dlg.mValueUpperLimit = valueUpperLimit;
37  if( IDOK == dlg.DoModal() )
38  {
39  enabled = !dlg.mDisabled;
40  value = ( uint16 )_tcstol( dlg.mValue, NULL, 10 );
41  return IDOK;
42  }
43  return IDCANCEL;
44 }
45 
46 //----------------------------------------------------------------------
50 //----------------------------------------------------------------------
52  CWnd* pParent
53  )
54  : CDialog(CHosSettingDlg::IDD, pParent)
55  , mValue(_T(""))
56  , mDisabled(FALSE)
57  {
58 
59 }
60 
62 {
63 }
64 
65 void CHosSettingDlg::DoDataExchange(CDataExchange* pDX)
66 {
67 CDialog::DoDataExchange(pDX);
68 DDX_Text(pDX, IDC_HOS_SETTING_VALUE, mValue);
69 DDV_MaxChars(pDX, mValue, 5);
70 DDX_Radio(pDX, IDC_ENABLE_YES, mDisabled);
71  }
72 
73 
74 BEGIN_MESSAGE_MAP(CHosSettingDlg, CDialog)
75  ON_BN_CLICKED(IDC_ENABLE_YES, OnReevaluate)
76  ON_BN_CLICKED(IDC_ENABLE_NO, OnReevaluate)
77  ON_EN_CHANGE(IDC_HOS_SETTING_VALUE, OnReevaluate)
78 END_MESSAGE_MAP()
79 
80 // CHosSettingDlg message handlers
81 
82 //----------------------------------------------------------------------
88 //----------------------------------------------------------------------
90 {
91  CDialog::OnInitDialog();
92 
93  //initialize controls
94  CString title;
95  title.LoadString( mTitleStringId );
96  SetWindowText( title );
97 
98  CString label;
99  label.LoadString( mValueLabelStringId );
100  GetDlgItem( IDC_HOS_SETTING_VALUE_LABEL )->SetWindowText( label );
101 
102  CString units;
103  units.LoadString( mValueUnitStringId );
104  GetDlgItem( IDC_HOS_SETTING_VALUE_UNIT )->SetWindowText( units );
105 
106  return TRUE;
107 }
108 
109 //----------------------------------------------------------------------
112 //----------------------------------------------------------------------
114  {
115  UpdateData();
116 
117  if( 0 == ((CButton*)GetDlgItem( IDC_ENABLE_YES ))->GetCheck() &&
118  0 == ((CButton*)GetDlgItem( IDC_ENABLE_NO ))->GetCheck() )
119  {
120  GetDlgItem( IDOK )->EnableWindow( FALSE );
121  return;
122  }
123  if( 0 != ((CButton*)GetDlgItem( IDC_ENABLE_NO ))->GetCheck() )
124  {
125  GetDlgItem( IDC_HOS_SETTING_VALUE )->EnableWindow( FALSE );
126  }
127  else
128  {
129  GetDlgItem( IDC_HOS_SETTING_VALUE )->EnableWindow();
130  if( 0 == mValue.GetLength() ||
131  mValueUpperLimit < _tcstol( mValue, NULL, 10 ) ||
132  mValueLowerLimit > _tcstol( mValue, NULL, 10 ) )
133  {
134  GetDlgItem( IDOK )->EnableWindow( FALSE );
135  return;
136  }
137  }
138 
139  GetDlgItem( IDOK )->EnableWindow();
140  }
141 
142 #endif
Form for individually capturing general HOS settings.
virtual ~CHosSettingDlg()
CHosSettingDlg(CWnd *pParent)
Constructor.
BOOL OnInitDialog()
Initialize the dialog.
#define FALSE
Definition: garmin_types.h:46
#define IDC_ENABLE_YES
Definition: resource.h:448
long mValueLowerLimit
Field value lower limit.
#define TRUE
Definition: garmin_types.h:45
#define IDC_HOS_SETTING_VALUE
Definition: resource.h:450
UINT mValueLabelStringId
Resource ID for the value field label.
#define IDC_ENABLE_NO
Definition: resource.h:449
UINT mTitleStringId
Resource ID for the window title.
UINT mValueUnitStringId
Resource ID for the value field units label.
unsigned short int uint16
16-bit unsigned integer
Definition: garmin_types.h:64
afx_msg void OnReevaluate()
Change handler for editable controls.
BOOL mDisabled
Control value representing radio button for enable/disable.
#define IDC_HOS_SETTING_VALUE_LABEL
Definition: resource.h:478
long mValueUpperLimit
Field value upper limit.
#define IDC_HOS_SETTING_VALUE_UNIT
Definition: resource.h:481
virtual void DoDataExchange(CDataExchange *pDX)
CString mValue
Control value representing the HOS setting&#39;s value.