www.pudn.com > ListViewInSDI.rar > ListViewInSDIView.cpp
// ListViewInSDIView.cpp : implementation of the CListViewInSDIView class
//
#include "stdafx.h"
#include "ListViewInSDI.h"
#include "ListViewInSDIDoc.h"
#include "ListViewInSDIView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListViewInSDIView
IMPLEMENT_DYNCREATE(CListViewInSDIView, CListView)
BEGIN_MESSAGE_MAP(CListViewInSDIView, CListView)
//{{AFX_MSG_MAP(CListViewInSDIView)
ON_COMMAND(ID_VIEW_SMALLICON, OnViewSmallicon)
ON_COMMAND(ID_VIEW_LARGEICON, OnViewLargeicon)
ON_COMMAND(ID_VIEW_LIST, OnViewList)
ON_COMMAND(ID_VIEW_DETAILS, OnViewDetails)
ON_UPDATE_COMMAND_UI(ID_VIEW_SMALLICON, OnUpdateViewSmallicon)
ON_UPDATE_COMMAND_UI(ID_VIEW_LIST, OnUpdateViewList)
ON_UPDATE_COMMAND_UI(ID_VIEW_LARGEICON, OnUpdateViewLargeicon)
ON_UPDATE_COMMAND_UI(ID_VIEW_DETAILS, OnUpdateViewDetails)
ON_WM_CONTEXTMENU()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CListView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CListView::OnFilePrintPreview)
ON_COMMAND_EX(IDM_ZOOM1,OnZoom)
ON_COMMAND_EX(IDM_ZOOM2,OnZoom)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListViewInSDIView construction/destruction
CListViewInSDIView::CListViewInSDIView()
{
}
CListViewInSDIView::~CListViewInSDIView()
{
}
BOOL CListViewInSDIView::PreCreateWindow(CREATESTRUCT& cs)
{
return CListView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CListViewInSDIView drawing
void CListViewInSDIView::OnDraw(CDC* pDC)
{
CListViewInSDIDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
void CListViewInSDIView::OnInitialUpdate()
{
CListView::OnInitialUpdate();
CListCtrl& ListCtrl = GetListCtrl();
m_LargeImageList.Create(IDB_LARGEIMAGE, 32, 1, RGB(192, 192, 192));
m_SmallImageList.Create(IDB_SMALLIMAGE, 16, 1, RGB(255, 255, 0));
ListCtrl.SetImageList(&m_LargeImageList, LVSIL_NORMAL);
ListCtrl.SetImageList(&m_SmallImageList, LVSIL_SMALL);
// insert columns
int i, j;
LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
for(i = 0; iIsKindOf(RUNTIME_CLASS(CListViewInSDIDoc)));
return (CListViewInSDIDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CListViewInSDIView message handlers
BOOL CListViewInSDIView::SetViewType(DWORD dwViewType)
{
return(ModifyStyle(LVS_TYPEMASK,dwViewType & LVS_TYPEMASK));
}
DWORD CListViewInSDIView::GetViewType()
{
return(GetStyle() & LVS_TYPEMASK);
}
void CListViewInSDIView::OnViewSmallicon()
{
if (GetViewType() != LVS_SMALLICON)
SetViewType(LVS_SMALLICON);
}
void CListViewInSDIView::OnViewLargeicon()
{
if (GetViewType() != LVS_ICON)
SetViewType(LVS_ICON);
}
void CListViewInSDIView::OnViewList()
{
if (GetViewType() != LVS_LIST)
SetViewType(LVS_LIST);
}
void CListViewInSDIView::OnViewDetails()
{
if ((GetViewType() != LVS_REPORT))
SetViewType(LVS_REPORT);
}
void CListViewInSDIView::OnUpdateViewSmallicon(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(GetViewType() == LVS_SMALLICON);
}
void CListViewInSDIView::OnUpdateViewList(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(GetViewType() == LVS_LIST);
}
void CListViewInSDIView::OnUpdateViewLargeicon(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(GetViewType() == LVS_ICON);
}
void CListViewInSDIView::OnUpdateViewDetails(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck((GetViewType() == LVS_REPORT)/* && !GetFullRowSel()*/);
}
void CListViewInSDIView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
}
void CListViewInSDIView::OnZoom(UINT nID)
{
if (nID == IDM_ZOOM1) {
AfxMessageBox("No 1");
}
else {
AfxMessageBox("No 2");
}
}