The MASM Forum

General => The Campus => Topic started by: K_F on February 27, 2013, 08:01:00 PM

Title: Listview columns - determining number of, at runtime
Post by: K_F on February 27, 2013, 08:01:00 PM
I don't see anything in the API list.. similar to LVM_GETITEMCOUNT.

Is the only way to determine the number, is to cycle through LVM_GETCOLUMN's  until the API fails ?
:lol:

Sorry: I forgot to mention that the LV is in report/details view format.

Title: Re: Listview columns - determining number of, at runtime
Post by: sinsi on February 27, 2013, 08:17:18 PM
Community content from http://msdn.microsoft.com/en-us/library/windows/desktop/bb761044(v=vs.85).aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/bb761044(v=vs.85).aspx)
Quote from: Reetep
Counting the number of columns

To count the number of columns, rather than the number of items (ie
rows), use the LVM_GETHEADER message to obtain a handle to the listview's
header. The header admits the admits the HDM_GETITEMCOUNT message, which returns the number of columns in the listview.
Title: Re: Listview columns - determining number of, at runtime
Post by: K_F on February 27, 2013, 09:02:41 PM
As far as I understand that message, is that it returns the Total Rows in the LV ....that is, Items only (column 0) and not the Subitems

There doesn't seem to be anything similar for Total Columns
:)
Title: Re: Listview columns - determining number of, at runtime
Post by: sinsi on February 27, 2013, 09:14:28 PM
"Item" in this case means a column. The header control is separate from (but part of) the listview control.

http://msdn.microsoft.com/en-us/library/windows/desktop/hh298343(v=vs.85).aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/hh298343(v=vs.85).aspx)
QuoteA header control typically has several header items that define the columns of the control.

One way to find out.
Title: Re: Listview columns - determining number of, at runtime
Post by: K_F on February 28, 2013, 12:10:33 AM
Ah.. OK, I can see clearly now :)

Thanks