Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 699

InitCommonControlsEx() function not recognised by compiler

$
0
0

I am trying to call InitCommonControlsEx() in the main entry of a window program, and although I included the header and linked to the ComCtl32.Lib, for some reason the compiler underlines that function as undefined. Following is the code...

#include <CommCtrl.h>int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow){INITCOMMONCONTROLSEX initControls;initControls.dwSize = sizeof(INITCOMMONCONTROLSEX);initControls.dwICC = ICC_BAR_CLASSES;InitCommonControlsEx(&initControls);}

I know that the inclusion of the is doing something, because if I delete the inclusion of that header, then the compiler doesn't recognise the class INITCOMMONCONTROLSEX.

I am really confused. I went into the CommCtrl.h file and found that many sections were underlined in red giving warnings by the compiler, including any reference to WINAPI. Could it be that I have a broken header? I know the functions declaration is in there, it's in the following picture...

enter image description here

I've been googling for hours and can't figure it out. There's not a DLL file I also need, is there? As I said I've already linked the ComCtl32.Lib, sometimes referred to as comctl32.lib (I don't think the capitals matter). Furthermore, on my computer I have 4 instances of this ComCtl32.Lib, two are for 64bit and two are for x86. But, my feeling is that the problem is it just can't find declaration of that function from that header. Thank you.

Edit: Thanks to Harry Johnson I fixed the problem. I had no idea that including standard header files requires that you include other header files before them. In this case the compiler didn't recognise anything because windows.h wasn't included BEFORE CommCtrl.h. An obvious mistake for anyone who knows what they're doing. You can delete this question entirely. I expected that when including a header that windows provides that all relevant dependencies are included in that header.


Viewing all articles
Browse latest Browse all 699

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>