分类: C/C++
2008-03-18 16:18:31
#include
在类中添加私有成员变量:
private: HIMAGELIST m_hImlIcons; HWND m_hListCtrl;
步骤五:添加WM_INITDIALG消息响应事件,并在事件处理函数中添加如下代码:
SendDlgItemMessage(IDC_PROGRESS1,PBM_SETBARCOLOR,0,(LPARAM)RGB(0,128,0)); SendDlgItemMessage(IDC_PROGRESS1,PBM_SETPOS,0,0); m_hListCtrl = GetDlgItem(IDC_LIST1); m_hImlIcons = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 2, 0); HICON hicon; // handle to icon hicon = LoadIcon(_Module.m_hInstResource,MAKEINTRESOURCE(IDI_ICON_LIST)); ImageList_AddIcon(m_hImlIcons,hicon); ListView_SetImageList(m_hListCtrl,m_hImlIcons,LVSIL_SMALL); ListView_SetExtendedListViewStyle(m_hListCtrl,LVS_EX_FULLROWSELECT); //::GetWindowLong(m_hListCtrl,GWL_EXSTYLE | GWL_EXSTYLE) & LVS_EX_FULLROWSELECT); LV_COLUMN lvCol; lvCol.mask = LVCF_TEXT | LVCF_WIDTH; lvCol.fmt = LVCFMT_LEFT; lvCol.iSubItem = 0; //添加表头 lvCol.cx = 200; lvCol.pszText = "文件名称"; ListView_InsertColumn(m_hListCtrl,0,&lvCol); lvCol.cx = 80; lvCol.pszText = "文件大小"; ListView_InsertColumn(m_hListCtrl,1,&lvCol);步骤六:添加WM_ DESTROY消息响应事件,并在事件处理函数中添加如下代码:
ImageList_Destroy(m_hImlIcons);
ListView_DeleteAllItems(m_hListCtrl); LVITEM lvItem; lvItem.mask = LVIF_TEXT | LVIF_IMAGE; lvItem.state = 0; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = "我爱VC.C++"; lvItem.iImage = 0; ListView_InsertItem(m_hListCtrl, &lvItem); ListView_SetItemText(m_hListCtrl,0,1,"1024"); SendDlgItemMessage(IDC_PROGRESS1,PBM_SETPOS,50,0);
Fire_AtlEven(0,"方法开始");
结尾处添加:
Fire_AtlEven(1,"方法结束");
步骤十一:建立测试程序TestAtlDlg。
在测试程序中接收连接点事件:
BEGIN_EVENTSINK_MAP(CTestAtlDlg, CDialog) ON_EVENT(CTestAtlDlg, IDC_ATLCOMP1, 1 /* Atl */, OnAtlEvent, VTS_I4 VTS_BSTR) //step 2 //}}AFX_EVENTSINK_MAP END_EVENTSINK_MAP()