⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listctrlview.cpp

📁 一个资产管理软件
💻 CPP
字号:
// ListCtrlView.cpp : implementation file
//

#include "stdafx.h"
#include "PropertyManager.h"
#include "ListCtrlView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CListCtrlView

IMPLEMENT_DYNCREATE(CListCtrlView, CFormView)

CListCtrlView::CListCtrlView()
	: CFormView(CListCtrlView::IDD)
{
	//{{AFX_DATA_INIT(CListCtrlView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CListCtrlView::~CListCtrlView()
{
}

void CListCtrlView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListCtrlView)
	DDX_Control(pDX, IDC_LIST, m_listCtrl);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CListCtrlView, CFormView)
	//{{AFX_MSG_MAP(CListCtrlView)
	ON_WM_SIZE()
	ON_NOTIFY(NM_RCLICK, IDC_LIST, OnRclickList)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CListCtrlView diagnostics

#ifdef _DEBUG
void CListCtrlView::AssertValid() const
{
	CFormView::AssertValid();
}

void CListCtrlView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CListCtrlView message handlers

void CListCtrlView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	m_listCtrl.SetBkColor(RGB(240,247,233));
	m_listCtrl.SetTextBkColor(RGB(240,247,233));

	CRect rect;
	m_listCtrl.GetClientRect(&rect);

	m_listCtrl.InsertColumn(0, "From", LVCFMT_LEFT, 80/*rect.Width()/4*/);
	m_listCtrl.InsertColumn(1, "Subject", LVCFMT_LEFT, 80/*rect.Width()/4*/);
	m_listCtrl.InsertColumn(2, "Date", LVCFMT_LEFT, 80/*rect.Width()/4*/);
	m_listCtrl.InsertColumn(3, "Size", LVCFMT_LEFT, 80/*rect.Width()/4*/);	
}

void CListCtrlView::OnSize(UINT nType, int cx, int cy) 
{
	CFormView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	CFormView::ShowScrollBar(SB_VERT,FALSE);
	CFormView::ShowScrollBar(SB_HORZ,FALSE);

	if (GetSafeHwnd())
	{
		if (m_listCtrl.GetSafeHwnd())
		{
			CRect rect(0,0,cx,cy);
			m_listCtrl.MoveWindow(&rect);
		}
	}	
}

void CListCtrlView::OnOK() 
{
	// TODO: Add your control notification handler code here
	
}

void CListCtrlView::OnCancel() 
{
	// TODO: Add your control notification handler code here
	
}

void CListCtrlView::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int item=m_listCtrl.GetSelectedCount();//.GetSelectedItem();
	if (!item)//如果没有选中就不显示菜单
		return;

	CPoint point;
	GetCursorPos(&point);//GetWindowRect(&rect);
	if (point.x == -1 && point.y == -1)
	{
		//keystroke invocation
		CRect rect;
		GetClientRect(rect);
		ClientToScreen(rect);
		point = rect.TopLeft();
		point.Offset(5, 5);
	}
	CMenu menu;
	VERIFY(menu.LoadMenu(IDR_MENU_LIST_POP));
	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL);
	CWnd* pWndPopupOwner = this;
	while (pWndPopupOwner->GetStyle() & WS_CHILD)
		pWndPopupOwner = pWndPopupOwner->GetParent();
	pPopup->TrackPopupMenu(TPM_LEFTALIGN
		| TPM_RIGHTBUTTON, point.x, 
		point.y, pWndPopupOwner);
	*pResult = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -