After creating the list view.. items are there i can select them but they have transparent brush or something like that.. and I only see a selection of that item but the item itself isn't there..
Anyone knows why.. ?
I have like 8 hours I look around this code can't figure out why my text doesn't show up..
Maybe I can show you the function the header and the window class I use in my project.
Theese are resource.h, main.cpp and the resource.rc. I took the code that refers to the listview ..sorry my code has 16.000+ lines can't copy all of it
#define ID_LISTVIEW 1000
#define NUM_ITEMS 30
#define NUM_COLUMNS 2
#define MAX_ITEMLEN 64
#define MAX_SYMBOLS 16
#define MAX_DESCRIPTION 64
#define IDS_SYMBOLS 1
#define IDS_DESCRIPTION 2
HWND CreateListView(HWND hWndParent);
LRESULT NotifyHandler(HWND, UINT, WPARAM, LPARAM);
typedef struct tagABRINFO
{
char szSymbol[MAX_SYMBOLS];
char szDescription[MAX_DESCRIPTION];
} ABRINFO;
====================================================|
#define _WIN32_IE 0x300
#include <windows.h>
#include <commctrl.h>
#include "resources.h"
#include <string.h>
#include <mmsystem.h>
#include <cstdio>
#define case ID_ABBREV 50
ABRINFO argsAbrInfo[] =
{
{"LoD", "Lord of Destruction"},
{"PvP", "Player versus Player"},
{"XP", "Experience"},
{"Javazon", "Javelin build Amazon"},
{"HOTO", "Hart of the Oak Runeword"},
{"Assa", "Assassin Character"},
{"Andy", "Final Boss Act 1 Andariel"},
{"D2", "Diablo 2 Classic"},
{"PVM", "Player versus Monsters"},
{"HP/MP", "Healing Potion/Mana Potion"}
};
HWND CreateListView(HWND hWndParent)
{
HWND hWndList;
int index;
LV_COLUMN lvC;
char szText[MAX_PATH];
LV_ITEM lvI;
int iSubItem;
InitCommonControls();
hWndList = CreateWindowEx(0L, WC_LISTVIEW, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER |
LVS_REPORT | LVS_SINGLESEL, 0, 32, 795, 448,
hWndParent, (HMENU)ID_LISTVIEW, hInst, NULL);
ListView_SetExtendedListViewStyle(hWndList, LVS_EX_FULLROWSELECT | LVM_ENSUREVISIBLE | LVM_SETOUTLINECOLOR);
if (hWndList == NULL)
return NULL;
lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvC.fmt = LVCFMT_LEFT;
lvC.cx = 0x100;
lvC.pszText = szText;
for (index = 0; index <= NUM_COLUMNS; index++)
{
lvC.iSubItem = index;
LoadString(hInst, IDS_SYMBOLS + index, szText, sizeof(szText));
if (ListView_InsertColumn(hWndList, index, &lvC) == -1)
return NULL;
}
lvI.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
lvI.state = 0;
lvI.stateMask = 0;
for (index = 0; index < NUM_ITEMS; index++)
{
lvI.iItem = index;
lvI.iSubItem = 0;
lvI.pszText = LPSTR_TEXTCALLBACK;
lvI.cchTextMax = MAX_ITEMLEN;
lvI.lParam = (LPARAM)&argsAbrInfo[index];
if (ListView_InsertItem(hWndList, &lvI) == -1)
return NULL;
for (iSubItem = 1; iSubItem < NUM_COLUMNS; iSubItem++)
{
ListView_SetItemText(hWndList, index, iSubItem, LPSTR_TEXTCALLBACK);
}
}
return (hWndList);
}
LRESULT NotifyHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
LV_DISPINFO *pLvdi = (LV_DISPINFO *)lParam;
ABRINFO *pAbr = (ABRINFO *)(pLvdi->item.lParam);
if (wParam != ID_LISTVIEW)
return 0L;
switch(pLvdi->hdr.code)
{
case LVN_GETDISPINFO:
switch (pLvdi->item.iSubItem)
{
case 0:
pLvdi->item.pszText = pAbr->szSymbol;
break;
case 1:
pLvdi->item.pszText = pAbr->szDescription;
break;
default:
break;
}
break;
default:
break;
}
return 0L;
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int nCmdShow)
{
InitCommonControls();
WNDCLASSW wc = {0};
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.hIcon = (HICON)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, 32, 32, 0);
wc.hInstance = hInst;
wc.lpfnWndProc = MainWndProc;
wc.lpszClassName = L"myMainClass";
wc.style = 0;
wc.lpszMenuName = MAKEINTRESOURCEW(IDR_MENU);
if(!RegisterClassW(&wc))
return -1;
registerCloseClass(hInst);
registerVersionClass(hInst);
hMainWindow = CreateWindowW(L"myMainClass", L"My app",
WS_SYSMENU | WS_MINIMIZEBOX | WS_CAPTION,
300, 100, 800, 550, NULL, NULL, NULL, NULL);
ShowWindow(hMainWindow, nCmdShow);
UpdateWindow(hMainWindow);
MSG msg = {0};
while(GetMessage(&msg, NULL, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
static HWND hWndListView;
switch(msg)
{
case WM_NOTIFY:
{
return (NotifyHandler(hWnd, msg, wp, lp));
break;
}
case WM_COMMAND:
switch(wp)
{
case ID_ABBREV:
{
hWndListView = CreateListView(hWnd);
PlaySound(MAKEINTRESOURCE(IDW_CLICK), NULL, SND_RESOURCE | SND_ASYNC);
return DefWindowProcW(hWnd, msg, wp, lp);
}
}
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
default:
return DefWindowProcW(hWnd, msg, wp, lp);
}
return 0;
}
====================================================|
STRINGTABLE DISCARDABLE
BEGIN
IDS_SYMBOLS "Symbols"
IDS_DESCRIPTION "Description"
END
What I have tried:
Don't know what else to provide.. I wrote this code with another WNDCLASS and it works..
Class Ex is working and the Class W not. Anyone can help me understand why Ex class can I see the items in the list and the W doesn't show up ?..
The example below is almost identical with the one is shown in the MSDN..