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

📄 contextmenutextdlg.cpp

📁 Microsoft Windows CE 程序设计实例(源码1)
💻 CPP
字号:
// ContextMenuTextDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ContextMenuText.h"
#include "ContextMenuTextDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CContextMenuTextDlg dialog

CContextMenuTextDlg::CContextMenuTextDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CContextMenuTextDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CContextMenuTextDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CContextMenuTextDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CContextMenuTextDlg)
	DDX_Control(pDX, IDC_LIST1, m_ListCtrl);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CContextMenuTextDlg, CDialog)
	//{{AFX_MSG_MAP(CContextMenuTextDlg)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
	ON_NOTIFY(GN_CONTEXTMENU, IDC_LIST1,OnContextMenu)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CContextMenuTextDlg message handlers

BOOL CContextMenuTextDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	m_ListCtrl.AddString(_T("000"));
	m_ListCtrl.AddString(_T("111"));
	m_ListCtrl.AddString(_T("222"));
	m_ListCtrl.AddString(_T("333"));
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CContextMenuTextDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	
//	if( m_ListCtrl.GetSelCount() == 1 )
//   {
		m_ListCtrl.SetCurSel(m_ListCtrl.GetSelCount()-1);
      SHRecognizeGesture(point);
      return; // it is important!!!!
 //   }	
	CDialog::OnLButtonDown(nFlags, point);
}
void CContextMenuTextDlg::OnContextMenu(NMHDR* pNMHDR, LRESULT* pResult)
{
  NMRGINFO* pnmhdr = reinterpret_cast <NMRGINFO*>(pNMHDR);
  POINT point = pnmhdr->ptAction;

 CMenu Menu;
	Menu.LoadMenu(IDR_MENUBAR1);
 // HMENU hMenu = Menu.GetSafeHmenu();
	CMenu *popMenu = Menu.GetSubMenu(0);
  int uSelectedCount = m_ListCtrl.GetSelCount();
// if( uSelectedCount == 1 )
	  popMenu->TrackPopupMenu(TPM_TOPALIGN, point.x, point.y,&m_ListCtrl);
}

⌨️ 快捷键说明

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