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

📄 computertablectrl.cpp

📁 用数据库控制树型控件现实内容的例子
💻 CPP
字号:
// ComputerTableCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "Kill.h"
#include "ComputerTableCtrl.h"

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

/////////////////////////////////////////////////////////////////////////////
// CComputerTableCtrl

CComputerTableCtrl::CComputerTableCtrl()
{
}

CComputerTableCtrl::~CComputerTableCtrl()
{
}


BEGIN_MESSAGE_MAP(CComputerTableCtrl, CListCtrl)
	//{{AFX_MSG_MAP(CComputerTableCtrl)
	ON_WM_CONTEXTMENU()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CComputerTableCtrl message handlers



void CComputerTableCtrl::OnContextMenu(CWnd* pWnd, CPoint point) 
{
	// TODO: Add your message handler code here
	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_COMPUTER_POPUP_MENU));
	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL);
	CWnd* pWndPopupOwner = this;

	POSITION pos = GetFirstSelectedItemPosition();
	int nItem;
	if (pos == NULL)
	{
		pPopup->EnableMenuItem(IDR_COMPUTER_DELETE,false);
		pPopup->EnableMenuItem(IDR_COMPUTER_INSTALL,false);
		pPopup->EnableMenuItem(IDR_COMPUTER_UNINSTALL,true);
		pPopup->EnableMenuItem(IDR_CHANGEPARENG_,true);
		TRACE0("No items were selected!\n");
	}
	else
	{
		nItem = GetNextSelectedItem(pos);
		TRACE1("Item %d was selected!\n", nItem);
	}
/*
	CString s=GetItemText(nItem, 3 );
	if(s.Compare("T")==0)
	{
		pPopup->RemoveMenu(4,MF_BYPOSITION);
	}
	else
	{
		pPopup->RemoveMenu(5,MF_BYPOSITION);
	}
*/

	while (pWndPopupOwner->GetStyle() & WS_CHILD)
		pWndPopupOwner = pWndPopupOwner->GetParent();

	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
		pWndPopupOwner);			
}

⌨️ 快捷键说明

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