SetSize.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // SetSize.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "SetSize.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // SetSize dialog
  13. SetSize::SetSize(CWnd* pParent /*=NULL*/)
  14. : CDialog(SetSize::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(SetSize)
  17. m_name = _T("");
  18. m_width = 0;
  19. m_height = 0;
  20. //}}AFX_DATA_INIT
  21. }
  22. void SetSize::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CDialog::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(SetSize)
  26. DDX_Control(pDX, IDC_LIST1, m_List1);
  27. DDX_Text(pDX, IDC_EDITname, m_name);
  28. DDX_Text(pDX, IDC_EDITwidth, m_width);
  29. DDX_Text(pDX, IDC_EDITheight, m_height);
  30. //}}AFX_DATA_MAP
  31. }
  32. BEGIN_MESSAGE_MAP(SetSize, CDialog)
  33. //{{AFX_MSG_MAP(SetSize)
  34. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  35. ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
  36. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // SetSize message handlers
  41. BOOL SetSize::OnInitDialog()
  42. {
  43. CDialog::OnInitDialog();
  44. // TODO: Add extra initialization here
  45. g_sendhead.bsql = 0;
  46. g_sendhead.code[0] = 174;
  47. g_sendhead.tabcount = 1;
  48. g_pMainWnd->ProcessChatMessageRequest2(6);
  49. if (g_bSendOK == 0)
  50. {
  51. CDialog::OnCancel();
  52. return 0;
  53. }
  54. DataToArray(&g_List1array);
  55. CenterWindow();
  56. for (int i = 0; i < g_List1array.GetSize(); i++)
  57. {
  58. namearray.Add(g_List1array.ElementAt(i).ElementAt(0));
  59. widtharray.Add(atoi(g_List1array.ElementAt(i).ElementAt(1)));
  60. heightarray.Add(atoi(g_List1array.ElementAt(i).ElementAt(2)));
  61. CString str;
  62. str.Format(_T("%s 宽:%d 高:%d"), g_List1array.ElementAt(i).ElementAt(0), atoi(g_List1array.ElementAt(i).ElementAt(1)), atoi(g_List1array.ElementAt(i).ElementAt(2)));
  63. m_List1.AddString(str);
  64. }
  65. return TRUE; // return TRUE unless you set the focus to a control
  66. // EXCEPTION: OCX Property Pages should return FALSE
  67. }
  68. void SetSize::OnSelchangeList1()
  69. {
  70. // TODO: Add your control notification handler code here
  71. int pos = m_List1.GetCurSel();
  72. if (pos == -1)return;
  73. m_name = namearray.ElementAt(pos);
  74. m_width = widtharray.ElementAt(pos);
  75. m_height = heightarray.ElementAt(pos);
  76. UpdateData(false);
  77. }
  78. void SetSize::OnBUTadd()
  79. {
  80. // TODO: Add your control notification handler code here
  81. UpdateData();
  82. m_name.TrimLeft();
  83. if (m_name.IsEmpty())
  84. {
  85. AfxMessageBox("名字不能为空", MB_ICONINFORMATION);
  86. return;
  87. }
  88. if (m_width < 1 || m_height < 1)
  89. {
  90. AfxMessageBox("尺寸不对", MB_ICONINFORMATION);
  91. return;
  92. }
  93. if (::FindArray(&namearray, m_name) != -1)
  94. {
  95. AfxMessageBox("已有此尺寸的记录!", MB_ICONINFORMATION);
  96. return;
  97. }
  98. CString sql;
  99. sql.Format("insert into framesize(name,width,height)values('%s','%d','%d')", m_name, m_width, m_height);
  100. g_sendhead.bsql = 1;
  101. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  102. namearray.Add(m_name);
  103. widtharray.Add(m_width);
  104. heightarray.Add(m_height);
  105. CString str;
  106. str.Format(_T("%s 宽:%d 高:%d"), m_name, m_width, m_height);
  107. m_List1.AddString(str);
  108. }
  109. void SetSize::OnBUTdel()
  110. {
  111. // TODO: Add your control notification handler code here
  112. int pos = m_List1.GetCurSel();
  113. if (pos == -1)
  114. {
  115. AfxMessageBox("请选中您要删除的项目!", MB_ICONINFORMATION);
  116. return;
  117. }
  118. if (AfxMessageBox("确认删除吗?", MB_ICONINFORMATION | MB_YESNO) != IDYES)return;
  119. CString sql;
  120. CString name = namearray.ElementAt(pos);
  121. sql.Format("delete from framesize where name='%s' ", name);
  122. g_sendhead.bsql = 1;
  123. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  124. m_List1.DeleteString(pos);
  125. namearray.RemoveAt(pos);
  126. widtharray.RemoveAt(pos);
  127. heightarray.RemoveAt(pos);
  128. }
  129. void SetSize::SaveToFile()
  130. {
  131. }