Looking for something specific?
  Home
Home
Articles
Page Tag-Cloud
  Software
Software Tag-Cloud
Building from Source
Open Source Definition
All Software
  Popular Tags
Legacy
C Plus Plus
Source Code
Class
Cryptography
  Members
Login
Web-Email
Notable Members
  Official
Our Company
Copyright Information
Software EULA
GPL EULA
LGPL Eula
Pre-Release EULA
Privacy Policy
  Support
Make Contact
 
 
Microsoft's ListView, What is it good for?

Have you ever used Microsoft's list view control?
 
I am speaking of the native Win32 control, not that pansy .NET control will all the fancy helpful and useful features. No, i'm talking about the real-man's control. The "thanks but no-thanks, I'll dig my own damned fox hole" control.
 
Have you used this control? Why would you?! Because there are few alternatives with similar performance and supported Windows version coverage. The list view is fast, hard as hell to use and comes built into every version of windows since windows 95 (it may, just may, go back even further).
 
Ok, tell me can you can craft a better mouse trap, with all the support, stability and performance of the list view. Go ahead! But once you tire of your personal re-invent and decide to go the way of every other application that strives for native windows support (e.g. WinZip, Windows explorer, 7-Zip, Fortitude HTTP, ect, ect) - I’ve got you a few pointers...
 
Rule #1: The List view does not have "columns", it has sub-items! The difference you ask? Well, the "column" that you may intuitively believe is column zero, it actually the list item. Subsequent "columns" are sub-items of the one item.
 
Rule #2: The list view is very basic in its functionality. This is because (in my humble yet strikingly concrete opinion) that the list view was created as the core component of the windows file manager (Windows Explorer). It therefore supports what you might find in windows explorer (such as icon view and detail view, period).
 
Rule #3: The list view is not designed to be friendly to the developer. It does not auto sort, you cannot easily remove icons once they are added, there is near nothing about the item (or its sub items) that allow you to retain any user data (you have text and LPARAM, deal with it!).

Want to populate your pet listview?

//Add a few columns:
LV_COLUMN lvColumn;
memset(&lvColumn, 0, sizeof(LV_COLUMN));
 
lvColumn.cx        = 100;
lvColumn.pszText   = "Column 1";
lvColumn.iSubItem  = 0;
lvColumn.mask      = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
lvColumn.fmt       = LVCFMT_LEFT;
ListView_InsertColumn(hList, WEBSITES_LIST_POS_NAME, &lvColumn);
 
lvColumn.cx        = 500;
lvColumn.pszText   = "Column 2";
lvColumn.iSubItem  = 1;
lvColumn.mask      = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
lvColumn.fmt       = LVCFMT_RIGHT;
ListView_InsertColumn(hList, WEBSITES_LIST_POS_BSENT, &lvColumn);
 
//Add an item, or 10:
for(int iItem = 0; iItem < 10; iItem++)
{
 LV_ITEM lvItem;
 memset(&lvItem, 0, sizeof(lvItem));
 
 lvItem.pszText = "Item in Column #1"
 lvItem.mask = LVIF_TEXT;
 lvItem.iSubItem = 0;
 lvItem.iItem = iItem;
 ListView_InsertItem(hList, &lvItem);
 
 lvItem.pszText = "Item in Column #2"
 lvItem.mask = LVIF_TEXT;
 lvItem.iSubItem = 1;
 lvItem.iItem = iItem;
 ListView_SetItem(hList, &lvItem);
}


For further examples and pre-built listview manipulation functionality, check out the ListView module of the NSWFL.

ps. If you can indeed build a "better-mouse-trap", I’d prefer the proof be in C++ and sent directly to my personal email (tongue in cheek implied).

Is this code snippet, product or advice warrantied against ill-effect and/or technical malaise? No. No it's not! Not expressed - Not implied - not at all.



Tags:
 C Plus Plus    Win32    Windows  

Created by Josh Patterson on 2/8/2013, last modified by Josh Patterson on 2/8/2013

No comments currently exists for this page. Why don't you add one?
First Previous Next Last 

 
Copyright © 2024 NetworkDLS.
All rights reserved.
 
Privacy Policy | Our Company | Contact