MFC中ListCtrl添加图标,更改图标


在MFC中向ListCtrl的subItem0添加icon图标,用定时器定时去改变图标。
资源截图
代码片段和文件信息

// ListSubItem0Icon.cpp : Defines the class behaviors for the application.
//

#include “stdafx.h“
#include “ListSubItem0Icon.h“
#include “ListSubItem0IconDlg.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CListSubItem0IconApp

BEGIN_MESSAGE_MAP(CListSubItem0IconApp CWinApp)
ON_COMMAND(ID_HELP &CWinApp::onhelp)
END_MESSAGE_MAP()


// CListSubItem0IconApp construction

CListSubItem0IconApp::CListSubItem0IconApp()
{
// support Restart Manager
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;

// TODO: add construction code here
// Place all significant initialization in InitInstance
}


// The one and only CListSubItem0IconApp object

CListSubItem0IconApp theApp;


// CListSubItem0IconApp initialization

BOOL CListSubItem0IconApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles.  Otherwise any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);

CWinApp::InitInstance();


AfxEnableControlContainer();

// Create the shell manager in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;

// Activate “Windows Native“ visual manager for enabling themes in MFC controls
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T(“Local AppWizard-Generated Applications“));

CListSubItem0IconDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel
}
else if (nResponse == -1)
{
TRACE(traceAppMsg 0 “Warning: dialog creation failed so application is terminating unexpectedly.
“);
TRACE(traceAppMsg 0 “Warning: if you are using MFC controls on the dialog you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.
“);
}

// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}

#ifndef _AFXDLL
ControlBarCleanUp();
#endif

// Since the dialog has been closed return FALSE so that we exit 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     27648  2017-11-23 11:09  ListSubItem0Icon.vsListSubItem0Iconv14.suo

     文件     216576  2017-11-23 11:08  ListSubItem0IconDebugListSubItem0Icon.exe

     文件     111928  2017-11-23 09:54  ListSubItem0IconListSubItem0IconListSubItem0Icon.aps

     文件       3095  2017-11-23 09:35  ListSubItem0IconListSubItem0IconListSubItem0Icon.cpp

     文件        565  2017-11-23 09:35  ListSubItem0IconListSubItem0IconListSubItem0Icon.h

     文件      12572  2017-11-23 09:54  ListSubItem0IconListSubItem0IconListSubItem0Icon.rc

     文件      10650  2017-11-23 09:55  ListSubItem0IconListSubItem0IconListSubItem0Icon.vcxproj

     文件       2343  2017-11-23 09:55  ListSubItem0IconListSubItem0IconListSubItem0Icon.vcxproj.filters

     文件       5392  2017-11-23 11:08  ListSubItem0IconListSubItem0IconListSubItem0IconDlg.cpp

     文件        879  2017-11-23 11:07  ListSubItem0IconListSubItem0IconListSubItem0IconDlg.h

     文件       5413  2017-11-23 09:35  ListSubItem0IconListSubItem0IconReadMe.txt

    .......     67777  2015-09-20 17:20  ListSubItem0IconListSubItem0Icon
esListSubItem0Icon.ico

     文件        816  2017-11-23 09:35  ListSubItem0IconListSubItem0Icon
esListSubItem0Icon.rc2

     文件       1150  2017-11-23 09:53  ListSubItem0IconListSubItem0Icon
es
esp_faild.ico

     文件       1150  2017-11-23 09:53  ListSubItem0IconListSubItem0Icon
es
esp_ok.ico

     文件       1558  2017-11-23 09:57  ListSubItem0IconListSubItem0IconResource.h

     文件        218  2017-11-23 09:35  ListSubItem0IconListSubItem0Iconstdafx.cpp

     文件       1753  2017-11-23 09:35  ListSubItem0IconListSubItem0Iconstdafx.h

     文件        314  2017-11-23 09:35  ListSubItem0IconListSubItem0Icon argetver.h

     文件       1330  2017-11-23 09:35  ListSubItem0IconListSubItem0Icon.sln

     文件   69332992  2017-11-23 11:09  ListSubItem0IconListSubItem0Icon.VC.db

     目录          0  2017-11-23 09:35  ListSubItem0Icon.vsListSubItem0Iconv14

     目录          0  2017-11-23 09:35  ListSubItem0Icon.vsListSubItem0Icon

     目录          0  2017-11-23 09:53  ListSubItem0IconListSubItem0Icon
es

    ...D.H.         0  2017-11-23 09:35  ListSubItem0Icon.vs

     目录          0  2017-11-23 11:09  ListSubItem0IconDebug

     目录          0  2017-11-23 11:09  ListSubItem0IconListSubItem0Icon

     目录          0  2017-11-23 11:09  ListSubItem0Icon

----------- ---------  ---------- -----  ----

             69806119                    28

............此处省略1个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)