Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2007nov19 Platform: win32 OS: Windows Language: C/C++ Keywords: listview Q. How do I use a list view (multi column table) in a non-Visual Studio Program? A. In the .rc (resource) file add this:CONTROL "", IDC_MY_LISTVIEW, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOSORTHEADER | WS_CHILD | WS_VISIBLE | WS_BORDER, 0, 0, 200, 100Near the beginning of your program call:InitCommonControls();Create the columns:hwndMyListView = GetDlgItem(hDlg, IDC_MY_LISTVIEW); ListView_InsertColumn(hwndMyListView, ...);Do other functions with the ListView_* macros. http://www.google.com/search?q=List-View+Controls+Macro Once you have it going you'll notice that you can only select the first column. One solution is to add LVS_OWNERDRAWFIXED to the .rc file and write your own code to draw the row -- which is a bit of a pain. http://www.google.com/search?q=LVS_OWNERDRAWFIXED Or, easier, you can not specify LVS_OWNERDRAWFIXED and process the NM_CUSTOMDRAW messages (which is sent in WM_NOTIFY). http://www.google.com/search?q=NM_CUSTOMDRAW
Add a commentSign in to add a comment