BookAdminView.cpp
上传用户:weisheen
上传日期:2022-07-09
资源大小:19390k
文件大小:4k
源码类别:

ActiveX/DCOM/ATL

开发平台:

Visual C++

  1. // BookAdminView.cpp : implementation of the CBookAdminView class
  2. //
  3. #include "stdafx.h"
  4. #include "BookAdmin.h"
  5. #include "BookAdminDoc.h"
  6. #include "BookAdminView.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CBookAdminView
  14. IMPLEMENT_DYNCREATE(CBookAdminView, CListView)
  15. BEGIN_MESSAGE_MAP(CBookAdminView, CListView)
  16. //{{AFX_MSG_MAP(CBookAdminView)
  17. // NOTE - the ClassWizard will add and remove mapping macros here.
  18. //    DO NOT EDIT what you see in these blocks of generated code!
  19. //}}AFX_MSG_MAP
  20. // Standard printing commands
  21. ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
  22. ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
  23. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
  24. END_MESSAGE_MAP()
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CBookAdminView construction/destruction
  27. CBookAdminView::CBookAdminView()
  28. {
  29. // TODO: add construction code here
  30. }
  31. CBookAdminView::~CBookAdminView()
  32. {
  33. }
  34. BOOL CBookAdminView::PreCreateWindow(CREATESTRUCT& cs)
  35. {
  36. // TODO: Modify the Window class or styles here by modifying
  37. //  the CREATESTRUCT cs
  38. return CListView::PreCreateWindow(cs);
  39. }
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CBookAdminView drawing
  42. void CBookAdminView::OnDraw(CDC* pDC)
  43. {
  44. CBookAdminDoc* pDoc = GetDocument();
  45. ASSERT_VALID(pDoc);
  46. CListCtrl& refCtrl = GetListCtrl();
  47. refCtrl.InsertItem(0, "Item!");
  48. // TODO: add draw code for native data here
  49. }
  50. void CBookAdminView::OnInitialUpdate()
  51. {
  52. CListView::OnInitialUpdate();
  53. //创建列;
  54. this->GetListCtrl().InsertColumn(0,"BookName",LVCFMT_CENTER,200);
  55. this->GetListCtrl().InsertColumn(1,"BookAuther",LVCFMT_CENTER,200);
  56. //添加数据;
  57. POSITION ps;
  58. ps=this->GetDocument()->allBooks.GetHeadPosition();
  59. while(ps!=NULL)
  60. {
  61. BookEntity* be=this->GetDocument()->allBooks.GetNext(ps);
  62. this->GetListCtrl().InsertItem(0,be->BookName);
  63. this->GetListCtrl().SetItemText(0,1,be->BookAuthor);
  64. }
  65. // TODO: You may populate your ListView with items by directly accessing
  66. //  its list control through a call to GetListCtrl().
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CBookAdminView printing
  70. BOOL CBookAdminView::OnPreparePrinting(CPrintInfo* pInfo)
  71. {
  72. // default preparation
  73. return DoPreparePrinting(pInfo);
  74. }
  75. void CBookAdminView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  76. {
  77. // TODO: add extra initialization before printing
  78. }
  79. void CBookAdminView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  80. {
  81. // TODO: add cleanup after printing
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CBookAdminView diagnostics
  85. #ifdef _DEBUG
  86. void CBookAdminView::AssertValid() const
  87. {
  88. CListView::AssertValid();
  89. }
  90. void CBookAdminView::Dump(CDumpContext& dc) const
  91. {
  92. CListView::Dump(dc);
  93. }
  94. CBookAdminDoc* CBookAdminView::GetDocument() // non-debug version is inline
  95. {
  96. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBookAdminDoc)));
  97. return (CBookAdminDoc*)m_pDocument;
  98. }
  99. #endif //_DEBUG
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CBookAdminView message handlers
  102. void CBookAdminView::OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
  103. {
  104. //TODO: add code to react to the user changing the view style of your window
  105. }