// MFCdvaView.cpp : implementation of the CMFCdvaView class // #include "stdafx.h" #include "MFCdva.h" #include "MFCdvaDoc.h" #include "MFCdvaView.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMFCdvaView IMPLEMENT_DYNCREATE(CMFCdvaView, CListView) BEGIN_MESSAGE_MAP(CMFCdvaView, CListView) END_MESSAGE_MAP() // CMFCdvaView construction/destruction CMFCdvaView::CMFCdvaView() { // TODO: add construction code here } CMFCdvaView::~CMFCdvaView() { } BOOL CMFCdvaView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CListView::PreCreateWindow(cs); } void CMFCdvaView::OnInitialUpdate() { CListView::OnInitialUpdate(); // TODO: You may populate your ListView with items by directly accessing // its list control through a call to GetListCtrl(). this->ModifyStyle(LVS_TYPEMASK, LVS_REPORT); CRect rect; this->GetClientRect(&rect); int firstWidth = 100; int secondWidth = 100; int lastWidth = rect.right - rect.left - firstWidth - secondWidth; CListCtrl& list = GetListCtrl(); list.InsertColumn(0,"Occupation",LVCFMT_LEFT,firstWidth); list.InsertColumn(1,"First Name",LVCFMT_RIGHT,secondWidth); list.InsertColumn(2,"Last Name",LVCFMT_LEFT,lastWidth); list.DeleteAllItems(); CString str = "Instructor"; int nItem = list.InsertItem(0,str); list.SetItemText(nItem,1,"Jim"); list.SetItemText(nItem,2,"Fawcett"); str = "Character"; nItem = list.InsertItem(1,str); list.SetItemText(nItem,1,"Alfred"); list.SetItemText(nItem,2,"Neumann"); str = "Hostess"; nItem = list.InsertItem(2,str); list.SetItemText(nItem,1,"Lucretia"); list.SetItemText(nItem,2,"Borgia"); } // CMFCdvaView diagnostics #ifdef _DEBUG void CMFCdvaView::AssertValid() const { CListView::AssertValid(); } void CMFCdvaView::Dump(CDumpContext& dc) const { CListView::Dump(dc); } CMFCdvaDoc* CMFCdvaView::GetDocument() const // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMFCdvaDoc))); return (CMFCdvaDoc*)m_pDocument; } #endif //_DEBUG // CMFCdvaView message handlers