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

📄 mylistctrl.cpp

📁 这是一个PDA上的铃声程序
💻 CPP
字号:
// MyListCtrl.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "MyListCtrl.h"
#include "ERingDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl

CMyListCtrl::CMyListCtrl()
{
	pNotify=NULL;
	pPoint=NULL;
}

CMyListCtrl::~CMyListCtrl()
{
}


BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
	//{{AFX_MSG_MAP(CMyListCtrl)
	ON_WM_LBUTTONDOWN()
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl message handlers

void CMyListCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
 
	SHORT sCurSelidx = -1;
	if( FALSE == GetSelectedItemIdx( point, &sCurSelidx ) )
		return;
	if (pNotify!=NULL&&SHRecognizeGesture(point,FALSE)){
		HMENU hMenu;
		CMenu popmenu;
		hMenu = LoadMenu (AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_RIGHTMENU));
		if (hMenu){
			CMenu popmenu;
			popmenu.Attach(hMenu);
			CMenu* smenu=popmenu.GetSubMenu (0);
//			bAbout=true;
			if (pPoint)
				*pPoint=point;
			ClientToScreen(&point);
			smenu->TrackPopupMenu(TPM_LEFTALIGN   , point.x, point.y, pNotify, NULL);
//			bAbout=false;
			smenu->DestroyMenu();
			DestroyMenu (hMenu);	
		}
	}
	else
		CListCtrl::OnLButtonDown(nFlags, point);
}

BOOL CMyListCtrl::GetSelectedItemIdx(CPoint &point, SHORT *pwIdx)
{
	INT nIndex = GetTopIndex();
	INT nLastVisibleIdx = nIndex + GetCountPerPage();
	
	if( GetItemCount() < nLastVisibleIdx )
	nLastVisibleIdx = GetItemCount();
	 
	while( nIndex <= nLastVisibleIdx )
	{
		CRect rect;
		GetItemRect( nIndex, &rect, LVIR_BOUNDS);
		if( rect.PtInRect( point ) )
		{
			*pwIdx = nIndex;
			return TRUE;
		}
		nIndex++;
	}
	*pwIdx = -1;
	return FALSE;

}

void CMyListCtrl::SetNotifyWnd(CWnd *pWnd)
{
	if (pWnd)
		pNotify=pWnd;
}

void CMyListCtrl::SetPoint(CPoint *pPt)
{
	if (pPt)
		pPoint=pPt;
}

void CMyListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	if (nChar==0x86||nChar==VK_RETURN){
		((CERingDlg *)pNotify)->m_exit=false;
	}

	CListCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

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