Hello, sorry for the delay.
In the compiling it appears the error: "'INITCOMMONCONTROLSEX' undeclared (first use in this function)" using the pragma comment.
I have to include another header than <windows.h> and <commctrl.h> to use INITCOMMONCONTROLSEX? In the commctrl.h appears that struct, and also the InitCommonControls() function. I have searched in the Win32 Reference Manual (*.hlp file) for more information but it doesn't appear anywhere, and in MSDN says that is a structure previously defined.
I have downloaded a working example from codeproject.com and there's no error in the compilation and it works well, without setting the pragma comment.
I would like to no post the entire large code of the project in that I'm working, so I have made that simple window to test to handle easily. That code only shows the static text but not the empty listview that it should do:
#include <windows.h>
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib"
#define ElemA 1000
#define IDC_LIST 1001
const char g_szClassName[] = "classefinestra";
HWND btton;
HWND lview;
LRESULT CALLBACK prPrinc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
btton=CreateWindow("STATIC
lview=CreateWindow("SysLis
}
break;
case WM_COMMAND:
{
DestroyWindow(hwnd);
}
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG missatge;
//INITCOMMONCONTROLSEX iccex;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = prPrinc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL,IDI_APPLICAT
if(!RegisterClassEx(&wc))
{
MessageBox(NULL,"RegisterC
return 0;
}
hwnd = CreateWindowEx(WS_EX_CLIEN
WS_OVERLAPPEDWINDOW,CW_USE
NULL,NULL,hInstance,NULL);
if(hwnd == NULL)
{
MessageBox(NULL,"CreateWin
return 0;
}
/*
iccex.dwSize = sizeof(INITCOMMONCONTROLSE
iccex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icce
*/
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&missatge
{
TranslateMessage(&missatge
DispatchMessage(&missatge)
}
return missatge.wParam;
}
The disabled lines are those in that the compiler alerts of the error.
Thank you.
jbosch(vosk)
Main Topics
Browse All Topics





by: PlanetCppPosted on 2004-12-30 at 10:23:27ID: 12927686
ive used listviews but not inside dialogs, ive made them with createwindow,, so i cant say this will fix it. but when you create then the way i do you have to use initcommoncontrols(ex)..us e the Ex version so you only init what you need.
)
X); x);
you need to inlcude commctrl.h and also comctl32.lib.. you can include the library file through the compiler's IDE or use pragma which is what i do.
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib"
then InitCommonControlsEx will work,,in case you need to know how to use it
anywhere before you create a common control..i use it in wm_create..but in your case this is different..winmain is fine.
INITCOMMONCONTROLSEX iccex;
iccex.dwSize = sizeof(INITCOMMONCONTROLSE
iccex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icce