?? mylistctrl.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 + -