Lidt kode (ja, det er C++):
- void initControls(HWND hWnd)
- {
- toolbarHandle = CreateWindowEx(0,
- TOOLBARCLASSNAME,
- NULL,
- WS_CHILD | TBSTYLE_WRAPABLE | WS_VISIBLE,
- 0,0,0,0,
- hWnd,
- (HMENU)toolbar,
- hInstance,
- NULL);
-
- pcListHandle = CreateWindowEx(WS_EX_CLIENTEDGE,
- WC_LISTVIEW,
- "",
- WS_GROUP | WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | LVS_REPORT,
- 150, 55, 620, 250,
- hWnd,
- (HMENU)pcListBox,
- hInstance,
- NULL);
-
- // BKB, make it look a bit nicer:
- ListView_SetExtendedListViewStyle(pcListHandle, LVS_EX_FULLROWSELECT);
- // BKB insert two columns
- LVCOLUMN Column;
- memset(&Column, 0, sizeof(Column));
- Column.mask = LVCF_TEXT | LVCF_WIDTH;
- Column.cx = 125;
- Column.pszText = "Process";
- SendDlgItemMessage(hWnd, pcListBox, LVM_INSERTCOLUMN, 0, (LPARAM )&Column);
- Column.pszText = "Memory";
- Column.mask |= LVCF_FMT;
- Column.fmt = LVCFMT_RIGHT;
- SendDlgItemMessage(hWnd, pcListBox, LVM_INSERTCOLUMN, 1, (LPARAM )&Column);
-
- // BKB fill in some random text
-
- LVITEM lvc;
- memset(&lvc, 0, sizeof(lvc));
- lvc.mask = LVIF_TEXT;
- lvc.pszText = "Line 1, Column 1";
- lvc.iItem = 0;
- SendMessage(pcListHandle, LVM_INSERTITEM, 0, (LPARAM )&lvc);
- lvc.pszText = "Line 1, Column 2";
- lvc.iSubItem = 1;
- SendMessage(pcListHandle, LVM_SETITEMTEXT, 0, (LPARAM )&lvc);
- lvc.pszText = "Line 1, Column 1";
- lvc.iItem = 1;
- lvc.iSubItem = 0;
- SendMessage(pcListHandle, LVM_INSERTITEM, 0, (LPARAM )&lvc);
- lvc.pszText = "Line 2, Column 2";
- lvc.iSubItem = 1;
- SendMessage(pcListHandle, LVM_SETITEMTEXT, 1, (LPARAM )&lvc);
-
-
- iPodListHandle = CreateWindowEx(WS_EX_CLIENTEDGE,
- WC_LISTVIEW,
- "",
- WS_GROUP | WS_CHILD | WS_TABSTOP | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL,
- 150, 360, 620, 270,
- hWnd,
- (HMENU)iPodListBox,
- hInstance,
- NULL);
-
- statusbarHandle = CreateWindowEx(0,
- STATUSCLASSNAME,
- NULL,
- WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
- 0,0,0,0,
- hWnd,
- (HMENU)statusbar,
- hInstance,
- NULL);
- int statwidths[] = {200, -1};
- SendMessage(statusbarHandle, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM) statwidths);
- SendMessage(statusbarHandle, SB_SETTEXT, 0, (LPARAM)"Velkommen til iSync");
- }
Det viser hvordan du løser:
Problem 1:
Jeg kan ikke lave kolonner i mine listviews.
Problem 2:
Jeg kan ikke tilføje tekst, som i en listbox.
At lave:
Problem 3:
Jeg kan ikke ændre farven på hver enkelt række.
Er ikke helt simpelt, så den vil jeg gerne vente lidt med.
Jeg synes din toolbar ser normal ud.