List Control via Visual c++ resource Editor (non-mfc)

I've added a List control to my Dialog box in the resource editor of Visual C++ 6. I've used the following code on a WM_CREATE message:

BOOL InitListView (HWND hwndListView)
{
  int index;                      
  LV_COLUMN lvColumn;        
  TCHAR szString[5][20] = {TEXT("Main Column"),
                           TEXT("Column 1"),
                           TEXT("Column 2"),
                           TEXT("Column 3"),
                           TEXT("Column 4")};

  // Empty the list in list view.
  ListView_DeleteAllItems (hwndListView);

  // Initialize the columns in the list view.
  lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  lvColumn.fmt = LVCFMT_LEFT;
  lvColumn.cx = 120;

  // Insert the five columns in the list view.
  for (index = 0; index < 5; index++)
  {
    lvColumn.pszText = szString[index];
    ListView_InsertColumn (hwndListView, index, &lvColumn);
  }
  ListView_SetItemCount (hwndListView, ITEM_COUNT);

  return TRUE;
}

Yet when it compiles and runs, nothing happens. Its just sitting on the dialog box with no columns, no data or anything. Has anyone actually used the resorce editor to successfully implement a list control??
I've included the commtrl.h and library and used the initcommoncontrols(). I use GetDlgItem to get the handle of the List Control from the Dialog.
CronicAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
PlanetCppConnect With a Mentor Commented:
use the LVS_REPORT style (if you're not) other then that i don't see anythign wrong
if you state LVCF_SUBITEM in the mask then validate it in the object, if you dot set things in the object don't state them in the mask
since i have no idea how you can specify styles in dialog apps as i don;t use dialogs ill give you another method which might be the method you ave to use :o\
long winstyle;
use:
winstyle = GetWindowLong(listview,GWL_STYLE)|LVS_REPORT;
SetWindowLong(listview,GWL_STYLE,winstyle);
after its created and before you add columns
then add the columns
0
 
cupConnect With a Mentor Commented:
InitCommonControls has been deprecated.  Try InitCommonControlsEx.  It takes a parameter LPINITCOMMONCONTROLSEX.  You have to initialize it something like

INITCOMMONCONTROLSEX icc;
icc.dwSize = sizeof (icc);
icc.dwICC = ICC_LISTVIEW_CLASSES | ICC_WIN95_CLASSES;
InitCommonControlsEx (&icc);

Search for ICC_ in the header files.  There are a lot more for dates, treeview etc.
0
 
bcladdCommented:
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points split between PlanetCpp and cup

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.