Account.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. // Account.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Account.h"
  6. #include "MyMdi.H"
  7. #include "SetLeftBar.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. //BOOL CALLBACK EnumChildProc_Accout(HWND hwnd, LPARAM lParam);
  14. /////////////////////////////////////////////////////////////////////////////
  15. // Account IDC_EDIT2
  16. IMPLEMENT_DYNCREATE(Account, MyFormView)
  17. Account::Account(): MyFormView(Account::IDD)
  18. {
  19. //{{AFX_DATA_INIT(Account)
  20. m_account = _T("");
  21. m_psw = _T("");
  22. m_psw2 = _T("");
  23. m_discount = "9.0";
  24. m_bAddNew = 1;
  25. m_discount2 = _T("9.0");
  26. //}}AFX_DATA_INIT
  27. }
  28. Account::~Account()
  29. {
  30. }
  31. void Account::DoDataExchange(CDataExchange* pDX)
  32. {
  33. MyFormView::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(Account)
  35. DDX_Control(pDX, IDC_SPIN1, m_spin1);
  36. DDX_Control(pDX, IDC_COMBOname, m_comboname);
  37. DDX_Control(pDX, IDC_LIST2, m_List1);
  38. DDX_Control(pDX, IDC_STATIC1, m_static1);
  39. DDX_Text(pDX, IDC_EDITaccount, m_account);
  40. DDX_Text(pDX, IDC_EDITpsw, m_psw);
  41. DDX_Text(pDX, IDC_EDITpsw2, m_psw2);
  42. DDX_Text(pDX, IDC_EDIT2, m_discount);
  43. DDX_Text(pDX, IDC_EDIT3, m_discount2);
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(Account, MyFormView)
  47. //{{AFX_MSG_MAP(Account)
  48. ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
  49. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  50. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  51. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  52. ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
  53. ON_BN_CLICKED(IDC_BUTbm1, OnBUTbm1)
  54. ON_BN_CLICKED(IDC_BUTbm6, OnBUTbm6)
  55. ON_BN_CLICKED(IDC_BUTbm2, OnBUTbm2)
  56. ON_BN_CLICKED(IDC_BUTbm3, OnBUTbm3)
  57. ON_BN_CLICKED(IDC_BUTbm4, OnBUTbm4)
  58. ON_BN_CLICKED(IDC_BUTbm5, OnBUTbm5)
  59. ON_BN_CLICKED(IDC_BUTleftbar, OnBUTleftbar)
  60. ON_BN_CLICKED(IDC_CHECK27, OnCheck27)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Account diagnostics
  65. #ifdef _DEBUG
  66. void Account::AssertValid() const
  67. {
  68. MyFormView::AssertValid();
  69. }
  70. void Account::Dump(CDumpContext& dc) const
  71. {
  72. MyFormView::Dump(dc);
  73. }
  74. #endif //_DEBUG
  75. /////////////////////////////////////////////////////////////////////////////
  76. // Account message handlers
  77. void Account::OnInitialUpdate()
  78. {
  79. //AfxMessageBox("用户管理");
  80. MyFormView::OnInitialUpdate();
  81. // TODO: Add your specialized code here and/or call the base class
  82. CMyMdi Mdi;
  83. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  84. #ifdef LKAY_VERSION
  85. GetDlgItem(IDC_CHECK54)->ShowWindow(SW_SHOW);
  86. #endif
  87. #ifdef LYFZ_VERSION
  88. GetDlgItem(IDC_CHECK54)->SetWindowText("明日安排");
  89. GetDlgItem(IDC_CHECK54)->ShowWindow(SW_SHOW);
  90. #endif
  91. #ifdef BASIC_VERSION
  92. GetDlgItem(IDC_BUTleftbar)->ShowWindow(0);
  93. #ifdef BASIC_ADDDRESS
  94. GetDlgItem(IDC_STATIC2)->ShowWindow(1);
  95. GetDlgItem(IDC_CHECK40)->ShowWindow(1);
  96. GetDlgItem(IDC_CHECK41)->ShowWindow(1);
  97. GetDlgItem(IDC_CHECK42)->ShowWindow(1);
  98. GetDlgItem(IDC_CHECK43)->ShowWindow(1);
  99. GetDlgItem(IDC_CHECK44)->ShowWindow(1);
  100. #endif
  101. #endif
  102. #ifdef ENTERPRISE_VERSION
  103. GetDlgItem(IDC_CHECK29)->ShowWindow(1);
  104. #endif
  105. // Here we create the outbar control using the splitter as its parent
  106. // and setting its id to the first pane.
  107. #if 1
  108. CRect rc2;
  109. GetWindowRect(rc2);
  110. // rc2 = m_rct;
  111. //
  112. // CString strRect;
  113. // strRect.Format(_T("%d,%d,%d,%d"),rc2.left,rc2.top,rc2.right,rc2.bottom);
  114. // AfxMessageBox(strRect);
  115. //
  116. // strRect.Format(_T("%d,%d,%d,%d"),g_rc.left,g_rc.top,g_rc.right,g_rc.bottom);
  117. // AfxMessageBox(strRect);
  118. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  119. //CString strRect;
  120. // CRect rr;
  121. // rr = g_rc;
  122. // ClientToScreen(&rr);
  123. // strRect.Format(_T("%d,%d,%d,%d"),rr.left,rr.top,rr.right,rr.bottom);
  124. // AfxMessageBox(strRect);
  125. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc_Accout, 0);
  126. m_comboname.GetWindowRect(rc2);
  127. ScreenToClient(rc2);
  128. rc2.bottom += 200;
  129. m_comboname.MoveWindow(rc2);
  130. #endif
  131. m_spin1.SetRange(0, 10);
  132. m_static1.SetFont(&g_titlefont);
  133. m_List1.SetHeadings("账号, 60;姓名, 60;部门,60");
  134. m_List1.LoadColumnInfo(112);
  135. // Jeff初始化,向服务器获取用户信息;
  136. g_sendhead.bsql = 0;
  137. g_sendhead.code[0] = 23;
  138. g_sendhead.tabcount = 1;
  139. g_pMainWnd->ProcessChatMessageRequest2(5);
  140. if (g_bSendOK == 0) return;
  141. DataToArray(&m_List1array);
  142. m_List1arrayBak.SetSize(m_List1array.GetSize());
  143. for (int i = 0; i < m_List1array.GetSize(); i++)
  144. {
  145. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(0)); // Jeff.账号;
  146. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(1)); // Jeff.性名;
  147. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(8)); // Jeff.部门;
  148. }
  149. // Jeff:这里需要做个小处理,不添加已有账号的姓名到下拉框中;
  150. #if 0// OldEdition;
  151. for( i=0; i<g_userarray.GetSize(); i++)
  152. m_comboname.AddString (g_userarray.ElementAt (i).ElementAt (1));
  153. #else
  154. for (i = 0; i < g_userarray.GetSize(); i++)
  155. m_strNameArray.Add(g_userarray.ElementAt(i).ElementAt(1));
  156. for (i = 0; i < m_List1array.GetSize(); i++)
  157. {
  158. for (int j = 0; j < m_strNameArray.GetSize(); j++)
  159. if (m_List1array.ElementAt(i).ElementAt(1) == m_strNameArray.ElementAt(j))
  160. {
  161. m_strNameArray.RemoveAt(j);
  162. }
  163. }
  164. CommboboxReLoad();
  165. #endif
  166. FillGrid();
  167. }
  168. void Account::CommboboxReLoad()
  169. {
  170. m_comboname.ResetContent();
  171. for (int i = 0; i < m_strNameArray.GetSize(); i++)
  172. m_comboname.AddString(m_strNameArray.ElementAt(i));
  173. }
  174. void Account::FillGrid()
  175. {
  176. m_List1.DeleteAllItems2();
  177. int ii = 0;
  178. //m_List1.m_arLabels.SetSize( m_List1arrayBak.GetSize (), 1 ); // Jeff:old
  179. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  180. int count = 0;
  181. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  182. {
  183. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1arrayBak.ElementAt(ii));
  184. //m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  185. }
  186. m_List1.m_arLabels.SetSize(count, 1);
  187. ii = count;
  188. m_List1.m_LabelCount = ii;
  189. m_List1.SetItemCountEx(ii);
  190. UpdateData();
  191. //Invalidate();
  192. }
  193. void Account::OnBUTclose()
  194. {
  195. // TODO: Add your control notification handler code here
  196. GetParent()->SendMessage(WM_CLOSE);
  197. }
  198. void Account::ClearCtrl()
  199. {
  200. m_account = _T("");
  201. m_psw = _T("");
  202. m_psw2 = _T("");
  203. m_comboname.SetCurSel(-1);
  204. UpdateData(false);
  205. for (int i = 0; i < 60; i++)
  206. {
  207. ((CButton*)GetDlgItem(IDC_CHECK1 + i))->SetCheck(0);
  208. }
  209. }
  210. void Account::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  211. {
  212. // TODO: Add your control notification handler code here
  213. ListSelChange();
  214. *pResult = 0;
  215. }
  216. void Account::ListSelChange()
  217. {
  218. #if 1 // Jeff 在选择列表时,启用删除按钮;
  219. GetDlgItem(IDC_BUTdel)->EnableWindow();
  220. #endif
  221. POSITION pos;
  222. pos = m_List1.GetFirstSelectedItemPosition();
  223. if (pos == NULL)
  224. {
  225. OnBUTadd();
  226. return;
  227. }
  228. GetDlgItem(IDC_BUTleftbar)->EnableWindow(1);
  229. m_bAddNew = 0;
  230. GetDlgItem(IDC_EDITaccount)->EnableWindow(0);
  231. GetDlgItem(IDC_COMBOname)->EnableWindow(0);
  232. GetDlgItem(IDC_EDITpsw)->EnableWindow(0);
  233. GetDlgItem(IDC_EDITpsw2)->EnableWindow(0);
  234. int iItem = m_List1.GetNextSelectedItem(pos);
  235. CString account = m_List1.GetItemText(iItem, 0);
  236. for (int ii = 0; ii < m_List1array.GetSize(); ii++)
  237. {
  238. if (m_List1array.ElementAt(ii).ElementAt(0) == account)
  239. {
  240. CString name, rights;
  241. m_account = m_List1array.ElementAt(ii).ElementAt(0);
  242. name = m_List1array.ElementAt(ii).ElementAt(1);
  243. m_psw = m_psw2 = m_List1array.ElementAt(ii).ElementAt(2);
  244. rights = m_List1array.ElementAt(ii).ElementAt(3);
  245. m_discount.Format("%0.1f", atof(m_List1array.ElementAt(ii).ElementAt(5)));
  246. m_discount2.Format("%0.1f", atof(m_List1array.ElementAt(ii).ElementAt(6)));
  247. UpdateData(false);
  248. //int nIndex =0 ;
  249. int pos = m_comboname.FindString(0, name);
  250. if (pos != -1)
  251. m_comboname.SetCurSel(pos);
  252. else
  253. {
  254. m_comboname.InsertString(0, name);
  255. m_comboname.SetCurSel(0);
  256. }
  257. SetRights(rights);
  258. return;
  259. }
  260. }
  261. }
  262. void Account::OnBUTadd() // 添加新账号按钮; 添加时禁用删除按钮;
  263. {
  264. // TODO: Add your control notification handler code here
  265. CommboboxReLoad();
  266. m_bAddNew = 1;
  267. GetDlgItem(IDC_EDITaccount)->EnableWindow(1);
  268. GetDlgItem(IDC_COMBOname)->EnableWindow(1);
  269. GetDlgItem(IDC_EDITpsw)->EnableWindow(1);
  270. GetDlgItem(IDC_EDITpsw2)->EnableWindow(1);
  271. ClearCtrl();
  272. GetDlgItem(IDC_BUTleftbar)->EnableWindow(0);
  273. #if 1 // Jeff添加时禁用删除按钮;
  274. GetDlgItem(IDC_BUTdel)->EnableWindow(0);
  275. #endif
  276. }
  277. void Account::OnBUTsave() // 保存按钮;
  278. {
  279. // TODO: Add your control notification handler code here
  280. UpdateData();
  281. CString name;
  282. CString rights = GetRights();
  283. CString sql;
  284. if (m_bAddNew)
  285. {
  286. if (m_account.IsEmpty())
  287. {
  288. AfxMessageBox("资料不全!", MB_ICONINFORMATION); return;
  289. }
  290. int pos = m_comboname.GetCurSel();
  291. if (pos == -1)
  292. {
  293. AfxMessageBox("资料不全!", MB_ICONINFORMATION); return;
  294. }
  295. m_comboname.GetLBText(pos, name);
  296. if (m_psw != m_psw2)
  297. {
  298. AfxMessageBox("密码不一至!", MB_ICONINFORMATION); return;
  299. }
  300. if (IsExist(m_account, name))
  301. {
  302. AfxMessageBox("已有此账号或姓名,请重新输入!", MB_ICONINFORMATION);
  303. return;
  304. }
  305. sql.Format("insert into [user](account,name,psw,rights,discount,discount2) values('%s','%s','%s','%s','%0.1f','%0.1f')", m_account, name, m_psw, rights, atof(m_discount), atof(m_discount2));
  306. sql += USER_REF;
  307. g_sendhead.bsql = 1;
  308. g_pMainWnd->ProcessChatMessageRequest2(sql);
  309. if (g_bSendOK == 0)
  310. return;
  311. #if 1 // Jeff添加成功后,要删除m_strNameArray里的存根;
  312. for (int i(0); i < m_strNameArray.GetSize(); i++)
  313. {
  314. if (name == m_strNameArray.ElementAt(i))
  315. {
  316. //AfxMessageBox("ssssss");
  317. m_strNameArray.RemoveAt(i);
  318. break;
  319. }
  320. }
  321. ClearCtrl();
  322. CommboboxReLoad();
  323. #endif
  324. GetData();
  325. }
  326. else//修改
  327. {
  328. sql.Format("update [user] set [rights]='%s',[discount]='%0.1f',[discount2]='%0.1f' where [account]='%s' ", rights, atof(m_discount), atof(m_discount2), m_account);
  329. sql += USER_REF;
  330. g_sendhead.bsql = 1;
  331. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  332. GetData();
  333. }
  334. }
  335. void Account::OnBUTdel() // 删除按钮;
  336. {
  337. // TODO: Add your control notification handler code here
  338. POSITION pos;
  339. pos = m_List1.GetFirstSelectedItemPosition();
  340. if (pos == NULL)
  341. {
  342. return;
  343. }
  344. if (AfxMessageBox("确认删除吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  345. int iItem = m_List1.GetNextSelectedItem(pos);
  346. CString account = m_List1.GetItemText(iItem, 0);
  347. if (account == "admin")
  348. {
  349. AfxMessageBox("管理员不能删除");
  350. return;
  351. }
  352. CString sql;
  353. sql.Format("delete from [user] where [account]='%s' ", account);
  354. sql += USER_REF;
  355. g_sendhead.bsql = 1;
  356. g_pMainWnd->ProcessChatMessageRequest2(sql);
  357. if (g_bSendOK == 0)
  358. return;
  359. #if 1 // Jeff 删除时要清空文本框;
  360. CString strName = m_List1.GetItemText(iItem, 1);
  361. //BOOL bNameInArray = FALSE;
  362. ClearCtrl();
  363. //for ( int i(0); i < m_strNameArray.GetSize(); i++)
  364. //{
  365. // if ( name == m_strNameArray.ElementAt(i))
  366. // {
  367. // bNameInArray = TRUE;
  368. // break;
  369. // }
  370. // }
  371. //if ( !bNameInArray )
  372. // {
  373. m_strNameArray.Add(strName);
  374. //}
  375. CommboboxReLoad();
  376. #endif
  377. GetData();
  378. }
  379. void Account::GetData()
  380. {
  381. g_sendhead.bsql = 0;
  382. g_sendhead.code[0] = 23;
  383. g_sendhead.tabcount = 1;
  384. g_pMainWnd->ProcessChatMessageRequest2(23);
  385. DataToArray(&m_List1array);
  386. // Jeff add:在getdata里处理;
  387. m_List1arrayBak.RemoveAll();
  388. m_List1arrayBak.SetSize(m_List1array.GetSize());
  389. for (int i = 0; i < m_List1array.GetSize(); i++)
  390. {
  391. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(0));
  392. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(1));
  393. m_List1arrayBak.ElementAt(i).Add(m_List1array.ElementAt(i).ElementAt(8));
  394. }
  395. //
  396. FillGrid();
  397. }
  398. BOOL Account::IsExist(CString account, CString name)
  399. {
  400. for (int i = 0; i < m_List1array.GetSize(); i++)
  401. {
  402. if (account == m_List1array.ElementAt(i).ElementAt(0))return 1;
  403. if (name == m_List1array.ElementAt(i).ElementAt(1))return 1;
  404. }
  405. return 0;
  406. }
  407. CString Account::GetRights()//50
  408. {
  409. CString ret, temp;
  410. for (int i = 0; i < 60; i++)
  411. {
  412. temp.Format("%d", ((CButton*)GetDlgItem(IDC_CHECK1 + i))->GetCheck());
  413. ret += temp;
  414. }
  415. return ret;
  416. }
  417. void Account::SetRights(CString rights)
  418. {
  419. for (int i = 0; i < rights.GetLength(); i++)
  420. {
  421. if (i >= 60)break;
  422. ((CButton*)GetDlgItem(IDC_CHECK1 + i))->SetCheck(rights.GetAt(i) == '1');
  423. }
  424. for (i = rights.GetLength(); i < 60; i++)
  425. {
  426. ((CButton*)GetDlgItem(IDC_CHECK1 + i))->SetCheck(0);
  427. }
  428. }
  429. void Account::OnBUTbm6()
  430. {
  431. // TODO: Add your control notification handler code here
  432. POSITION pos;
  433. pos = m_List1.GetFirstSelectedItemPosition();
  434. if (pos)
  435. {
  436. int iItem = m_List1.GetNextSelectedItem(pos);
  437. CString account = m_List1.GetItemText(iItem, 0);
  438. if (account == "admin")
  439. {
  440. SetRights("000000000000000000000000000000000000000000000000010000000000");
  441. return;
  442. }
  443. }
  444. SetRights("000000000000000000000000000000000000000000000000000000000000");
  445. }
  446. void Account::OnBUTbm1()
  447. {
  448. // TODO: Add your control notification handler code here
  449. ((CButton*)GetDlgItem(IDC_CHECK1 + 0))->SetCheck(1);
  450. ((CButton*)GetDlgItem(IDC_CHECK1 + 15))->SetCheck(1);
  451. }
  452. void Account::OnBUTbm2()
  453. {
  454. // TODO: Add your control notification handler code here
  455. ((CButton*)GetDlgItem(IDC_CHECK1 + 4))->SetCheck(1);
  456. ((CButton*)GetDlgItem(IDC_CHECK1 + 5))->SetCheck(1);
  457. ((CButton*)GetDlgItem(IDC_CHECK1 + 8))->SetCheck(1);
  458. ((CButton*)GetDlgItem(IDC_CHECK1 + 15))->SetCheck(1);
  459. }
  460. void Account::OnBUTbm3()
  461. {
  462. // TODO: Add your control notification handler code here
  463. ((CButton*)GetDlgItem(IDC_CHECK1 + 5))->SetCheck(1);
  464. ((CButton*)GetDlgItem(IDC_CHECK1 + 6))->SetCheck(1);
  465. ((CButton*)GetDlgItem(IDC_CHECK1 + 7))->SetCheck(1);
  466. ((CButton*)GetDlgItem(IDC_CHECK1 + 8))->SetCheck(1);
  467. ((CButton*)GetDlgItem(IDC_CHECK1 + 9))->SetCheck(1);
  468. ((CButton*)GetDlgItem(IDC_CHECK1 + 10))->SetCheck(1);
  469. ((CButton*)GetDlgItem(IDC_CHECK1 + 11))->SetCheck(1);
  470. ((CButton*)GetDlgItem(IDC_CHECK1 + 12))->SetCheck(1);
  471. }
  472. void Account::OnBUTbm4()
  473. {
  474. // TODO: Add your control notification handler code here
  475. ((CButton*)GetDlgItem(IDC_CHECK1 + 16))->SetCheck(1);
  476. ((CButton*)GetDlgItem(IDC_CHECK1 + 17))->SetCheck(1);
  477. ((CButton*)GetDlgItem(IDC_CHECK1 + 18))->SetCheck(1);
  478. ((CButton*)GetDlgItem(IDC_CHECK1 + 19))->SetCheck(1);
  479. ((CButton*)GetDlgItem(IDC_CHECK1 + 20))->SetCheck(1);
  480. ((CButton*)GetDlgItem(IDC_CHECK1 + 21))->SetCheck(1);
  481. ((CButton*)GetDlgItem(IDC_CHECK1 + 22))->SetCheck(1);
  482. }
  483. void Account::OnBUTbm5()
  484. {
  485. // TODO: Add your control notification handler code here
  486. SetRights("111111111111111111111111111111111111111111111111111111111111");
  487. }
  488. void Account::OnBUTleftbar() // 界面设置
  489. {
  490. // TODO: Add your control notification handler code here
  491. SetLeftBar dlg;
  492. dlg.m_account = m_account;
  493. dlg.DoModal();
  494. }
  495. void Account::OnCheck27()
  496. {
  497. // TODO: Add your control notification handler code here
  498. // if(((CButton*)GetDlgItem(IDC_CHECK27))->GetCheck())
  499. // {
  500. // }
  501. }
  502. /************************************************************************/
  503. /*
  504. 函数:EnumChildProc_Accout
  505. 参数:
  506. 返回:
  507. 要求:
  508. 注意:
  509. 示例:
  510. */
  511. /************************************************************************/
  512. BOOL Account::EnumChildProc_Accout(HWND hwnd, LPARAM lParam)
  513. {
  514. // 1182 与 537 是资源对话框的像素值;而不是由GetWindowsRect获得的;
  515. static float fWidthScale = ((float)g_rc.Width()) / 1182.0;
  516. static float fHeightScale = ((float)g_rc.Height()) / 537.0;
  517. // static float fWidthScale = ((float)g_rc.Width()) / m_rct.Width();
  518. // static float fHeightScale = ((float)g_rc.Height()) / m_rct.Height();
  519. CRect rtCtrl, rtWnd; // 子窗口,父窗口;
  520. if (hwnd)
  521. {
  522. float temp;
  523. TCHAR szClassName[MAX_PATH];
  524. ::GetClassName(hwnd, szClassName, MAX_PATH);
  525. ::GetWindowRect(hwnd, &rtCtrl); // 获取控件大小;
  526. ::GetWindowRect(::GetParent(hwnd), &rtWnd); // 获取父窗口大小;
  527. // CString strRect;
  528. // strRect.Format(_T("A %d,%d,%d,%d"),rtCtrl.left,rtCtrl.top,rtCtrl.right,rtCtrl.bottom);
  529. // AfxMessageBox(strRect);
  530. //
  531. // strRect.Format(_T("B %d,%d,%d,%d"),rtWnd.left,rtWnd.top,rtWnd.right,rtWnd.bottom);
  532. // AfxMessageBox(strRect);
  533. //if ( _tcscmp(szClassName,_T("EDIT")) != 0 )
  534. if ( strcmp(szClassName,_T("EDIT")) != 0 )
  535. {
  536. rtCtrl.OffsetRect(-rtWnd.left, -rtWnd.top);
  537. temp = (float)rtCtrl.left*fWidthScale;
  538. rtCtrl.left = (int)temp + g_dx;
  539. temp = (float)rtCtrl.top*fHeightScale;
  540. rtCtrl.top = (int)temp + g_dy;
  541. temp = (float)rtCtrl.right*fWidthScale;
  542. rtCtrl.right = (int)temp + g_dx;
  543. temp = (float)rtCtrl.bottom*fHeightScale;
  544. rtCtrl.bottom = (int)temp + g_dy;
  545. }
  546. else
  547. {
  548. rtCtrl.OffsetRect(-rtWnd.left, -rtWnd.top);
  549. temp = (float)rtCtrl.left*fWidthScale;
  550. rtCtrl.left = (int)temp + g_dx;
  551. temp = (float)rtCtrl.top*fHeightScale;
  552. rtCtrl.top = (int)temp + g_dy;
  553. temp = (float)rtCtrl.right*fWidthScale;
  554. rtCtrl.right = (int)temp + g_dx;
  555. temp = (float)rtCtrl.bottom*fHeightScale;
  556. rtCtrl.bottom = (int)temp + g_dy;
  557. }
  558. ::MoveWindow(hwnd, rtCtrl.left, rtCtrl.top, rtCtrl.Width(), rtCtrl.Height(), TRUE);
  559. return TRUE;
  560. }
  561. else
  562. {
  563. return FALSE;
  564. }
  565. }