Click to See Complete Forum and Search --> : Creating a List-View


GordonFreeman
April 16th, 2005, 05:14 PM
----------------------------------------------------------------------------------------------------

// m_hWnd is the main window handle

hListView = CreateWindow
(WC_LISTVIEW,"List",
WS_VISIBLE | WS_CHILD,0,0,
200,200,m_hWnd,NULL, (HINSTANCE)GetWindowLong(m_hWnd,GWL_HINSTANCE),
NULL);

SetWindowLong(hListView,GWL_STYLE,LVS_REPORT);

LV_COLUMN col;
col.mask = LVCF_WIDTH;
col.cx = 50;
SendMessage(hListView,LVM_INSERTCOLUMN,0,(LPARAM)&col);

// ... insert other columns

-----------------------------------------------------------------------------------------------------

I tried to create a list view which looks like the Outlook Express' message list

but it seems it doesn't work,the listview isn't visible...what's the error? :(

SuperKoko
April 16th, 2005, 05:42 PM
SetWindowLong(hListView,GWL_STYLE,LVS_REPORT);

This line remove the WS_CHILD style, and maybe the WS_VISIBLE style.

Instead of using SetWindowLong, just specify the LVS_REPORT in the dwFlags parameter of 'CreateWindow'.

GordonFreeman
April 17th, 2005, 07:42 AM
SetWindowLong(hListView,GWL_STYLE,LVS_REPORT);

This line remove the WS_CHILD style, and maybe the WS_VISIBLE style.

Instead of using SetWindowLong, just specify the LVS_REPORT in the dwFlags parameter of 'CreateWindow'.



wow!! you're a genius!