What is WC_LISTVIEW? I think it should be SysListView32.
Call GetLastError after CreateWindowEx, what is it's return value?
Main Topics
Browse All TopicsHello,
i've been trying to create a listview. I dont get any compile errors but it cant create the listview either when i run the program.
Ill post the WndProc only so it wont look messy with all the codes. And its the only important thing you need to see i guess.
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
//draw the listview
lstv_schedule = CreateWindowEx(WS_EX_CLIEN
//lstv_schedule = CreateWindowEx(0, WC_LISTVIEW, "", LVS_ICON | WS_CHILD | LVS_AUTOARRANGE | LVS_SINGLESEL | LVS_SHOWSELALWAYS, 0, 0, 640, 480, hwnd, (HMENU)IDB_SCHEDULE, GetModuleHandle(NULL), NULL);
if(lstv_schedule==NULL){
MessageBox(NULL, "Could not create the window properly.", "Error", MB_OK | MB_ICONERROR);
PostQuitMessage(0);
}
break;
/*** On Exit ***/
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wPa
}
return 0;
}
I get the messagebox everytime that it couldnt create the listview.
Can someone please tell me what i've been doing wrong.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I've got it working now. But i was wondering about what hemakumar said.
Why would i need
#define WC_LISTVIEWA "SysListView32"
#define WC_LISTVIEWW L"SysListView32"
Cause it also work without that?
Anywayz heres the code, maybe its also usefull for someone else.
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
//draw the listview
InitCommonControls();
lstv_schedule = CreateWindowEx(WS_EX_CLIEN
break;
/*** On Exit ***/
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wPa
}
return 0;
}
// I've got it working now. But i was wondering about what hemakumar said.
Why would i need
#define WC_LISTVIEWA "SysListView32"
#define WC_LISTVIEWW L"SysListView32"
Cause it also work without that?
It will work without that is true.
Take little time to understand what that macro means.
select WC_LISTVIEW in ur code AND right click go to definition .Then u will understand what i said.I never specified to use those macros.I was trying to explain u to understand what is the definition of macro.
Thank u.
>>>> Why would i need
>>>> #define WC_LISTVIEWA "SysListView32"
>>>> #define WC_LISTVIEWW L"SysListView32"
MS sometimes works with 'A' and 'W' extension in macros. The purpose is to redefine the original function name either to a ANSI (8bit characters) or UNICODE (16bit character) alternative, e. g. for the sample above there could be preprocessor code somewhere in a system header above that is like
#ifdef UNICODE
# define WC_LISTVIEW WC_LISTVIEWW
#else
# define WC_LISTVIEW WC_LISTVIEWA
#endif
If your source includes that header directly or indirectly, you now are working with ANSI string "SysListView32". But when turning your project to a UNICODE project, you automatically would use the UNICODE version of CreateWindowEx - maybe switched by macro as well - that requires a wide character string.
Regards, Alex
P:S: Though I know what happens I don't like these amcros. I never saw a project that could be switched from ANSI to UNICODE by simply defining the UNICODE macro. On the other hand you can't properly debug code parts that are defined by macro and if somehow some defines were mixed up you need days or weeks to clean up that stuff.
Business Accounts
Answer for Membership
by: jweston1Posted on 2005-07-31 at 14:59:05ID: 14566412
You can try calling InitCommonControlsEx with ICC_LISTVIEW_CLASSES. It requires commctrl.h and comctl32.lib. library/de fault.asp? url=/libra ry/ en-us/s hellcc/pla tform/comm ctls/commo n/function s/ initcomm oncontrols ex.asp
http://msdn.microsoft.com/