I searched on msdn on list view but i get these complex sample which i cant understand can some teach me or post some code on :
How to create a listview
how to create columns
how to add info to the columns and
how to get info from them
Printable View
I searched on msdn on list view but i get these complex sample which i cant understand can some teach me or post some code on :
How to create a listview
how to create columns
how to add info to the columns and
how to get info from them
Adding a new column:
Code:void Lv_AddColumn(HWND hWnd, LPSTR lpText, UINT uWidth, UINT uID)
{
//variable
LVCOLUMN lvc;
//create item
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
lvc.pszText = lpText;
lvc.cx = uWidth;
//insert column
ListView_InsertColumn(hWnd, uID, &lvc);
}
thanks but i would i create the listview to use that with>?
Here you go:
Code:hList = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | LVS_REPORT, 0, 0, 0, 0, hWnd, NULL, hInst, 0);
i get a error on LVS_REPORT
VB Code:
E:\Program Files\Microsoft Visual Studio\MyProjects\Menu1\Main.cpp(72) : error C2065: 'LVS_REPORT' : undeclared identifier
Did you include commctrl.h and import comctl32.lib?
And you must call InitializeCommonControls or InitializeCommonControlsEx
how do i import that comctl32.lib?
and how do i call InitializeCommonControls
with the code below . what is the UINT uID?
VB Code:
void Lv_AddColumn(HWND hWnd, LPSTR lpText, UINT uWidth, UINT uID) { //variable LVCOLUMN lvc; //create item lvc.mask = LVCF_TEXT | LVCF_WIDTH; lvc.pszText = lpText; lvc.cx = uWidth; //insert column ListView_InsertColumn(hWnd, uID, &lvc); }
i see the column part but cant seem to add column
VB Code:
#define IDC_MAIN_HLIST 102VB Code:
hList = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | LVS_REPORT , 40, 40, 200, 200, hwnd, (HMENU)IDC_MAIN_HLIST, GetModuleHandle(NULL), 0); int lWidth; lWidth = 1440; Lv_AddColumn(hwnd,"jason",lWidth,IDC_MAIN_HLIST);
can someone tell me how to add a column and test to the subitems
void Lv_AddColumn(HWND hWnd, LPSTR lpText, UINT uWidth, UINT uID)
{
//variable
LVCOLUMN lvc;
//create item
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
lvc.pszText = lpText;
lvc.cx = uWidth;
//insert column
ListView_InsertColumn(hWnd, uID, &lvc);
}
HWND = Handle to list view
LPSTR = Text
UINT uWidth = Width
uID = ID of a column. Each column is increased in ID starting with 1. In your case just put one.
doh :eek: , thanks alot :D
I got this really wierd problem. I got it the first time and it still
works on that program but i follow what i did and try to make it again and no good. here are the basic lines i add
VB Code:
#include <windows.h> #include <commctrl.h> HWND hList; hList = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | LVS_REPORT, 0, 0, 200,200, hwnd, NULL, GetModuleHandle(NULL), 0); Lv_AddColumn(hList,"Jason",90,1); Lv_AddColumn(hList,"Lpz",90,2); //thats to add the listview void Lv_AddColumn(HWND hWnd, LPSTR lpText, UINT uWidth, UINT uID) { //variable LVCOLUMN lvc; //create item lvc.mask = LVCF_TEXT | LVCF_WIDTH; lvc.pszText = lpText; lvc.cx = uWidth; //insert column ListView_InsertColumn(hWnd, uID, &lvc); } //to add column
heres the full source
As i thought it was my stupid PC its sick i had to restart it works great now lol thanks alot again