// ListCtrlDemoDlg.cpp : implementation file
//
// Written by matt weagle (matt_weagle@hotmail.com)
// Copyright (c) 2000.
//
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included. If
// the source code in this file is used in any commercial application
// then a simple email would be nice.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage whatsoever.
// Consider yourself lucky if it works, unlucky if it doesn't.
//
// Thanks to Chris Maunder (chris@codeproject.com) for the
// foregoing disclaimer.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this
// file.
//
#include "stdafx.h"
#include "ListCtrlDemo.h"
#include "ListCtrlDemoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "Hyperlink.h"
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CHyperLink m_cEmail;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Control(pDX, IDC_EMAIL, m_cEmail);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListCtrlDemoDlg dialog
CListCtrlDemoDlg::CListCtrlDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CListCtrlDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CListCtrlDemoDlg)
m_nItems = 100;
m_nSelectItem = 0;
m_bImage = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CListCtrlDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CListCtrlDemoDlg)
DDX_Control(pDX, IDC_LOG, m_Log);
DDX_Control(pDX, IDC_LIST_CTRL, m_cListCtrl);
DDX_Control(pDX, IDC_LIST_CTRL_MODE, m_cTabListMode);
DDX_Text(pDX, IDC_LIST_CTRL_NUMITEMS, m_nItems);
DDV_MinMaxInt(pDX, m_nItems, 0, 32257);
DDX_Text(pDX, IDC_LIST_CTRL_SELECTITEM, m_nSelectItem);
DDV_MinMaxInt(pDX, m_nSelectItem, 0, 32567);
DDX_Check(pDX, IDC_BK_IMAGE, m_bImage);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CListCtrlDemoDlg, CDialog)
//{{AFX_MSG_MAP(CListCtrlDemoDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_NOTIFY(TCN_SELCHANGE, IDC_LIST_CTRL_MODE, OnSelchangeListCtrlMode)
ON_BN_CLICKED(IDC_UPDATE_ITEM_COUNT, OnUpdateItemCount)
ON_BN_CLICKED(IDC_STYLES_EX, OnStylesEx)
ON_BN_CLICKED(IDC_STYLES, OnStyles)
ON_BN_CLICKED(IDC_GET_SELECTED, OnGetSelected)
ON_BN_CLICKED(IDC_ITEM_SELECT, OnItemSelect)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_CTRL, OnItemchangedListCtrl)
ON_NOTIFY(NM_CLICK, IDC_LIST_CTRL, OnClickListCtrl)
ON_NOTIFY(NM_RCLICK, IDC_LIST_CTRL, OnRclickListCtrl)
ON_BN_CLICKED(IDC_CLEAR_LOG, OnClearLog)
ON_BN_CLICKED(IDC_BK_IMAGE, OnBkImage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListCtrlDemoDlg message handlers
BOOL CListCtrlDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// Initial extended style for the list control on this dialog
DWORD dwStyle = m_cListCtrl.GetExtendedStyle();
dwStyle |= LVS_EX_FULLROWSELECT;
m_cListCtrl.SetExtendedStyle(dwStyle);
// initialize the standard and custom hot cursors
m_hCustomHotCursor= AfxGetApp()->LoadCursor(IDC_HOTCURSOR);
m_hHotCursor= m_cListCtrl.GetHotCursor();
m_bHotCursor = FALSE;
// Setup the tab header
InitTabCtrl();
// Setup the column headings
InitListCtrlCols();
// Create the image list that is attached to the list control
InitImageList();
// Insert the default dummy items
InsertItems();
return TRUE; // return TRUE unless you set the focus to a control
}
void CListCtrlDemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CListCtrlDemoDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CListCtrlDemoDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
/////////////////////////////////////////////////////////////////////////////
/*
InitImageList
Create the image list that is associated with the list control. Then
attach the list of images to the control so that we can add items with
images.
Params
None
Returns
BOOL Image list created and attached?
*/
/////////////////////////////////////////////////////////////////////////////
BOOL CListCtrlDemoDlg::InitImageList()
{
// Create 256 color image lists
HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR8 |ILC_MASK , 8, 1);
m_cImageListNormal.Attach(hList);
hList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 8, 1);
m_cImageListSmall.Attach(hList);
// Load the large icons
CBitmap cBmp;
cBmp.LoadBitmap(IDB_IMAGES_NORMAL);
m_cImageListNormal.Add(&cBmp, RGB(255,0, 255));
cBmp.DeleteObject();
// Load the small icons
cBmp.LoadBitmap(IDB_IMAGES_SMALL);
m_cImageListSmall.Add(&cBmp, RGB(255,0, 255));
// Attach them
m_cListCtrl.SetImageList(&m_cImageListNormal, LVSIL_NORMAL);
m_cListCtrl.SetImageList(&m_cImageListSmall, LVSIL_SMALL);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
/*
InitTabCtrl
Setup the tab control with the differ
没有合适的资源?快使用搜索试试~ 我知道了~
MFC tree平铺显示文件
共31个文件
h:8个
cpp:7个
bmp:5个
4星 · 超过85%的资源 需积分: 9 14 下载量 127 浏览量
2013-07-29
11:07:46
上传
评论
收藏 101KB ZIP 举报
温馨提示
MFC平铺显示文件 包含大图标 小图标 竖着,横着优先平铺,清单式罗列,显示内容个数可控,还可搜索显示指定位置文件, 实现了基本window下打开文件夹所能显示的基本几种展现效果
资源推荐
资源详情
资源评论
收起资源包目录
ListCtrlDemo.zip (31个子文件)
ListCtrlDemo
HyperLink.h 4KB
Release
ListCtrlDemo.exe 116KB
ListCtrlStylesExDlg.h 3KB
ListCtrlDemo.dsw 632B
res
bmp00002.bmp 3KB
bmp00001.bmp 3KB
gradient.bmp 39KB
Font.ico 4KB
ListCtrlDemo.ico 2KB
ListCtrlDemo.rc2 404B
images_n.bmp 9KB
Application.ico 4KB
Ber_Hand.cur 5KB
Image.ico 4KB
Config.ico 4KB
ListCtrlDemo.dsp 6KB
HistoryEdit.cpp 2KB
bk.bmp 27KB
ListCtrlDemoDlg.cpp 24KB
ListCtrlDemo.cpp 3KB
HyperLink.cpp 14KB
ListCtrlDemoDlg.h 3KB
ListCtrlStylesExDlg.cpp 10KB
StdAfx.cpp 214B
resource.h 3KB
ListCtrlDemo.rc 9KB
StdAfx.h 1KB
HistoryEdit.h 1KB
ListCtrlStylesDlg.cpp 8KB
ListCtrlDemo.h 2KB
ListCtrlStylesDlg.h 2KB
共 31 条
- 1
资源评论
- wsxking19852013-11-27还是很不错,主要是想验证自己为什么图标不能一排铺满在换行的问题。 对比参考看自己是否在个别设置上没选对
- 阿山仔2018-09-22挺好的,和官方demo差不多
- qingqingzijuan2014-05-16还可以,就是想借鉴一下
yejie1111
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功