Listview column header problem 
Author Message
 Listview column header problem

hello,

I have the following snipit of code in my views OnInitialUpdate function.
////////////////////////////////////////////////////////////////////////////
/////////////////////////////

        CListCtrl* pList = (CListCtrl*)GetDlgItem(IDC_SERVER_INFO);
        LV_COLUMN serverInfoColumn;

//  ???????????????????
//      If abc is not included, then svrCols passes junk to the listviews column
title
//      char *abc[] = {"one", "two", "three"};
//      If abc is included, then svrCols inserts the correct listview column
titles
//  ???????????????????
        char *svrCols[] = {"Client Name", "Operator ID", "Network Address"};

        serverInfoColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT |     LVCF_SUBITEM;
        serverInfoColumn.fmt = LVCFMT_LEFT;
        serverInfoColumn.cx = 120;

        for (int nColumn = 0; nColumn < 3; nColumn++)
        {
                serverInfoColumn.iSubItem = nColumn;
                serverInfoColumn.pszText = svrCols[nColumn];
                pList->InsertColumn (nColumn, &serverInfoColumn);
        }
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////

If I build the app without declaring the variable abc, then the svrCols
variable
passes junk to my listviews headers.  If I include the bogus unused
varaiable
abc and build the app, then the svrCols variable places the correct titles
in
each column header.

What am I missing here??



Tue, 12 Oct 1999 03:00:00 GMT  
 Listview column header problem



Quote:
> hello,

> I have the following snipit of code in my views OnInitialUpdate function.

- code deleted -
> If I build the app without declaring the variable abc, then the svrCols
> variable
> passes junk to my listviews headers.  If I include the bogus unused
> varaiable
> abc and build the app, then the svrCols variable places the correct
titles
> in
> each column header.

> What am I missing here??

Very strange!  Your code looks pretty much like mine, which works, with one
exception.  I (by rote) include
        memset(&serverInfoColumn, 0, sizeof(LV_COLUMN);
 before I use the structure.  Since the only member you don't set
explicitly is cchTextMax, this is equivalent to adding
        serverInfoColumn.cchTextMax = 0;
The help explicitly states that this member is ignored, so this may not be
the problem, but it's worth a try.

--
Timothy J. Ebben
2470 Island Drive #304
Spring Park, MN  55384

"Since it costs a lot to win and even more to lose
 You and me bound to spend some time wondrin' what to choose."

-Robert Hunter



Thu, 14 Oct 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Double clicking column header of ListView

2. Multi-line column headers in ListView

3. Catching listview column header order and width

4. Listview column header

5. How to get the clicked column number or column header text in CListctl(report view)

6. Listview column problem

7. ListView problems: Displaying a button in a column

8. Listview column problem

9. Problem in sorting list control by clicking column header

10. Adding columns to ListView after it's been added to a form

11. How to hide/Disable a Column in ListView control C#

12. ListView Sorting by Column

 

 
Powered by phpBB® Forum Software