TXSPDlg.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. // TXSPDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "TXSPDlg.h"
  6. #include "MyMdi.H"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. IMPLEMENT_DYNCREATE(TXSPDlg, MyFormView)
  13. TXSPDlg::TXSPDlg(): MyFormView(TXSPDlg::IDD),m_CostPackage(0.0),m_SalePackage(0.0)
  14. {
  15. m_taoxiid = _T("");
  16. m_taoxijiage = _T("");
  17. m_zs = _T("");
  18. }
  19. TXSPDlg::~TXSPDlg()
  20. {
  21. }
  22. void TXSPDlg::DoDataExchange(CDataExchange* pDX)
  23. {
  24. MyFormView::DoDataExchange(pDX);
  25. DDX_Control(pDX, IDC_LIST2, m_List2);
  26. DDX_Control(pDX, IDC_LIST1, m_List1);
  27. DDX_Control(pDX, IDC_STATIC1, m_static1);
  28. DDX_Control(pDX, IDC_COMBOtaoxiname, m_combotaoxiname);
  29. DDX_Text(pDX, IDC_EDITtaoxiid, m_taoxiid);
  30. DDX_Text(pDX, IDC_EDITtaoxijiage, m_taoxijiage);
  31. DDX_Text(pDX, IDC_EDITzs, m_zs);
  32. DDX_Control(pDX, CB_KINDS, m_cbKinds);
  33. }
  34. BEGIN_MESSAGE_MAP(TXSPDlg, MyFormView)
  35. ON_BN_CLICKED(IDC_BUTsave, OnBUTsave)
  36. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  37. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  38. ON_CBN_SELCHANGE(IDC_COMBOtaoxiname, OnSelchangeCOMBOtaoxiname)
  39. ON_BN_CLICKED(IDC_BUTspbox, OnBUTspbox)
  40. ON_WM_TIMER()
  41. ON_BN_CLICKED(IDC_BUTsave2, OnBUTsave2)
  42. ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
  43. ON_BN_CLICKED(IDC_BUTspbox2, OnBUTspbox2)
  44. ON_BN_CLICKED(IDC_BUTclose2, OnBUTclose2)
  45. ON_CBN_SELCHANGE(CB_KINDS, OnCbnSelchangeKinds)
  46. ON_WM_SIZE()
  47. END_MESSAGE_MAP()
  48. #ifdef _DEBUG
  49. void TXSPDlg::AssertValid() const
  50. {
  51. MyFormView::AssertValid();
  52. }
  53. void TXSPDlg::Dump(CDumpContext& dc) const
  54. {
  55. MyFormView::Dump(dc);
  56. }
  57. #endif
  58. void TXSPDlg::OnInitialUpdate()
  59. {
  60. MyFormView::OnInitialUpdate();
  61. CMyMdi Mdi;
  62. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  63. CRect rc1, rc2;
  64. GetWindowRect(rc1);
  65. rc2 = rc1;
  66. rc1 = g_rc;
  67. ScreenToClient(&rc1);
  68. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  69. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  70. m_combotaoxiname.GetWindowRect(rc2);
  71. ScreenToClient(rc2);
  72. rc2.bottom += 200;
  73. m_combotaoxiname.MoveWindow(rc2);
  74. m_static1.SetFont(&g_titlefont);
  75. g_sendhead.bsql = 0;
  76. g_sendhead.code[0] = 6;
  77. g_sendhead.code[1] = 7;
  78. g_sendhead.code[2] = 10;
  79. g_sendhead.code[3] = 4;
  80. g_sendhead.tabcount = 4;
  81. g_pMainWnd->ProcessChatMessageRequest2(6);
  82. if (g_bSendOK == 0)return;
  83. DataToArray(&m_List1array, &m_List2array, &m_List3array, &m_sparray);
  84. for (int i = 0; i < m_List1array.GetSize(); i++)
  85. m_combotaoxiname.AddString(m_List1array.ElementAt(i).ElementAt(1));
  86. // 商品;
  87. m_List1.InitStyle();
  88. m_List1.InsertColumn(0, _T("编号"), LVCFMT_LEFT, 80);
  89. m_List1.InsertColumn(1, _T("商品名称"), LVCFMT_LEFT, 200);
  90. m_List1.InsertColumn(2, _T("数量"), LVCFMT_LEFT, 60);
  91. m_List1.InsertColumn(3, _T("商品卖价"), LVCFMT_LEFT, 200);
  92. // 服务;
  93. m_List2.InitStyle();
  94. m_List2.InsertColumn(0, _T("编号"), LVCFMT_LEFT, 80);
  95. m_List2.InsertColumn(1, _T("商品名称"), LVCFMT_LEFT, 200);
  96. m_List2.InsertColumn(2, _T("数量"), LVCFMT_LEFT, 60);
  97. }
  98. void TXSPDlg::OnSelchangeCOMBOtaoxiname()
  99. {
  100. int pos = m_combotaoxiname.GetCurSel();
  101. if (pos == -1)return;
  102. m_taoxiid = m_List1array.ElementAt(pos).ElementAt(0);
  103. m_taoxijiage = m_List1array.ElementAt(pos).ElementAt(2);
  104. m_zs = m_List1array.ElementAt(pos).ElementAt(3);
  105. UpdateData(false);
  106. FillGrid();
  107. }
  108. void TXSPDlg::FillGrid()
  109. {
  110. m_List1.DeleteAllItems();
  111. int pos = 0;
  112. int i = 0;
  113. // 清空上次累计成本/卖价;
  114. m_CostPackage = m_SalePackage = 0.0;
  115. for ( i = 0; i < m_List2array.GetSize(); i++)
  116. {
  117. if (m_List2array.ElementAt(i).ElementAt(0) != m_taoxiid)
  118. continue;
  119. STProductInfo productinfo;
  120. GetProductInfoById(m_List2array.ElementAt(i).ElementAt(1), productinfo);
  121. m_List1.InsertItem(pos, m_List2array.ElementAt(i).ElementAt(1));
  122. //m_List1.SetItemText(pos, 1, GetSPNameFromId(m_List2array.ElementAt(i).ElementAt(1)));
  123. m_List1.SetItemText(pos, 1, productinfo.strProductName);
  124. m_List1.SetItemText(pos, 2, m_List2array.ElementAt(i).ElementAt(2));
  125. // 可能要做权限控制,尤其是成本价;
  126. m_List1.SetItemText(pos, 3, productinfo.strProductSale);
  127. //m_List1.SetItemText(pos, 4, productinfo.strProductCost);
  128. // 累计成本和售价;
  129. m_CostPackage += atof(productinfo.strProductCost) * atoi(m_List2array.ElementAt(i).ElementAt(2));
  130. m_SalePackage += atof(productinfo.strProductSale) * atoi(m_List2array.ElementAt(i).ElementAt(2));
  131. pos++;
  132. }
  133. //#ifndef MODERN_VERSION
  134. #if 0
  135. for( i=0; i<m_List3array.GetSize (); i++)
  136. {
  137. if(m_List3array.ElementAt (i).ElementAt (0)!=m_taoxiid)continue;
  138. m_List1.InsertItem(pos, m_List3array.ElementAt (i).ElementAt (1));
  139. m_List1.SetItemText(pos,1, GetSPNameFromId(m_List3array.ElementAt (i).ElementAt (1)));
  140. m_List1.SetItemText(pos,2, m_List3array.ElementAt (i).ElementAt (2));
  141. pos++;
  142. }
  143. #else
  144. m_List2.DeleteAllItems();
  145. pos = 0;
  146. for (i = 0; i < m_List3array.GetSize(); i++)
  147. {
  148. if (m_List3array.ElementAt(i).ElementAt(0) != m_taoxiid)continue;
  149. m_List2.InsertItem(pos, m_List3array.ElementAt(i).ElementAt(1));
  150. m_List2.SetItemText(pos, 1, GetSPNameFromId(m_List3array.ElementAt(i).ElementAt(1)));
  151. m_List2.SetItemText(pos, 2, m_List3array.ElementAt(i).ElementAt(2));
  152. pos++;
  153. }
  154. #endif
  155. CString strCostAndSale;
  156. strCostAndSale.Format(_T("%0.2lf/%0.2lf"), m_CostPackage, m_SalePackage);
  157. SetDlgItemText(IDC_EDIT4, strCostAndSale);
  158. }
  159. CString TXSPDlg::GetSPNameFromId(CString id)
  160. {
  161. int i = 0;
  162. for ( i = 0; i < m_sparray.GetSize(); i++)
  163. {
  164. if (id == m_sparray.ElementAt(i).ElementAt(0))
  165. return m_sparray.ElementAt(i).ElementAt(1);
  166. }
  167. id.TrimLeft("0");
  168. for (i = 0; i < m_sparray.GetSize(); i++)
  169. {
  170. if (id == m_sparray.ElementAt(i).ElementAt(0))
  171. return m_sparray.ElementAt(i).ElementAt(1);
  172. }
  173. return "";
  174. }
  175. BOOL TXSPDlg::GetProductInfoById(IN CString strProductId, OUT STProductInfo &productinfo)
  176. {
  177. BOOL bExist = FALSE;
  178. INT nSize = m_sparray.GetSize();
  179. for ( int i = 0; i < nSize; i++ )
  180. {
  181. if ( strProductId == m_sparray.ElementAt(i).ElementAt(0) )
  182. {
  183. productinfo.strProductId = strProductId;
  184. productinfo.strProductName = m_sparray.ElementAt(i).ElementAt(1);
  185. productinfo.strProductCost = m_sparray.ElementAt(i).ElementAt(3);
  186. productinfo.strProductSale = m_sparray.ElementAt(i).ElementAt(4);
  187. bExist = TRUE;
  188. break;
  189. }
  190. }
  191. return bExist;
  192. }
  193. BOOL TXSPDlg::PreTranslateMessage(MSG* pMsg)
  194. {
  195. if (pMsg->message == WM_KEYDOWN)
  196. {
  197. switch (pMsg->wParam)
  198. {
  199. case 0x43: // copy
  200. if ((GetKeyState(VK_CONTROL) & 0x80))
  201. {
  202. GetFocus()->SendMessage(WM_COPY);
  203. return TRUE;
  204. }
  205. break;
  206. case 0x56: //Ctrl + V:
  207. if ((GetKeyState(VK_CONTROL) & 0x80))
  208. {
  209. GetFocus()->SendMessage(WM_PASTE);
  210. return TRUE;
  211. }
  212. break;
  213. case 0x58: // cut
  214. if ((GetKeyState(VK_CONTROL) & 0x80))
  215. {
  216. GetFocus()->SendMessage(WM_CUT);
  217. return TRUE;
  218. }
  219. break;
  220. case 0x5A: //undo
  221. case 0x59: //redo
  222. if ((GetKeyState(VK_CONTROL) & 0x80))
  223. {
  224. GetFocus()->SendMessage(WM_UNDO);
  225. return TRUE;
  226. }
  227. break;
  228. }
  229. }
  230. else if (pMsg->message == WM_LBUTTONDBLCLK)
  231. {
  232. if (0)
  233. {//list1
  234. CPoint pt;
  235. CRect rc, rc2;
  236. ::GetCursorPos(&pt);
  237. m_List1.GetWindowRect(rc2);
  238. if (rc2.PtInRect(pt) == 0) return MyFormView::PreTranslateMessage(pMsg);
  239. pt.x -= rc2.left;
  240. pt.y -= rc2.top;
  241. POSITION pos;
  242. pos = m_List1.GetFirstSelectedItemPosition();
  243. if (pos == NULL)return 1;
  244. int iItem = m_List1.GetNextSelectedItem(pos);
  245. m_List1.GetSubItemRect(iItem, 2, LVIR_BOUNDS, rc);
  246. if (rc.PtInRect(pt))
  247. return MyFormView::PreTranslateMessage(pMsg);
  248. else
  249. return 1;
  250. }
  251. }
  252. return MyFormView::PreTranslateMessage(pMsg);
  253. }
  254. void TXSPDlg::SetSPName1()
  255. {
  256. for (int i = 0; i < m_List1.GetItemCount(); i++)
  257. {
  258. m_List1.SetItemText(i, 1, GetSPNameFromId(m_List1.GetItemText(i, 0)));
  259. }
  260. }
  261. void TXSPDlg::SetSPName2()
  262. {
  263. for (int i = 0; i < m_List2.GetItemCount(); i++)
  264. {
  265. m_List2.SetItemText(i, 1, GetSPNameFromId(m_List2.GetItemText(i, 0)));
  266. }
  267. }
  268. void TXSPDlg::OnTimer(UINT nIDEvent)
  269. {
  270. if (nIDEvent == 1)
  271. {
  272. KillTimer(nIDEvent);
  273. SetSPName1();
  274. }
  275. else if (nIDEvent == 2)
  276. {
  277. KillTimer(nIDEvent);
  278. SetSPName2();
  279. }
  280. }
  281. void TXSPDlg::OnBUTsave()
  282. {
  283. int pos = m_combotaoxiname.GetCurSel();
  284. if (pos == -1)return;
  285. CArray<CStringArray, CStringArray>sparray;
  286. sparray.SetSize(m_List1.GetItemCount());
  287. int realcount = 0;
  288. for (int i = 0; i < m_List1.GetItemCount(); i++)
  289. {
  290. if (m_List1.GetItemText(i, 0).IsEmpty())continue;
  291. sparray.ElementAt(realcount).Add(m_List1array.ElementAt(pos).ElementAt(0));
  292. sparray.ElementAt(realcount).Add(m_List1.GetItemText(i, 0));
  293. sparray.ElementAt(realcount).Add(m_List1.GetItemText(i, 2));
  294. realcount++;
  295. }
  296. sparray.SetSize(realcount);
  297. if (realcount == 0)
  298. {
  299. sparray.SetSize(1);
  300. sparray.ElementAt(0).Add(m_List1array.ElementAt(pos).ElementAt(0));
  301. }
  302. CMemFile memfile;
  303. CArchive ar(&memfile, CArchive::store);
  304. for (int ii = 0; ii < sparray.GetSize(); ii++)
  305. {
  306. sparray.ElementAt(ii).Serialize(ar);
  307. }
  308. ar.Close();
  309. int length = memfile.GetLength();
  310. BYTE *pData = memfile.Detach();
  311. int size = sparray.GetSize();
  312. BYTE *pData2 = new BYTE[length + sizeof(int)];
  313. memcpy(pData2, pData, length);
  314. memcpy(pData2 + length, &size, sizeof(int));
  315. delete[]pData;
  316. length += sizeof(int);
  317. g_nSendCode = 1;
  318. g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
  319. g_nSendCode = 0;
  320. delete[]pData2;
  321. if (g_bSendOK == 0)return;
  322. g_sendhead.bsql = 0;
  323. g_sendhead.code[0] = 7;
  324. g_sendhead.code[1] = 10;
  325. g_sendhead.tabcount = 2;
  326. g_pMainWnd->ProcessChatMessageRequest2(7); if (g_bSendOK == 0)return;
  327. DataToArray(&m_List2array, &m_List3array);
  328. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  329. }
  330. void TXSPDlg::OnBUTdel()
  331. {
  332. POSITION pos;
  333. pos = m_List1.GetFirstSelectedItemPosition();
  334. if (pos == NULL)
  335. {
  336. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  337. return;
  338. }
  339. int iItem = m_List1.GetNextSelectedItem(pos);
  340. m_List1.DeleteItem(iItem);
  341. int count = m_List1.GetItemCount();
  342. if (count == 0)return;
  343. if (iItem == count)
  344. iItem = 0;
  345. m_List1.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
  346. }
  347. void TXSPDlg::OnBUTspbox()
  348. {
  349. SPBox dlg;
  350. if (dlg.DoModal() != IDOK)return;
  351. for (int a = 0; a < dlg.m_spidarray.GetSize(); a++)
  352. {
  353. dlg.m_spid = dlg.m_spidarray.ElementAt(a);
  354. dlg.m_spname = dlg.m_spnamearray.ElementAt(a);
  355. dlg.m_lb = dlg.m_lbarray.ElementAt(a);
  356. int pos = m_List1.GetItemCount();
  357. if (pos)
  358. {
  359. if (m_List1.GetItemText(pos - 1, 0).IsEmpty() && m_List1.GetItemText(pos - 1, 1).IsEmpty() && m_List1.GetItemText(pos - 1, 2).IsEmpty())
  360. {
  361. pos--;
  362. m_List1.SetItemText(pos, 0, dlg.m_spid);
  363. m_List1.SetItemText(pos, 1, GetSPNameFromId(dlg.m_spid));
  364. }
  365. else
  366. {
  367. m_List1.InsertItem(pos, dlg.m_spid);
  368. m_List1.SetItemText(pos, 1, GetSPNameFromId(dlg.m_spid));
  369. m_List1.SetItemText(pos, 2, "1");
  370. }
  371. }
  372. else
  373. {
  374. m_List1.InsertItem(pos, dlg.m_spid);
  375. m_List1.SetItemText(pos, 1, GetSPNameFromId(dlg.m_spid));
  376. m_List1.SetItemText(pos, 2, "1");
  377. }
  378. }
  379. }
  380. void TXSPDlg::OnBUTclose()
  381. {
  382. GetParent()->SendMessage(WM_CLOSE);
  383. }
  384. void TXSPDlg::OnBUTsave2()
  385. {
  386. int pos = m_combotaoxiname.GetCurSel();
  387. if (pos == -1)return;
  388. CArray<CStringArray, CStringArray>sparray;
  389. sparray.SetSize(m_List2.GetItemCount());
  390. int realcount = 0;
  391. for (int i = 0; i < m_List2.GetItemCount(); i++)
  392. {
  393. if (m_List2.GetItemText(i, 0).IsEmpty())continue;
  394. sparray.ElementAt(realcount).Add(m_List1array.ElementAt(pos).ElementAt(0));
  395. sparray.ElementAt(realcount).Add(m_List2.GetItemText(i, 0));
  396. sparray.ElementAt(realcount).Add(m_List2.GetItemText(i, 2));
  397. realcount++;
  398. }
  399. sparray.SetSize(realcount);
  400. if (realcount == 0)
  401. {
  402. sparray.SetSize(1);
  403. sparray.ElementAt(0).Add(m_List1array.ElementAt(pos).ElementAt(0));
  404. }
  405. CMemFile memfile;
  406. CArchive ar(&memfile, CArchive::store);
  407. for (int ii = 0; ii < sparray.GetSize(); ii++)
  408. {
  409. sparray.ElementAt(ii).Serialize(ar);
  410. }
  411. ar.Close();
  412. int length = memfile.GetLength();
  413. BYTE *pData = memfile.Detach();
  414. int size = sparray.GetSize();
  415. BYTE *pData2 = new BYTE[length + sizeof(int)];
  416. memcpy(pData2, pData, length);
  417. memcpy(pData2 + length, &size, sizeof(int));
  418. delete[]pData;
  419. length += sizeof(int);
  420. g_nSendCode = 2;
  421. g_pMainWnd->ProcessChatMessageRequest2(pData2, length);
  422. g_nSendCode = 0;
  423. delete[]pData2;
  424. if (g_bSendOK == 0)return;
  425. g_sendhead.bsql = 0;
  426. g_sendhead.code[0] = 7;
  427. g_sendhead.code[1] = 10;
  428. g_sendhead.tabcount = 2;
  429. g_pMainWnd->ProcessChatMessageRequest2(7); if (g_bSendOK == 0)return;
  430. DataToArray(&m_List2array, &m_List3array);
  431. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  432. }
  433. void TXSPDlg::OnBUTdel2()
  434. {
  435. POSITION pos;
  436. pos = m_List2.GetFirstSelectedItemPosition();
  437. if (pos == NULL)
  438. {
  439. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);
  440. return;
  441. }
  442. int iItem = m_List2.GetNextSelectedItem(pos);
  443. m_List2.DeleteItem(iItem);
  444. int count = m_List2.GetItemCount();
  445. if (count == 0)return;
  446. if (iItem == count)
  447. iItem = 0;
  448. m_List2.SetItemState(iItem, LVIS_SELECTED, LVIS_SELECTED);
  449. }
  450. void TXSPDlg::OnBUTspbox2()
  451. {
  452. SPBox dlg;
  453. dlg.m_mode = 1;
  454. if (dlg.DoModal() != IDOK)return;
  455. for (int a = 0; a < dlg.m_spidarray.GetSize(); a++)
  456. {
  457. dlg.m_spid = dlg.m_spidarray.ElementAt(a);
  458. dlg.m_spname = dlg.m_spnamearray.ElementAt(a);
  459. dlg.m_lb = dlg.m_lbarray.ElementAt(a);
  460. int pos = m_List2.GetItemCount();
  461. if (pos)
  462. {
  463. if (m_List2.GetItemText(pos - 1, 0).IsEmpty() && m_List2.GetItemText(pos - 1, 1).IsEmpty() && m_List2.GetItemText(pos - 1, 2).IsEmpty())
  464. {
  465. pos--;
  466. m_List2.SetItemText(pos, 0, dlg.m_spid);
  467. m_List2.SetItemText(pos, 1, GetSPNameFromId(dlg.m_spid));
  468. m_List2.SetItemText(pos, 2, "1");
  469. }
  470. else
  471. {
  472. m_List2.InsertItem(pos, dlg.m_spid);
  473. m_List2.SetItemText(pos, 1, GetSPNameFromId(dlg.m_spid));
  474. m_List2.SetItemText(pos, 2, "1");
  475. }
  476. }
  477. else
  478. {
  479. m_List2.InsertItem(pos, dlg.m_spid);
  480. m_List2.SetItemText(pos, 1, GetSPNameFromId(dlg.m_spid));
  481. m_List2.SetItemText(pos, 2, "1");
  482. }
  483. }
  484. }
  485. void TXSPDlg::OnBUTclose2()
  486. {
  487. GetParent()->SendMessage(WM_CLOSE);
  488. }
  489. void TXSPDlg::OnCbnSelchangeKinds()
  490. {
  491. }
  492. BOOL CALLBACK TXSPDlg::EnumChildProc1(HWND hwnd, LPARAM lParam)
  493. {
  494. CSize sz = (CSize)lParam;
  495. CRect rtCtrl, rtWnd; // 子窗口,父窗口;
  496. if (hwnd)
  497. {
  498. ::GetWindowRect(hwnd, &rtCtrl); // 获取控件大小;
  499. ::GetWindowRect(::GetParent(hwnd), &rtWnd); // 获取父窗口大小;
  500. ((CWnd*)hwnd)->ScreenToClient(rtCtrl);
  501. rtCtrl.left += g_rc.left;
  502. rtCtrl.top += g_rc.top;
  503. rtCtrl.right += sz.cx;
  504. rtCtrl.bottom += sz.cy;
  505. ::MoveWindow(hwnd, rtCtrl.left, rtCtrl.top, rtCtrl.Width(), rtCtrl.Height(), TRUE);
  506. return TRUE;
  507. }
  508. else
  509. {
  510. return FALSE;
  511. }
  512. }
  513. // 从OnSize中可以获取两个坐标:1.原始的, 2.最后的;
  514. // 1.原始的:第一次的Get cx,cy;
  515. // 2.最后的:最后一次Get cx,cy;
  516. void TXSPDlg::OnSize(UINT nType, int cx, int cy)
  517. {
  518. MyFormView::OnSize(nType, cx, cy);
  519. static BOOL bDeal = FALSE;
  520. static CRect FirstRect(g_rc.left, g_rc.top, g_rc.left + cx, g_rc.top + cy); // 移动到g_rc后的原始屏幕坐标;
  521. static CRect LastWindowRect( g_rc.left, g_rc.top, g_rc.right, g_rc.bottom );
  522. if ( bDeal == FALSE)
  523. {
  524. m_rcOld = FirstRect;
  525. bDeal = TRUE;
  526. }
  527. }