tags:

views:

1353

answers:

1

I'm completely new to win32. I have been working on it the last 48 hours.

I'm trying to build a "grid", and I got examples of a List-View control and a Header control on msdn.microsoft.com .

The first one calls the InitCommonControls() function (besides I read this function is obsolete).

HWND DoCreateHeader(HWND hwndParent, HINSTANCE hInst) 
{ 
    HWND hwndHeader; 
    RECT rcParent; 
    HDLAYOUT hdl; 
    WINDOWPOS wp; 

    // Ensure that the common control DLL is loaded, and then create 
    // the header control. 
    InitCommonControls(); 

    // ...

    // hwndHeader = CreateWindowEx(0, WC_HEADER, ...
}

The second one calls the InitCommonControlsEx() function.

HWND CreateListView (HWND hwndParent, HINSTANCE hInst) 
{     
    RECT rcl; 
    INITCOMMONCONTROLSEX icex;

    // Ensure that the common control DLL is loaded. 
    icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icex.dwICC  = ICC_LISTVIEW_CLASSES;
    InitCommonControlsEx(&icex); 

    // ...

    // HWND hWndListView = CreateWindow(WC_LISTVIEW ...
}

Seems these functions need comctl32.lib library, but download it is a mess.

Furthermore I have noticed that if I remove these functions, everything keeps working well. Then, are they necessary?

Thanks!

+1  A: 

Yes it is necessary. They are required to get the window classes for those custom controls registered. Odds are, some other component in your code is loading them. I'm not sure, but I think if you have support for comctl v6 (XP and up visual styles) in your manifest, you get commctl32.dll automatically.

More info on what InitCommonControlsEx does is here.

Not sure what you mean by downloading comctl32.lib, it is present on every Windows platform since NT 4 and Windows 95 so you don't need to redistribute it.

Michael
Oh my god! Thank you! I haven't noticed it was on c:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib
Kiewic