PageMaskedEdit.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:22k
源码类别:

界面编程

开发平台:

Visual C++

  1. // PageMaskedEdit.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "profuis_controls.h"
  5. #include "PageMaskedEdit.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. #if (!defined __EXT_MFC_NO_GRIDWND )
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CPageMaskedEdit dialog
  14. CPageMaskedEdit::CPageMaskedEdit(CWnd* pParent /*=NULL*/)
  15. : CPageBase(CPageMaskedEdit::IDD, pParent)
  16. , m_bInitComplete( false )
  17. {
  18. //{{AFX_DATA_INIT(CPageMaskedEdit)
  19. //}}AFX_DATA_INIT
  20. m_wndRuleGrid.m_pEditWithBehaviorWnd = &m_editTextMaskedRich;
  21. SetAutoSubclassChildControls();
  22. }
  23. void CPageMaskedEdit::DoDataExchange(CDataExchange* pDX)
  24. {
  25. CPageBase::DoDataExchange(pDX);
  26. //{{AFX_DATA_MAP(CPageMaskedEdit)
  27. DDX_Control(pDX, IDC_CHECK_MODE_NULLABLE, m_checkModeNullable);
  28. DDX_Control(pDX, IDC_CHECK_MODE_INSERT, m_checkModeInsert);
  29. DDX_Control(pDX, IDC_CHECK_MODE_FIELD_SELECTION, m_checkModeFieldSelection);
  30. DDX_Control(pDX, IDC_MASKED_TEXT_EDIT_SIMPLE, m_editTextMaskedSimple);
  31. DDX_Control(pDX, IDC_MASKED_TEXT_EDIT_RICH, m_editTextMaskedRich);
  32. DDX_Control(pDX, IDC_CHECK_USE_RICH_EDIT, m_checkUseMaskedRichEdit);
  33. //}}AFX_DATA_MAP
  34. DDX_Control(pDX, IDC_RULE_GRID, m_wndRuleGrid);
  35. }
  36. BEGIN_MESSAGE_MAP(CPageMaskedEdit, CPageBase)
  37. //{{AFX_MSG_MAP(CPageMaskedEdit)
  38. ON_BN_CLICKED(IDC_CHECK_USE_RICH_EDIT, OnUseMaskedRichEdit)
  39. ON_BN_CLICKED(ID_CHAR_RULE_ADD, OnCharRuleAdd)
  40. ON_BN_CLICKED(ID_CHAR_RULE_REMOVE, OnCharRuleRemove)
  41. ON_EN_CHANGE(IDC_EDIT_MASK, OnChangeEditMask)
  42. ON_BN_CLICKED(ID_CHAR_RULE_RESET_ALL, OnCharRuleResetAll)
  43. ON_BN_CLICKED(IDC_CHECK_MODE_FIELD_SELECTION, OnOptionChanged)
  44. ON_BN_CLICKED(IDC_CHECK_MODE_INSERT, OnOptionChanged)
  45. ON_BN_CLICKED(IDC_CHECK_MODE_NULLABLE, OnOptionChanged)
  46. ON_EN_CHANGE(IDC_EDIT_NULL_CHAR, OnOptionChanged)
  47. ON_EN_SETFOCUS(IDC_EDIT_NULL_CHAR, OnSetfocusEditNullChar)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CPageMaskedEdit message handlers
  52. BOOL CPageMaskedEdit::OnInitDialog() 
  53. {
  54. CPageBase::OnInitDialog();
  55. static TCHAR g_strInitMask[] = _T("($)$$ z$$$$-$$$$ ($$y$$)");
  56. GetDlgItem(IDC_EDIT_MASK)->SetWindowText( g_strInitMask );
  57. m_editTextMaskedRich.MaskSet( LPCTSTR(g_strInitMask) );
  58. m_editTextMaskedSimple.MaskSet( LPCTSTR(g_strInitMask) );
  59. m_checkModeNullable.SetCheck( m_editTextMaskedRich.NullableModeGet() ? 1 : 0 );
  60. m_checkModeInsert.SetCheck( m_editTextMaskedRich.InsertModeGet() ? 1 : 0 );
  61. m_checkModeFieldSelection.SetCheck( m_editTextMaskedRich.FieldSelectionModeGet() ? 1 : 0 );
  62. TCHAR strNullChar[2] = { m_editTextMaskedRich.NullCharGet(), _T('') };
  63. GetDlgItem( IDC_EDIT_NULL_CHAR )->SetWindowText( strNullChar );
  64. ((CEdit*)GetDlgItem( IDC_EDIT_NULL_CHAR ))->SetSel( 0, -1 );
  65. AddAnchor( IDC_MASKED_TEXT_EDIT_SIMPLE, __RDA_LT, __RDA_RT );
  66. AddAnchor( IDC_MASKED_TEXT_EDIT_RICH, __RDA_LT, __RDA_RT );
  67. AddAnchor( IDC_EDIT_MASK, __RDA_LT, __RDA_RT );
  68. AddAnchor( IDC_RULE_GRID, __RDA_LT, __RDA_RB );
  69. AddAnchor( ID_CHAR_RULE_ADD, __RDA_RT );
  70. AddAnchor( ID_CHAR_RULE_REMOVE, __RDA_RT );
  71. AddAnchor( ID_CHAR_RULE_RESET_ALL, __RDA_RT );
  72. AddAnchor( IDC_STATIC_MASKED_EDIT_OPTIONS, __RDA_LB );
  73. AddAnchor( IDC_STATIC_MASKED_EDIT_NULL_CHAR, __RDA_LB );
  74. AddAnchor( IDC_CHECK_MODE_INSERT, __RDA_LB );
  75. AddAnchor( IDC_CHECK_MODE_NULLABLE, __RDA_LB );
  76. AddAnchor( IDC_CHECK_MODE_FIELD_SELECTION, __RDA_LB );
  77. AddAnchor( IDC_EDIT_NULL_CHAR, __RDA_LB );
  78. m_wndRuleGrid.RuleResetAll();
  79. m_checkUseMaskedRichEdit.SetCheck( 1 );
  80. m_bInitComplete = true;
  81. OnUseMaskedRichEdit();
  82. return TRUE;
  83. }
  84. void CPageMaskedEdit::OnCharRuleAdd() 
  85. {
  86. CExtEditWithBehavior::CBehaviorMasked::CharRule _cr( RGB(144,144,144), _T('?'), NULL, NULL );
  87. m_wndRuleGrid.RuleAdd( true, _cr, NULL, NULL );
  88. }
  89. void CPageMaskedEdit::OnCharRuleRemove() 
  90. {
  91. m_wndRuleGrid.RuleRemove();
  92. }
  93. void CPageMaskedEdit::OnChangeEditMask() 
  94. {
  95. CString strMask;
  96. GetDlgItem(IDC_EDIT_MASK)->GetWindowText( strMask );
  97. m_editTextMaskedRich.MaskSet( LPCTSTR(strMask) );
  98. m_editTextMaskedSimple.MaskSet( LPCTSTR(strMask) );
  99. }
  100. void CPageMaskedEdit::OnCharRuleResetAll() 
  101. {
  102. m_wndRuleGrid.RuleResetAll();
  103. }
  104. void CPageMaskedEdit::OnOptionChanged() 
  105. {
  106. m_editTextMaskedRich  .NullableModeSet( m_checkModeNullable.GetCheck() ? true : false );
  107. m_editTextMaskedSimple.NullableModeSet( m_checkModeNullable.GetCheck() ? true : false );
  108. m_editTextMaskedRich  .InsertModeSet( m_checkModeInsert.GetCheck() ? true : false );
  109. m_editTextMaskedSimple.InsertModeSet( m_checkModeInsert.GetCheck() ? true : false );
  110. m_editTextMaskedRich  .FieldSelectionModeSet( m_checkModeFieldSelection.GetCheck() ? true : false );
  111. m_editTextMaskedSimple.FieldSelectionModeSet( m_checkModeFieldSelection.GetCheck() ? true : false );
  112. CString strNullChar1, strNullChar2;
  113. GetDlgItem( IDC_EDIT_NULL_CHAR )->GetWindowText( strNullChar1 );
  114. strNullChar2 = strNullChar1;
  115. strNullChar2.TrimLeft( _T(" rnt") );
  116. strNullChar2.TrimRight( _T(" rnt") );
  117. if( strNullChar2.GetLength() != 1 )
  118. strNullChar2 = _T("_");
  119. if( strNullChar1 != strNullChar2 )
  120. GetDlgItem( IDC_EDIT_NULL_CHAR )->SetWindowText( strNullChar2 );
  121. m_editTextMaskedRich  .NullCharSet( strNullChar2.GetAt( 0 ) );
  122. m_editTextMaskedSimple.NullCharSet( strNullChar2.GetAt( 0 ) );
  123. m_editTextMaskedRich  .SetWindowText( _T("") );
  124. m_editTextMaskedSimple.SetWindowText( _T("") );
  125. m_editTextMaskedRich  .OnCheckText( true );
  126. m_editTextMaskedSimple.OnCheckText( true );
  127. ((CEdit*)GetDlgItem( IDC_EDIT_NULL_CHAR ))->SetSel( 0, -1 );
  128. }
  129. void CPageMaskedEdit::OnSetfocusEditNullChar() 
  130. {
  131. ((CEdit*)GetDlgItem( IDC_EDIT_NULL_CHAR ))->SetSel( 0, -1 );
  132. }
  133. void CPageMaskedEdit::OnUseMaskedRichEdit()
  134. {
  135. int nStart, nEnd;
  136. CString str;
  137. if( m_checkUseMaskedRichEdit.GetCheck() != 0 )
  138. {
  139. m_editTextMaskedRich.ShowWindow( SW_SHOW );
  140. m_editTextMaskedSimple.ShowWindow( SW_HIDE );
  141. m_wndRuleGrid.m_pEditWithBehaviorWnd = &m_editTextMaskedRich;
  142. m_wndRuleGrid.OnRuleSetChanged();
  143. m_editTextMaskedSimple.GetWindowText( str );
  144. m_editTextMaskedRich  .SetWindowText( LPCTSTR(str) );
  145. m_editTextMaskedSimple.GetSel( nStart, nEnd );
  146. m_editTextMaskedRich  .SetSel( nStart, nEnd );
  147. }
  148. else
  149. {
  150. m_editTextMaskedRich.ShowWindow( SW_HIDE );
  151. m_editTextMaskedSimple.ShowWindow( SW_SHOW );
  152. m_wndRuleGrid.m_pEditWithBehaviorWnd = &m_editTextMaskedSimple;
  153. m_wndRuleGrid.OnRuleSetChanged();
  154. m_editTextMaskedRich  .GetWindowText( str );
  155. m_editTextMaskedSimple.SetWindowText( LPCTSTR(str) );
  156. m_editTextMaskedRich  .GetSel( nStart, nEnd );
  157. m_editTextMaskedSimple.SetSel( nStart, nEnd );
  158. }
  159. }
  160. #endif // (!defined __EXT_MFC_NO_GRIDWND )
  161. /////////////////////////////////////////////////////////////////////////////
  162. // CPageSystemNumberCurrencyEditors dialog
  163. CPageSystemNumberCurrencyEditors::CPageSystemNumberCurrencyEditors(CWnd* pParent /*=NULL*/)
  164. : CPageBase( CPageSystemNumberCurrencyEditors::IDD, pParent )
  165. , m_bInitComplete( false )
  166. {
  167. //{{AFX_DATA_INIT(CPageSystemNumberCurrencyEditors)
  168. //}}AFX_DATA_INIT
  169. SetAutoSubclassChildControls();
  170. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_NUMBER );
  171. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_FRACTION );
  172. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_SIGN );
  173. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_BRACKETS );
  174. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_SEPARATOR_GROUP );
  175. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_SEPARATOR_DECIMAL );
  176. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_DEFAULT_TEXT );
  177. m_listColorButtonIDs.AddTail( IDC_BUTTON_COLOR_DEFAULT_BACK );
  178. }
  179. void CPageSystemNumberCurrencyEditors::DoDataExchange(CDataExchange* pDX)
  180. {
  181. CPageBase::DoDataExchange(pDX);
  182. //{{AFX_DATA_MAP(CPageSystemNumberCurrencyEditors)
  183. DDX_Control(pDX, IDC_CHECK_USE_RICH_EDIT, m_checkUseRichEditors);
  184. DDX_Control(pDX, IDC_EDIT_SYSTEM_NUMBER_SIMPLE, m_editSystemNumberSimple);
  185. DDX_Control(pDX, IDC_EDIT_SYSTEM_NUMBER_RICH, m_editSystemNumberRich);
  186. DDX_Control(pDX, IDC_STATIC_VALUE_OF_SYSTEM_NUMBER, m_labelValueOfSystemNumberEditor);
  187. DDX_Control(pDX, IDC_EDIT_SYSTEM_CURRENCY_SIMPLE, m_editSystemCurrencySimple);
  188. DDX_Control(pDX, IDC_EDIT_SYSTEM_CURRENCY_RICH, m_editSystemCurrencyRich);
  189. DDX_Control(pDX, IDC_STATIC_VALUE_OF_SYSTEM_CURRENCY, m_labelValueOfSystemCurrencyEditor);
  190. DDX_Control(pDX, IDC_EDIT_MAX_WHOLE_DIGITS, m_editMaxWholeDigits);
  191. DDX_Control(pDX, IDC_SPIN_MAX_WHOLE_DIGITS, m_spinMaxWholeDigits);
  192. DDX_Control(pDX, IDC_EDIT_MAX_FRACTION_DIGITS, m_editMaxFractionDigits);
  193. DDX_Control(pDX, IDC_SPIN_MAX_FRACTION_DIGITS, m_spinMaxFractionDigits);
  194. DDX_Control(pDX, IDC_CHECK_CAN_BE_NEGATIVE, m_checkCanBeNegative);
  195. DDX_Control(pDX, IDC_BUTTON_COLOR_NUMBER, m_buttonColorNumber);
  196. DDX_Control(pDX, IDC_BUTTON_COLOR_FRACTION, m_buttonColorFraction);
  197. DDX_Control(pDX, IDC_BUTTON_COLOR_SIGN, m_buttonColorSign);
  198. DDX_Control(pDX, IDC_BUTTON_COLOR_BRACKETS, m_buttonColorBrackets);
  199. DDX_Control(pDX, IDC_BUTTON_COLOR_SEPARATOR_GROUP, m_buttonColorSeparatorGroup);
  200. DDX_Control(pDX, IDC_BUTTON_COLOR_SEPARATOR_DECIMAL, m_buttonColorSeparatorDecimal);
  201. DDX_Control(pDX, IDC_BUTTON_COLOR_DEFAULT_TEXT, m_buttonDefaultText);
  202. DDX_Control(pDX, IDC_BUTTON_COLOR_DEFAULT_BACK, m_buttonDefaultBack);
  203. //}}AFX_DATA_MAP
  204. // DDX_Text( pDX, IDC_EDIT_MAX_WHOLE_DIGITS, m_nTestNumberWholeDigits );
  205. // DDX_Text( pDX, IDC_EDIT_MAX_FRACTION_DIGITS, m_nTestNumberFractionDigits );
  206. }
  207. BEGIN_MESSAGE_MAP(CPageSystemNumberCurrencyEditors, CPageBase)
  208. //{{AFX_MSG_MAP(CPageSystemNumberCurrencyEditors)
  209. ON_BN_CLICKED(IDC_CHECK_USE_RICH_EDIT, OnCheckUseRichEditors)
  210. ON_EN_CHANGE(IDC_EDIT_SYSTEM_NUMBER_SIMPLE, OnChangeEditSystemNumberSimple)
  211. ON_EN_CHANGE(IDC_EDIT_SYSTEM_NUMBER_RICH, OnChangeEditSystemNumberRich)
  212. ON_EN_CHANGE(IDC_EDIT_SYSTEM_CURRENCY_SIMPLE, OnChangeEditSystemCurrencySimple)
  213. ON_EN_CHANGE(IDC_EDIT_SYSTEM_CURRENCY_RICH, OnChangeEditSystemCurrencyRich)
  214. ON_EN_CHANGE(IDC_EDIT_MAX_WHOLE_DIGITS, OnChangeMaxWholeDigits)
  215. ON_EN_CHANGE(IDC_EDIT_MAX_FRACTION_DIGITS, OnChangeMaxFractionDigits)
  216. ON_BN_CLICKED(IDC_CHECK_CAN_BE_NEGATIVE, OnCheckCanBeNegative)
  217. ON_BN_CLICKED(IDC_BUTTON_CHANGE_WINDOWS_LOCALE_SETTINGS, OnChangeWindowsLocaleSettings)
  218. //}}AFX_MSG_MAP
  219. ON_REGISTERED_MESSAGE(
  220. CExtPopupColorMenuWnd::g_nMsgNotifyColorChangedFinally,
  221. OnColorChangedFinally
  222. )
  223. ON_REGISTERED_MESSAGE(
  224. CExtPopupColorMenuWnd::g_nMsgNotifyCustColor,
  225. OnColorSelectCustom
  226. )
  227. END_MESSAGE_MAP()
  228. /////////////////////////////////////////////////////////////////////////////
  229. // CPageSystemNumberCurrencyEditors message handlers
  230. BOOL CPageSystemNumberCurrencyEditors::OnInitDialog() 
  231. {
  232. CPageBase::OnInitDialog();
  233. POSITION pos;
  234. for( pos = m_listColorButtonIDs.GetHeadPosition(); pos != NULL; )
  235. {
  236. UINT nID = m_listColorButtonIDs.GetNext( pos );
  237. CExtColorButton * pColorButton = DYNAMIC_DOWNCAST( CExtColorButton, GetDlgItem( nID ) );
  238. ASSERT_VALID( pColorButton );
  239. pColorButton->m_clrDefault = COLORREF(-1L);
  240. pColorButton->m_lParamCookie = LPARAM(nID);
  241. }
  242. m_buttonColorNumber.m_clrSelected = RGB(0,0,164);
  243. m_buttonColorFraction.m_clrSelected = RGB(0,164,0);
  244. m_buttonColorSign.m_clrSelected = RGB(164,0,0);
  245. m_buttonColorBrackets.m_clrSelected = RGB(128,128,128);
  246. m_buttonColorSeparatorGroup.m_clrSelected = RGB(164,164,164);
  247. m_buttonColorSeparatorDecimal.m_clrSelected = RGB(164,0,0);
  248. m_buttonDefaultText.m_clrSelected = RGB(0,0,0);
  249. m_buttonDefaultBack.m_clrSelected = RGB(255,255,255);
  250. m_checkUseRichEditors.SetCheck( 1 );
  251. m_checkCanBeNegative.SetCheck( 1 );
  252. m_spinMaxWholeDigits.SetRange( 1, 15 );
  253. m_spinMaxFractionDigits.SetRange( 0, 20 );
  254. CString str;
  255. str.Format( _T("%d"), m_editSystemNumberSimple.MaxWholeDigitsGet() );
  256. m_editMaxWholeDigits.SetWindowText( LPCTSTR(str) );
  257. str.Format( _T("%d"), m_editSystemNumberSimple.MaxFractionDigitsGet() );
  258. m_editMaxFractionDigits.SetWindowText( LPCTSTR(str) );
  259. AddAnchor( IDC_EDIT_SYSTEM_NUMBER_SIMPLE, __RDA_LT, __RDA_RT );
  260. AddAnchor( IDC_EDIT_SYSTEM_NUMBER_RICH, __RDA_LT, __RDA_RT );
  261. AddAnchor( IDC_EDIT_SYSTEM_CURRENCY_SIMPLE, __RDA_LT, __RDA_RT );
  262. AddAnchor( IDC_EDIT_SYSTEM_CURRENCY_RICH, __RDA_LT, __RDA_RT );
  263. AddAnchor( IDC_STATIC_VALUE_OF_SYSTEM_NUMBER, __RDA_RT );
  264. AddAnchor( IDC_STATIC_VALUE_OF_SYSTEM_CURRENCY, __RDA_RT );
  265. AddAnchor( IDC_STATIC_ETCHED_LINE_00, __RDA_LT, __RDA_RT );
  266. AddAnchor( IDC_STATIC_ETCHED_LINE_01, __RDA_LT, __RDA_RT );
  267. AddAnchor( IDC_STATIC_ETCHED_LINE_02, __RDA_LT, __RDA_RT );
  268. m_bInitComplete = true;
  269. OnCheckUseRichEditors();
  270. OnCheckCanBeNegative();
  271. OnChangeMaxWholeDigits();
  272. OnChangeMaxFractionDigits();
  273. for( pos = m_listColorButtonIDs.GetHeadPosition(); pos != NULL; )
  274. {
  275. UINT nID = m_listColorButtonIDs.GetNext( pos );
  276. CExtColorButton * pColorButton = DYNAMIC_DOWNCAST( CExtColorButton, GetDlgItem( nID ) );
  277. ASSERT_VALID( pColorButton );
  278. OnColorChangedFinally( (WPARAM)pColorButton->m_clrSelected, (LPARAM)pColorButton->m_lParamCookie );
  279. }
  280. _SyncValueOfNumber();
  281. _SyncValueOfCurrency();
  282. return TRUE;
  283. }
  284. void CPageSystemNumberCurrencyEditors::OnCheckUseRichEditors()
  285. {
  286. if( ! m_bInitComplete )
  287. return;
  288. int nStart, nEnd;
  289. CString str;
  290. bool bUseRichEditors = ( m_checkUseRichEditors.GetCheck() != 0 ) ? true : false;
  291. if( bUseRichEditors )
  292. {
  293. m_editSystemNumberRich.ShowWindow( SW_SHOW );
  294. m_editSystemNumberSimple.ShowWindow( SW_HIDE );
  295. m_editSystemNumberSimple.GetWindowText( str );
  296. m_editSystemNumberRich  .SetWindowText( LPCTSTR(str) );
  297. m_editSystemNumberSimple.GetSel( nStart, nEnd );
  298. m_editSystemNumberRich  .SetSel( nStart, nEnd );
  299. m_editSystemCurrencyRich.ShowWindow( SW_SHOW );
  300. m_editSystemCurrencySimple.ShowWindow( SW_HIDE );
  301. m_editSystemCurrencySimple.GetWindowText( str );
  302. m_editSystemCurrencyRich  .SetWindowText( LPCTSTR(str) );
  303. m_editSystemCurrencySimple.GetSel( nStart, nEnd );
  304. m_editSystemCurrencyRich  .SetSel( nStart, nEnd );
  305. }
  306. else
  307. {
  308. m_editSystemNumberRich.ShowWindow( SW_HIDE );
  309. m_editSystemNumberSimple.ShowWindow( SW_SHOW );
  310. m_editSystemNumberRich  .GetWindowText( str );
  311. m_editSystemNumberSimple.SetWindowText( LPCTSTR(str) );
  312. m_editSystemNumberRich  .GetSel( nStart, nEnd );
  313. m_editSystemNumberSimple.SetSel( nStart, nEnd );
  314. m_editSystemCurrencyRich.ShowWindow( SW_HIDE );
  315. m_editSystemCurrencySimple.ShowWindow( SW_SHOW );
  316. m_editSystemCurrencyRich  .GetWindowText( str );
  317. m_editSystemCurrencySimple.SetWindowText( LPCTSTR(str) );
  318. m_editSystemCurrencyRich  .GetSel( nStart, nEnd );
  319. m_editSystemCurrencySimple.SetSel( nStart, nEnd );
  320. }
  321. POSITION pos;
  322. for( pos = m_listColorButtonIDs.GetHeadPosition(); pos != NULL; )
  323. {
  324. UINT nID = m_listColorButtonIDs.GetNext( pos );
  325. CExtColorButton * pColorButton = DYNAMIC_DOWNCAST( CExtColorButton, GetDlgItem( nID ) );
  326. ASSERT_VALID( pColorButton );
  327. pColorButton->EnableWindow( bUseRichEditors ? TRUE : FALSE );
  328. }
  329. }
  330. void CPageSystemNumberCurrencyEditors::_SyncFrom( CExtEditSystemNumberCurrencyBase * pWndEditSyncFrom )
  331. {
  332. ASSERT_VALID( pWndEditSyncFrom );
  333. ASSERT( pWndEditSyncFrom->GetSafeHwnd() != NULL );
  334. if( ! m_bInitComplete )
  335. return;
  336. m_bInitComplete = false;
  337. CExtEditSystemNumberCurrencyBase * arrEditors[ 4 ] =
  338. {
  339. &m_editSystemNumberSimple,
  340. &m_editSystemNumberRich,
  341. &m_editSystemCurrencySimple,
  342. &m_editSystemCurrencyRich,
  343. };
  344. long double lfVal = pWndEditSyncFrom->LongDoubleGet();
  345. INT nIndex, nCount = INT( sizeof(arrEditors) / sizeof(arrEditors[0]) );
  346. for( nIndex = 0; nIndex < nCount; nIndex ++ )
  347. {
  348. CExtEditSystemNumberCurrencyBase * pWndEdit = arrEditors[ nIndex ];
  349. ASSERT_VALID( pWndEdit );
  350. ASSERT( pWndEdit->GetSafeHwnd() != NULL );
  351. if( LPVOID(pWndEdit) == LPVOID(pWndEditSyncFrom) )
  352. continue;
  353. pWndEdit->LongDoubleSet( lfVal );
  354. }
  355. m_bInitComplete = true;
  356. _SyncValueOfNumber();
  357. _SyncValueOfCurrency();
  358. }
  359. void CPageSystemNumberCurrencyEditors::_SyncValueOfNumber()
  360. {
  361. ASSERT( m_editSystemNumberSimple.GetSafeHwnd() != NULL );
  362. ASSERT( m_editSystemNumberRich.GetSafeHwnd() != NULL );
  363. ASSERT( m_labelValueOfSystemNumberEditor.GetSafeHwnd() != NULL );
  364. CExtEditSystemNumber & wndEdit =
  365. ( ( m_editSystemNumberSimple.GetStyle() & WS_VISIBLE ) != 0 )
  366. ? m_editSystemNumberSimple : m_editSystemNumberRich;
  367. long double lfVal = wndEdit.LongDoubleGet();
  368. CString strText;
  369. strText.Format( _T("%le"), lfVal );
  370. m_labelValueOfSystemNumberEditor.SetWindowText( LPCTSTR(strText) );
  371. }
  372. void CPageSystemNumberCurrencyEditors::_SyncValueOfCurrency()
  373. {
  374. ASSERT( m_editSystemCurrencySimple.GetSafeHwnd() != NULL );
  375. ASSERT( m_editSystemCurrencyRich.GetSafeHwnd() != NULL );
  376. ASSERT( m_labelValueOfSystemCurrencyEditor.GetSafeHwnd() != NULL );
  377. CExtEditSystemCurrency & wndEdit =
  378. ( ( m_editSystemCurrencySimple.GetStyle() & WS_VISIBLE ) != 0 )
  379. ? m_editSystemCurrencySimple : m_editSystemCurrencyRich;
  380. long double lfVal = wndEdit.LongDoubleGet();
  381. CString strText;
  382. strText.Format( _T("%e"), lfVal );
  383. m_labelValueOfSystemCurrencyEditor.SetWindowText( LPCTSTR(strText) );
  384. }
  385. void CPageSystemNumberCurrencyEditors::OnChangeEditSystemNumberSimple()
  386. {
  387. _SyncFrom( &m_editSystemNumberSimple );
  388. }
  389. void CPageSystemNumberCurrencyEditors::OnChangeEditSystemNumberRich()
  390. {
  391. _SyncFrom( &m_editSystemNumberRich );
  392. }
  393. void CPageSystemNumberCurrencyEditors::OnChangeEditSystemCurrencySimple()
  394. {
  395. _SyncFrom( &m_editSystemCurrencySimple );
  396. }
  397. void CPageSystemNumberCurrencyEditors::OnChangeEditSystemCurrencyRich()
  398. {
  399. _SyncFrom( &m_editSystemCurrencyRich );
  400. }
  401. void CPageSystemNumberCurrencyEditors::OnChangeMaxWholeDigits()
  402. {
  403. if( ! m_bInitComplete )
  404. return;
  405. CString str;
  406. m_editMaxWholeDigits.GetWindowText( str );
  407. INT nVal = (INT)_ttol( LPCTSTR(str) );
  408. INT nValSrc = nVal;
  409. nVal = max( nVal, 1 );
  410. nVal = min( nVal, 15 );
  411. if( nValSrc != nVal )
  412. {
  413. str.Format( _T("%d"), nVal );
  414. m_editMaxWholeDigits.SetWindowText( LPCTSTR(str) );
  415. m_editMaxWholeDigits.SetSel( 0, -1 );
  416. }
  417. m_editSystemNumberSimple  .MaxWholeDigitsSet( nVal );
  418. m_editSystemNumberRich    .MaxWholeDigitsSet( nVal );
  419. m_editSystemCurrencySimple.MaxWholeDigitsSet( nVal );
  420. m_editSystemCurrencyRich  .MaxWholeDigitsSet( nVal );
  421. }
  422. void CPageSystemNumberCurrencyEditors::OnChangeMaxFractionDigits()
  423. {
  424. if( ! m_bInitComplete )
  425. return;
  426. CString str;
  427. m_editMaxFractionDigits.GetWindowText( str );
  428. INT nVal = (INT)_ttol( LPCTSTR(str) );
  429. INT nValSrc = nVal;
  430. nVal = max( nVal, 0 );
  431. nVal = min( nVal, 20 );
  432. if( nValSrc != nVal )
  433. {
  434. str.Format( _T("%d"), nVal );
  435. m_editMaxFractionDigits.SetWindowText( LPCTSTR(str) );
  436. m_editMaxFractionDigits.SetSel( 0, -1 );
  437. }
  438. m_editSystemNumberSimple  .MaxFractionDigitsSet( nVal );
  439. m_editSystemNumberRich    .MaxFractionDigitsSet( nVal );
  440. m_editSystemCurrencySimple.MaxFractionDigitsSet( nVal );
  441. m_editSystemCurrencyRich  .MaxFractionDigitsSet( nVal );
  442. }
  443. void CPageSystemNumberCurrencyEditors::OnCheckCanBeNegative()
  444. {
  445. if( ! m_bInitComplete )
  446. return;
  447. bool bAllowNegative = ( m_checkCanBeNegative.GetCheck() != 0 ) ? true : false;
  448. m_editSystemNumberSimple  .AllowNegativeSet( bAllowNegative );
  449. m_editSystemNumberRich    .AllowNegativeSet( bAllowNegative );
  450. m_editSystemCurrencySimple.AllowNegativeSet( bAllowNegative );
  451. m_editSystemCurrencyRich  .AllowNegativeSet( bAllowNegative );
  452. }
  453. LRESULT CPageSystemNumberCurrencyEditors::OnColorChangedFinally( WPARAM wParam, LPARAM lParam )
  454. {
  455. UINT nID = UINT(lParam);
  456. if( m_listColorButtonIDs.Find( nID ) == NULL )
  457. return 0L;
  458. COLORREF clr = COLORREF(wParam);
  459. switch( nID )
  460. {
  461. case IDC_BUTTON_COLOR_NUMBER:
  462. m_editSystemNumberRich  .NumberColorSet( clr );
  463. m_editSystemCurrencyRich.NumberColorSet( clr );
  464. break;
  465. case IDC_BUTTON_COLOR_FRACTION:
  466. m_editSystemNumberRich  .FractionColorSet( clr );
  467. m_editSystemCurrencyRich.FractionColorSet( clr );
  468. break;
  469. case IDC_BUTTON_COLOR_SIGN:
  470. m_editSystemNumberRich  .SignColorSet( clr );
  471. m_editSystemCurrencyRich.SignColorSet( clr );
  472. break;
  473. case IDC_BUTTON_COLOR_BRACKETS:
  474. m_editSystemNumberRich  .BracketsColorSet( clr );
  475. m_editSystemCurrencyRich.BracketsColorSet( clr );
  476. break;
  477. case IDC_BUTTON_COLOR_SEPARATOR_GROUP:
  478. m_editSystemNumberRich  .GroupSeparatorColorSet( clr );
  479. m_editSystemCurrencyRich.GroupSeparatorColorSet( clr );
  480. break;
  481. case IDC_BUTTON_COLOR_SEPARATOR_DECIMAL:
  482. m_editSystemNumberRich  .DecimalSeparatorColorSet( clr );
  483. m_editSystemCurrencyRich.DecimalSeparatorColorSet( clr );
  484. break;
  485. case IDC_BUTTON_COLOR_DEFAULT_TEXT:
  486. m_editSystemNumberRich  .m_clrRichTextNormal = clr;
  487. m_editSystemCurrencyRich.m_clrRichTextNormal = clr;
  488. m_editSystemNumberRich  ._Rich_OnDraw();
  489. m_editSystemCurrencyRich._Rich_OnDraw();
  490. break;
  491. case IDC_BUTTON_COLOR_DEFAULT_BACK:
  492. m_editSystemNumberRich  .m_clrRichBackNormal = clr;
  493. m_editSystemCurrencyRich.m_clrRichBackNormal = clr;
  494. m_editSystemNumberRich  ._Rich_OnDraw();
  495. m_editSystemCurrencyRich._Rich_OnDraw();
  496. break;
  497. } // switch( nID )
  498. return 0L;
  499. }
  500. LRESULT CPageSystemNumberCurrencyEditors::OnColorSelectCustom( WPARAM wParam, LPARAM lParam )
  501. {
  502. wParam;
  503. UINT nID = UINT(lParam);
  504. if( m_listColorButtonIDs.Find( nID ) == NULL )
  505. return 0L;
  506. CExtColorDlg dlgColor;
  507. dlgColor.m_strSection = _T("ColorDialog");
  508. dlgColor.m_strEntryDialogPosition = _T("Position");
  509. dlgColor.m_strEntryColorModelSelection = _T("ColorModel");
  510. switch( nID )
  511. {
  512. case IDC_BUTTON_COLOR_NUMBER:
  513. dlgColor.m_strCaption = _T("Number Color");
  514. break;
  515. case IDC_BUTTON_COLOR_FRACTION:
  516. dlgColor.m_strCaption = _T("Fraction Color");
  517. break;
  518. case IDC_BUTTON_COLOR_SIGN:
  519. dlgColor.m_strCaption = _T("Sign Color");
  520. break;
  521. case IDC_BUTTON_COLOR_BRACKETS:
  522. dlgColor.m_strCaption = _T("Brackets Color");
  523. break;
  524. case IDC_BUTTON_COLOR_SEPARATOR_GROUP:
  525. dlgColor.m_strCaption = _T("Group Separator Color");
  526. break;
  527. case IDC_BUTTON_COLOR_SEPARATOR_DECIMAL:
  528. dlgColor.m_strCaption = _T("Decimal Separator Color");
  529. break;
  530. case IDC_BUTTON_COLOR_DEFAULT_TEXT:
  531. dlgColor.m_strCaption = _T("Default Text Color");
  532. break;
  533. case IDC_BUTTON_COLOR_DEFAULT_BACK:
  534. dlgColor.m_strCaption = _T("Default Background Color");
  535. break;
  536. } // switch( nID )
  537. if( dlgColor.DoModal() != IDOK )
  538. return 0;
  539. OnColorChangedFinally( (WPARAM)dlgColor.m_clrNew, lParam );
  540. return 0L;
  541. }
  542. void CPageSystemNumberCurrencyEditors::OnChangeWindowsLocaleSettings()
  543. {
  544. ::ShellExecute(
  545. ::GetDesktopWindow(), // GetParent()->GetSafeHwnd(),
  546. g_PaintManager.m_bIsWin2000orLater ? LPCTSTR(NULL) : _T("run"),
  547. _T("intl.cpl"),
  548. NULL,
  549. NULL,
  550. SW_SHOW
  551. );
  552. }