EDN Admin
Well-known member
Is it possible to populate a list control (created in a dialog via the resource editor) without the use of MFC? Or am I forced to use a listbox or custom control?
If it is possible, Id imagine its very similar to the way that a listbox is populated, but I just cant seem to get it to work. Can someone provide a simple example of doing this, or at least verify whether or not this is possible and if its any different
from a listbox?
EDIT: Perhaps Ive lost touch with a few Win32 API concepts, but without manual drawing it seems the only thing I can get it to do is display a selection behind where the image/text is supposed to appear (though, the column headers do show up as expected):
<pre class="prettyprint" style=" LVCOLUMN lvc = {0};
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
lvc.pszText = TEXT("Header ONE");
lvc.cx = 150;
ListView_InsertColumn( m_hListView, 0, &lvc );
HIMAGELIST hImageList = ImageList_Create( 16, 16, ILC_COLOR, 2, 0 );
HBITMAP hBmp = (HBITMAP)LoadImage(g_hModule, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 48, 48, 0);
ImageList_Add( hImageList, hBmp, NULL );
ListView_SetImageList( m_hListView, hImageList, LVSIL_SMALL );
DeleteObject( hBmp );
LVITEM lvi = {0};
lvi.mask = LVIF_IMAGE;
lvi.iImage = 0;
lvi.pszText = L"One...";
ListView_InsertItem( m_hListView, &lvi );
lvi.iImage = 1;
lvi.pszText = L"Two...";
ListView_InsertItem( m_hListView, &lvi );[/code]
<br/>
View the full article
If it is possible, Id imagine its very similar to the way that a listbox is populated, but I just cant seem to get it to work. Can someone provide a simple example of doing this, or at least verify whether or not this is possible and if its any different
from a listbox?
EDIT: Perhaps Ive lost touch with a few Win32 API concepts, but without manual drawing it seems the only thing I can get it to do is display a selection behind where the image/text is supposed to appear (though, the column headers do show up as expected):
<pre class="prettyprint" style=" LVCOLUMN lvc = {0};
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
lvc.pszText = TEXT("Header ONE");
lvc.cx = 150;
ListView_InsertColumn( m_hListView, 0, &lvc );
HIMAGELIST hImageList = ImageList_Create( 16, 16, ILC_COLOR, 2, 0 );
HBITMAP hBmp = (HBITMAP)LoadImage(g_hModule, MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 48, 48, 0);
ImageList_Add( hImageList, hBmp, NULL );
ListView_SetImageList( m_hListView, hImageList, LVSIL_SMALL );
DeleteObject( hBmp );
LVITEM lvi = {0};
lvi.mask = LVIF_IMAGE;
lvi.iImage = 0;
lvi.pszText = L"One...";
ListView_InsertItem( m_hListView, &lvi );
lvi.iImage = 1;
lvi.pszText = L"Two...";
ListView_InsertItem( m_hListView, &lvi );[/code]
<br/>
View the full article