newlistbox.cpp

来自「利用OLEDB以数据库的方式打开Excell文件」· C++ 代码 · 共 92 行

CPP
92
字号
// NewListBox.cpp : implementation file
//

#include "stdafx.h"
#include "DBManager.h"
#include "NewListBox.h"
#include "resource.h"

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

/////////////////////////////////////////////////////////////////////////////
// CNewListBox

CNewListBox::CNewListBox()
{
}

CNewListBox::~CNewListBox()
{
}


BEGIN_MESSAGE_MAP(CNewListBox, CListBox)
	ON_WM_CONTEXTMENU()
	//{{AFX_MSG_MAP(CNewListBox)
	ON_WM_RBUTTONDOWN()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNewListBox message handlers

void CNewListBox::OnContextMenu(CWnd*, CPoint point)
{
	// CG: This block was added by the Pop-up Menu component	{		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(CG_IDR_POPUP_NEW_LIST_BOX));		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);	}
}

void CNewListBox::OnRButtonDown(UINT nFlags, CPoint point) 
{

	CPoint ptCursor;
	::GetCursorPos( &ptCursor );

	CMenu menu;
	VERIFY(menu.LoadMenu(CG_IDR_POPUP_NEW_LIST_BOX));

	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, ptCursor.x , ptCursor.y ,
		pWndPopupOwner);
	CListBox::OnRButtonDown(nFlags, point);
}

void CNewListBox::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CListBox::OnLButtonDown(nFlags, point);
}

⌨️ 快捷键说明

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