1 //////////////////////////////////////////////
\r
3 // Definitions for CViewFiles
\r
6 #include "TabDemoApp.h"
\r
8 #include "resource.h"
\r
11 ///////////////////////////////////////////////
\r
12 // CViewFiles functions
\r
13 CViewFiles::CViewFiles() : m_himlSmall(0)
\r
17 CViewFiles::~CViewFiles()
\r
19 if (IsWindow()) DeleteAllItems();
\r
20 ImageList_Destroy(m_himlSmall);
\r
23 void CViewFiles::OnInitialUpdate()
\r
25 // Set the image lists
\r
26 m_himlSmall = ImageList_Create(16, 15, ILC_COLOR32 | ILC_MASK, 1, 0);
\r
27 HBITMAP hbm = LoadBitmap(MAKEINTRESOURCE(IDB_FILEVIEW));
\r
28 ImageList_AddMasked(m_himlSmall, hbm, RGB(255, 0, 255));
\r
29 SetImageList(m_himlSmall, LVSIL_SMALL);
\r
30 ::DeleteObject(hbm);
\r
32 // Set the report style
\r
33 DWORD dwStyle = (DWORD)GetWindowLongPtr(GWL_STYLE);
\r
34 SetWindowLongPtr(GWL_STYLE, (dwStyle & ~LVS_TYPEMASK) | LVS_REPORT);
\r
40 int CViewFiles::AddItem(LPCTSTR szText, int nImage)
\r
43 lvi.mask = LVIF_TEXT|LVIF_IMAGE;
\r
44 lvi.iImage = nImage;
\r
45 lvi.pszText = (LPTSTR)szText;
\r
47 return InsertItem(lvi);
\r
50 void CViewFiles::SetColumns()
\r
55 //initialise the columns
\r
56 LV_COLUMN lvColumn = {0};
\r
57 lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
\r
58 lvColumn.fmt = LVCFMT_LEFT;
\r
60 TCHAR szString[3][20] = {TEXT("Name"), TEXT("Size"), TEXT("Type")};
\r
61 for(int i = 0; i < 3; ++i)
\r
63 lvColumn.pszText = szString[i];
\r
64 InsertColumn(i, lvColumn);
\r
68 BOOL CViewFiles::SetSubItem(int nItem, int nSubItem, LPCTSTR szText)
\r
71 lvi1.mask = LVIF_TEXT;
\r
73 lvi1.iSubItem = nSubItem;
\r
74 lvi1.pszText = (LPTSTR)szText;
\r
75 return (BOOL)SendMessage(LVM_SETITEM, 0, (LPARAM)&lvi1);
\r
78 void CViewFiles::InsertItems()
\r
81 int item = AddItem(_T("ListViewApp.h"), 2);
\r
82 SetSubItem(item, 1, _T("1 KB"));
\r
83 SetSubItem(item, 2, _T("C Header file"));
\r
86 item = AddItem(_T("ListViewApp.cpp"), 1);
\r
87 SetSubItem(item, 1, _T("3 KB"));
\r
88 SetSubItem(item, 2, _T("C++ Source file"));
\r
91 item = AddItem(_T("main.cpp"), 1);
\r
92 SetSubItem(item, 1, _T("1 KB"));
\r
93 SetSubItem(item, 2, _T("C++ Source file"));
\r
96 item = AddItem(_T("ListView"), 0);
\r
97 SetSubItem(item, 2, _T("Folder"));
\r