?
Solved

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

Posted on 2003-03-08
4
Medium Priority
?
1,545 Views
Last Modified: 2013-12-14
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.
0
Comment
Question by:Cronic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Accepted Solution

by:
PlanetCpp earned 240 total points
ID: 8095241
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
 
LVL 11

Assisted Solution

by:cup
cup earned 240 total points
ID: 8096773
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
 
LVL 11

Expert Comment

by:bcladd
ID: 9892959
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question