menudlg.cpp
来自「WinCE 下实现Listctrl自画」· C++ 代码 · 共 111 行
CPP
111 行
// MenuDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ListView.h"
#include "MenuDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMenuDlg dialog
CMenuDlg::CMenuDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMenuDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMenuDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CMenuDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMenuDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMenuDlg, CDialog)
//{{AFX_MSG_MAP(CMenuDlg)
// NOTE: the ClassWizard will add message map macros here
ON_NOTIFY(NM_CLICK, 1, OnClickList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMenuDlg message handlers
BOOL CMenuDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetWindowPos(NULL,264,36,120,170,NULL);
// TODO: Add extra initialization here
newlist = new CMenuListCtrl;
newlist->Create(WS_VISIBLE |LVS_REPORT|LVS_OWNERDRAWFIXED/* LVS_ICON | LVS_NOSCROLL*/ ,
CRect(0,0,120,165), this,1);
newlist->SetTextBkColor(CLR_NONE);
newlist->SetBkImage(IDB_BMP_ITEM);
newlist->InitVScroll();
newlist->HideScrollBars(LCSB_CLIENTDATA);
newlist->OnInitialUpdate();
int i=newlist->GetItemCount();
newlist->InsertImgTextItems(i+1, 32,_T("打开"));
newlist->InsertImgTextItems(i+1, 32,_T("复制"));
newlist->InsertImgTextItems(i+1, 32,_T("删除"));
newlist->InsertImgTextItems(i+1, 32,_T("粘贴"));
newlist->InsertImgTextItems(i+1, 32,_T("加入"));
newlist->InsertImgTextItems(i+1, 32,_T("添加"));
newlist->InsertImgTextItems(i+1, 32,_T("演示"));
return TRUE; // return TRUE unless you set the focus to a control
}
void CMenuDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if(pNMListView->iItem != -1)
{
CString strtemp;
strtemp.Format(_T("单击的是第%d行第%d列"),
pNMListView->iItem, pNMListView->iSubItem);
TCHAR szBuf[1024];
LVITEM lvi;
lvi.iItem = pNMListView->iItem;
lvi.iSubItem = 0;
lvi.mask = LVIF_TEXT;
lvi.pszText = szBuf;
lvi.cchTextMax = 1024;
newlist->GetItem(&lvi);
CWnd *parent=GetParent();
if (parent!=NULL)
{
parent->SendMessage(IDOK, NULL,NULL);
::AfxMessageBox(szBuf);
}
}
//////////////////////////////////////////////////////////////////////////
*pResult = 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?