ReportColPage.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. // ReportColPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "IDE.h"
  5. #include "ReportColPage.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. IMPLEMENT_SERIAL(CColPro, CObject, 0)
  12. CColPro::CColPro()
  13. {
  14. m_strTitle = g_strColumnName;
  15. m_strVar = g_strVarName3;
  16. m_strFormat = "####";
  17. }
  18. CColPro::~CColPro()
  19. {
  20. }
  21. CColPro* CColPro::Clone(void)
  22. {
  23. CColPro *pObj = new CColPro;
  24. *((CColPro*)pObj) = *(CColPro*)this;
  25. pObj->m_strTitle = m_strTitle;
  26. pObj->m_strVar = m_strVar;
  27. pObj->m_strFormat = m_strFormat;
  28. return pObj;
  29. }
  30. void CColPro::Serialize(CArchive& ar)
  31. {
  32. CObject::Serialize(ar);
  33. if(ar.IsStoring())
  34. {
  35. ar << m_strTitle;
  36. ar << m_strVar;
  37. ar << m_strFormat;
  38. }
  39. else
  40. {
  41. ar >> m_strTitle;
  42. ar >> m_strVar;
  43. ar >> m_strFormat;
  44. }
  45. }
  46. CColPro& CColPro::operator=(CColPro& Obj)
  47. {
  48. m_strTitle = Obj.m_strTitle;
  49. m_strVar = Obj.m_strVar;
  50. m_strFormat = Obj.m_strFormat;
  51. return *this;
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CReportColPage property page
  55. IMPLEMENT_DYNCREATE(CReportColPage, CPropertyPage)
  56. CReportColPage::CReportColPage() : CPropertyPage(CReportColPage::IDD)
  57. {
  58. //{{AFX_DATA_INIT(CReportColPage)
  59. m_strTitle = g_strColumnName;
  60. m_strVar = _T("");
  61. m_strFormat = _T("");
  62. //}}AFX_DATA_INIT
  63. }
  64. CReportColPage::~CReportColPage()
  65. {
  66. }
  67. void CReportColPage::DoDataExchange(CDataExchange* pDX)
  68. {
  69. CPropertyPage::DoDataExchange(pDX);
  70. //{{AFX_DATA_MAP(CReportColPage)
  71. DDX_Text(pDX, IDC_TITILE, m_strTitle);
  72. DDX_Text(pDX, IDC_VAR, m_strVar);
  73. DDX_CBString(pDX, IDC_FORMAT, m_strFormat);
  74. /*DDX_Control(pDX, IDC_COLLIST, m_ctrlList);*/
  75. //}}AFX_DATA_MAP
  76. }
  77. BEGIN_MESSAGE_MAP(CReportColPage, CPropertyPage)
  78. //{{AFX_MSG_MAP(CReportColPage)
  79. ON_BN_CLICKED(IDC_ADD, OnAdd)
  80. ON_BN_CLICKED(IDC_REVISE, OnRevise)
  81. ON_BN_CLICKED(IDC_DEL, OnDel)
  82. ON_BN_CLICKED(IDC_UP, OnUp)
  83. ON_BN_CLICKED(IDC_DOWN, OnDown)
  84. ON_BN_CLICKED(IDC_SELVAR, OnSelvar)
  85. //}}AFX_MSG_MAP
  86. END_MESSAGE_MAP()
  87. /////////////////////////////////////////////////////////////////////////////
  88. // CReportColPage message handlers
  89. void CReportColPage::OnAdd()
  90. {
  91. UpdateData(TRUE);
  92. CColPro* pObj = new CColPro();
  93. pObj->m_strVar = m_strVar;
  94. pObj->m_strTitle = m_strTitle;
  95. pObj->m_strFormat = m_strFormat;
  96. m_colList.AddTail( pObj );
  97. FreshList();
  98. }
  99. void CReportColPage::OnRevise()
  100. {
  101. // 修改数据,然后刷新界面
  102. UpdateData(true);
  103. #if 0
  104. int row = m_ctrlList.GetRow();
  105. POSITION pos = m_colList.GetHeadPosition();
  106. int i = 0;
  107. while (pos!=NULL)
  108. {
  109. i++;
  110. CColPro* pPro = m_colList.GetNext(pos);
  111. if ( i == row)
  112. {
  113. pPro->m_strVar = m_strVar;
  114. pPro->m_strTitle = m_strTitle;
  115. pPro->m_strFormat = m_strFormat;
  116. break;
  117. }
  118. }
  119. FreshList();
  120. #endif
  121. }
  122. void CReportColPage::OnDel()
  123. {
  124. // 修改数据,然后刷新界面
  125. #if 0
  126. int row = m_ctrlList.GetRow();
  127. POSITION pos = m_colList.GetHeadPosition();
  128. int i = 0;
  129. while (pos!=NULL)
  130. {
  131. i++;
  132. if ( i == row)
  133. {
  134. m_colList.RemoveAt(pos);
  135. break;
  136. }
  137. CColPro* pPro = m_colList.GetNext(pos);
  138. }
  139. FreshList();
  140. #endif
  141. }
  142. void CReportColPage::OnUp()
  143. {
  144. #if 0
  145. int row = m_ctrlList.GetRow();
  146. POSITION pos = m_colList.GetHeadPosition();
  147. int i = 0;
  148. CColPro* lastPro = NULL;
  149. while (pos!=NULL)
  150. {
  151. i++;
  152. CColPro* pPro = m_colList.GetNext(pos);
  153. if ( i == row)
  154. {
  155. CColPro pro;
  156. pro = *pPro;
  157. *pPro = *lastPro;
  158. *lastPro = pro;
  159. break;
  160. }
  161. lastPro = pPro;
  162. }
  163. FreshList();
  164. #endif
  165. }
  166. void CReportColPage::OnDown()
  167. {
  168. #if 0
  169. int row = m_ctrlList.GetRow();
  170. POSITION pos = m_colList.GetHeadPosition();
  171. int i = 0;
  172. while (pos!=NULL)
  173. {
  174. i++;
  175. CColPro* pPro = m_colList.GetNext(pos);
  176. if ( i == row)
  177. {
  178. CColPro* nextPro = m_colList.GetNext(pos);
  179. CColPro pro;
  180. pro = *pPro;
  181. *pPro = *nextPro;
  182. *nextPro = pro;
  183. break;
  184. }
  185. }
  186. FreshList();
  187. #endif
  188. }
  189. void CReportColPage::SetVal(int row, int col, CString str)
  190. {
  191. #if 0
  192. m_ctrlList.SetRow(row);
  193. m_ctrlList.SetCol(col);
  194. m_ctrlList.SetText(str);
  195. #endif
  196. }
  197. BOOL CReportColPage::OnInitDialog()
  198. {
  199. CPropertyPage::OnInitDialog();
  200. FreshList();
  201. return TRUE;
  202. }
  203. void CReportColPage::FreshList()
  204. {
  205. #if 0
  206. m_ctrlList.Clear();
  207. m_ctrlList.SetCols(3);
  208. m_ctrlList.SetColWidth(0, 1400);
  209. m_ctrlList.SetColWidth(1, 1480);
  210. m_ctrlList.SetColWidth(2, 950);
  211. SetVal(0, 0, g_strStrVar);
  212. SetVal(0, 1, g_strHeader);
  213. SetVal(0, 2, g_strFormat);
  214. int count = m_colList.GetCount();
  215. int i = 1;
  216. POSITION pos = m_colList.GetHeadPosition();
  217. while (pos!=NULL)
  218. {
  219. CColPro* pPro = m_colList.GetNext(pos);
  220. SetVal(i, 0, pPro->m_strVar);
  221. SetVal(i, 1, pPro->m_strTitle);
  222. SetVal(i, 2, pPro->m_strFormat);
  223. i++;
  224. }
  225. #endif
  226. }
  227. BEGIN_EVENTSINK_MAP(CReportColPage, CPropertyPage)
  228. //{{AFX_EVENTSINK_MAP(CReportColPage)
  229. ON_EVENT(CReportColPage, IDC_COLLIST, -600 /* Click */, OnClickCollist, VTS_NONE)
  230. //}}AFX_EVENTSINK_MAP
  231. END_EVENTSINK_MAP()
  232. void CReportColPage::OnClickCollist()
  233. {
  234. #if 0
  235. int row = m_ctrlList.GetRow();
  236. POSITION pos = m_colList.GetHeadPosition();
  237. int i = 0;
  238. while (pos!=NULL)
  239. {
  240. i++;
  241. CColPro* pPro = m_colList.GetNext(pos);
  242. if ( i == row)
  243. {
  244. m_strVar = pPro->m_strVar;
  245. m_strTitle = pPro->m_strTitle;
  246. m_strFormat = pPro->m_strFormat;
  247. UpdateData(false);
  248. break;
  249. }
  250. }
  251. #endif
  252. }
  253. void CReportColPage::OnSelvar()
  254. {
  255. }