Thread: ListView with "LVS_REPORT|LVS_NOCOLUMNHEADER"

  1. #1
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310

    Red face ListView with "LVS_REPORT|LVS_NOCOLUMNHEADER"

    This is the code for the ListView creation:
    Code:
    CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_NOCOLUMNHEADER|LVS_SINGLESEL, 0, 0, 0, 0, hwndParent, HMENU(iID), hInstance, 0);
    This is my code to add the items:
    Code:
    void LogMessage(HWND g_hwndList, const char *pStr)
    {
    	LVITEM item = {0};
    	item.mask = LVIF_TEXT;
    	item.pszText = (char *)pStr;
    	item.cchTextMax = strlen(pStr);
    	item.iItem = SendMessage(g_hwndList, LVM_GETITEMCOUNT, 0, 0);
    	ListView_InsertItem(g_hwndList, &item);
        ListView_EnsureVisible(g_hwndList, item.iItem, 0);
        return;
    }
    So there's a button that adds the strings into the listview:
    Code:
    LogMessage(hListView1, "Joel");
    The listview shows correctly and I want it to emulate a listbox control...but the strings are not visible...any ideas?
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Add a column. Make sure you set the size to something reasonable. (Like the width of the control, if you're only using 1 column.) Although the headers aren't visible, I believe you still have to create the columns.
    And keep in mind that without headers, users won't be able to resize the columns. (Unless there's some mojo that I don't know about...) If you're only using 1, it might be wise to keep the column width locked to either the largest item's width or the control's width.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    310
    Ah...thanks
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ListView Refresh, Update
    By de4th in forum C++ Programming
    Replies: 1
    Last Post: 12-23-2006, 09:13 AM
  2. Replies: 6
    Last Post: 07-10-2006, 12:05 AM
  3. Troubles with ListView and Toolbar
    By cornholio in forum Windows Programming
    Replies: 8
    Last Post: 11-14-2005, 01:26 AM
  4. Listview with c/c++
    By X PaYnE X in forum Windows Programming
    Replies: 8
    Last Post: 03-20-2005, 11:29 PM
  5. Listview??
    By SuperNewbie in forum C# Programming
    Replies: 4
    Last Post: 02-13-2003, 03:34 AM