Develop and Download Open Source Software

Browse Subversion Repository

Contents of /WinCS/MasterSettingDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations) (download) (as text)
Wed Feb 10 18:21:00 2010 UTC (14 years, 2 months ago) by sho1get
File MIME type: text/x-c++src
File size: 4519 byte(s)


1 #include "stdafx.h"
2 #include "WinCS.h"
3 #include "MasterSettingDlg.h"
4
5 IMPLEMENT_DYNAMIC(CMasterSettingDlg, CDialog)
6
7 BEGIN_MESSAGE_MAP(CMasterSettingDlg, CDialog)
8 ON_BN_CLICKED(IDOK, &CMasterSettingDlg::OnBnClickedOk)
9 ON_CBN_SELCHANGE(IDC_CMB_MASTER_SETTING_CONNECTION, &CMasterSettingDlg::OnCbnSelchangeCmbConnections)
10 ON_WM_CTLCOLOR()
11 END_MESSAGE_MAP()
12
13 //////////////////////////////////////////////////////////////////////////
14
15 CMasterSettingDlg::CMasterSettingDlg(CWnd* pParent)
16 : CDialog(CMasterSettingDlg::IDD, pParent)
17 {
18 m_hIcon = AfxGetApp()->LoadIcon(IDI_SETTING);
19 m_MasterSetting.fInternet = TRUE;
20 m_MasterSetting.nConnections = UINT_MAX;
21 m_MasterSetting.nProcessors = UINT_MAX;
22 }
23
24 CMasterSettingDlg::~CMasterSettingDlg()
25 {
26 }
27
28 void CMasterSettingDlg::DoDataExchange(CDataExchange* pDX)
29 {
30 CDialog::DoDataExchange(pDX);
31 DDX_Control(pDX, IDC_CMB_MASTER_SETTING_CONNECTION, m_xCmbLimit);
32 DDX_Control(pDX, IDC_EDIT_MASTER_SETTING_COUNT1, m_xEditCount1);
33 DDX_Control(pDX, IDC_CHECK_MASTER_SETTING_INTERNET, m_xCheckInternet);
34 DDX_Control(pDX, IDC_SPIN_MASTER_SETTING_CONNECTION, m_xSpnCount1);
35 DDX_Control(pDX, IDC_SPIN_MASTER_SETTING_PROCESSORS, m_xSpnCount2);
36 DDX_Control(pDX, IDC_EDIT_MASTER_SETTING_COUNT2, m_xEditCount2);
37 DDX_Control(pDX, IDC_TXT_MASTER_SETTING_PROCESSORS, m_xTxtCount);
38 DDX_Control(pDX, IDC_RADIO_MASTER_SETTING_GRAPHICS1, m_xRadioGraphics1);
39 DDX_Control(pDX, IDC_RADIO_MASTER_SETTING_GRAPHICS2, m_xRadioGraphics2);
40 DDX_Control(pDX, IDC_CHECK_MASTER_SETTING_LOG_PLUGIN, m_xCheckPlugin);
41 }
42
43 HBRUSH CMasterSettingDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
44 {
45 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
46 int nCtlID = pWnd->GetDlgCtrlID();
47
48 switch (nCtlID)
49 {
50 case IDC_EDIT_MASTER_SETTING_COUNT2:
51 hbr = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
52 pDC->SetBkColor(RGB(255, 255, 255));
53 break;
54 }
55
56 return hbr;
57 }
58
59 BOOL CMasterSettingDlg::OnInitDialog()
60 {
61 CDialog::OnInitDialog();
62
63 SYSTEM_INFO si;
64 CString cs;
65
66 SetIcon(m_hIcon, TRUE);
67 SetIcon(m_hIcon, FALSE);
68
69 GetSystemInfo(&si);
70 m_dwMaxProcessors = si.dwNumberOfProcessors;
71 cs.Format(_T("Maximum processors: %d"), m_dwMaxProcessors);
72 m_xTxtCount.SetWindowText(cs);
73 m_xCmbLimit.AddString(_T("Unlimited"));
74 m_xCmbLimit.AddString(_T("Limited"));
75 m_xSpnCount1.SetRange32(2, INT_MAX);
76 m_xSpnCount2.SetRange32(1, m_dwMaxProcessors);
77 m_xSpnCount2.SetPos32(m_MasterSetting.nProcessors);
78 m_xRadioGraphics1.SetCheck(m_MasterSetting.fRtRendering ? BST_CHECKED : BST_UNCHECKED);
79 m_xRadioGraphics2.SetCheck(m_MasterSetting.fRtRendering ? BST_UNCHECKED : BST_CHECKED);
80 m_xCheckInternet.SetCheck(m_MasterSetting.fInternet ? BST_CHECKED : BST_UNCHECKED);
81 m_xCheckPlugin.SetCheck(m_MasterSetting.fLogPlugin ? BST_CHECKED : BST_UNCHECKED);
82
83 if (m_MasterSetting.nConnections == UINT_MAX)
84 {
85 m_xCmbLimit.SetCurSel(0);
86 m_xEditCount1.EnableWindow(FALSE);
87 }
88 else
89 {
90 m_xCmbLimit.SetCurSel(1);
91 m_xSpnCount1.SetPos32(m_MasterSetting.nConnections);
92 }
93
94 return TRUE;
95 }
96
97 void CMasterSettingDlg::OnBnClickedOk()
98 {
99 CString cs;
100 BOOL fError;
101 UINT nConnections = UINT_MAX;
102 UINT nProcessors = UINT_MAX;
103 int nIndex;
104
105 nIndex = m_xCmbLimit.GetCurSel();
106
107 if (nIndex == 1)
108 {
109 nConnections = GetDlgItemInt(IDC_EDIT_MASTER_SETTING_COUNT1, &fError, TRUE);
110
111 if (!fError || nConnections < 2)
112 {
113 m_xEditCount1.SetFocus();
114 cs.LoadString(IDS_WCS_ERROR_CONNECTION_LIMIT);
115 AfxMessageBox(cs);
116 return;
117 }
118 }
119
120 nProcessors = GetDlgItemInt(IDC_EDIT_MASTER_SETTING_COUNT2, &fError, TRUE);
121
122 if (!fError || nProcessors < 1 || nProcessors > m_dwMaxProcessors)
123 {
124 m_xEditCount2.SetFocus();
125 cs.LoadString(IDS_WCS_ERROR_PROCESSOR_LIMIT);
126 AfxMessageBox(cs);
127 return;
128 }
129
130 m_MasterSetting.nConnections = nConnections;
131 m_MasterSetting.nProcessors = nProcessors;
132 m_MasterSetting.fInternet = (m_xCheckInternet.GetCheck() == BST_CHECKED);
133 m_MasterSetting.fLogPlugin = (m_xCheckPlugin.GetCheck() == BST_CHECKED);
134 m_MasterSetting.fRtRendering = (m_xRadioGraphics1.GetCheck() == BST_CHECKED);
135
136 OnOK();
137 }
138
139 void CMasterSettingDlg::OnCbnSelchangeCmbConnections()
140 {
141 int nIndex = m_xCmbLimit.GetCurSel();
142
143 if (nIndex == 1)
144 {
145 m_xEditCount1.EnableWindow(TRUE);
146 m_xSpnCount1.SetPos32(50);
147 }
148 else
149 {
150 m_xEditCount1.EnableWindow(FALSE);
151 }
152 }
153
154 //////////////////////////////////////////////////////////////////////////

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26