where can i find comctl32.lib ( code::blocks )

Pages: 12
Dec 16, 2013 at 12:00pm
Is it pre-installed ? or is only available on Visual Studio ?

i am using code::blocks / mingw

And is libcomctl32.a w/c i found under \lib in mingw same as comctl32.lib ? i've tried linking it and it doesn't seem to work

Thank you
Dec 16, 2013 at 2:19pm
On my Win7 32 bit box I have Code::Blocks installed at ...

C:\Program Files\CodeBlocks

And under that is ...

C:\Program Files\CodeBlocks\MinGW\Lib\libComCtl32.a

MinGW prefaces all libs with the lib prefix. So if you interoperate between Microsoft and MinGW you'll need to take those naming conventions into consideration.

But your code should work in a MinGW Codeblocks development environment once you correctly set the link commandline. Do you know how to do that?
Last edited on Dec 16, 2013 at 2:19pm
Dec 16, 2013 at 5:28pm
You can simply use 'comctl32' without .lib suffix if you use MinGW instead of 'libcomctl32.a'.
Dec 16, 2013 at 6:37pm
It kind of matters what you are trying to do with the COM library because the default version of MingW that comes with Code::Blocks doesn't have full COM support. I've read that some other branches of MingW do and one of them gets a pretty solid review from one of the regular contributors here otherwise Code::Blocks likes MS VS 2010 just fine.
Dec 16, 2013 at 7:56pm
I don't believe shadow_fiend's question had anything to do with COM, as in Microsoft's 'Component Object Model' ComputerGeek. Rather, ComCtl32.lib/ComCtl32.h contains the obj code / function prototypes for Microsoft's 'Common Controls' library, which would be such stuff as the Treeview control, Calendar control, sliders, etc?
Dec 16, 2013 at 8:06pm
It looks like you're right! I don't know why I get that mixed up with the Ole**.lib stuff.
Dec 17, 2013 at 1:54am
But your code should work in a MinGW Codeblocks development environment once you correctly set the link commandline. Do you know how to do that?

i don't know how, what i did is
build options -> linker settings -> link libraries

then i add libcomctl32.

and it didn't work, am i missing something ?
Last edited on Dec 17, 2013 at 1:57am
Dec 17, 2013 at 2:47am

am i missing something ?


Did you call InitCommonControlsEx() ?

1
2
3
4
5
6
7
8
9
10
11
12
InitCommonControlsEx


BOOL InitCommonControlsEx
(
    LPINITCOMMONCONTROLSEX lpInitCtrls
);

Registers specific common control classes from the common control dynamic-link library (DLL). 

Returns TRUE if successful, or FALSE otherwise. 
lpInitCtrls  Address of an INITCOMMONCONTROLSEX structure that contains information specifying which control classes will be registered. 
Last edited on Dec 17, 2013 at 2:47am
Dec 17, 2013 at 3:01am
yes, i called it, and the compiler says it was undeclared in this scope
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#define WIN32_LEAN_AND_MEAN

#define _WIN32_IE 0x0300 // EDIT !

#include <windows.h>
#include <commctrl.h>
#include "resource.h"

#include <array>

LRESULT CALLBACK
windowProcedure( HWND hwnd,
                 UINT uMsg,
                 WPARAM wParam,
                 LPARAM lParam );


int WINAPI
WinMain( HINSTANCE hInstance,
         HINSTANCE hPrevInstance,
         LPSTR lpCmdLine,
         int nCmdShow )
{
    LPCTSTR className( "bla" );

    char windowCaption[ 50 ];
    const int numberOfButtons = 7;

    LoadString( hInstance, IDS_APPNAME, windowCaption, 50 );

    WNDCLASSEX wndClassEx
    {
        sizeof( WNDCLASSEX ), // cbSize
        CS_HREDRAW | CS_VREDRAW, // style
        windowProcedure, // lpfnWinProc
        0, // cbClsExtra
        0, // cbWinExtra
        hInstance, // hInstance
        LoadIcon( NULL, IDI_APPLICATION ), // hIcon
        LoadCursor( NULL, IDC_ARROW ), // hCursor
        static_cast<HBRUSH>( GetStockObject( WHITE_BRUSH ) ), // hbrBackground
        MAKEINTRESOURCE( IDR_MAINMENU ), // lpszMenuName
        className, // lpszClassName
        LoadIcon( NULL, IDI_APPLICATION ) // hIconSm
    };

    RegisterClassEx( &wndClassEx );

    HWND hWnd(
        CreateWindow(
            className,
            windowCaption,
            WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            nullptr,
            nullptr,
            hInstance,
            nullptr
        )
    );
    if( !hWnd )
        return 1;

    INITCOMMONCONTROLSEX initCtrlEx
    {
        sizeof( INITCOMMONCONTROLSEX ),
        ICC_BAR_CLASSES
    };

    InitCommonControlsEx( &initCtrlEx );

    TBBUTTON tbrButtons[ numberOfButtons ]
    {
        {
            0, IDM_FILE_NEW, TBSTATE_ENABLED,
            TBSTYLE_BUTTON, { 0,0 }, 0L, 0
        },
        {
            1, IDM_FILE_OPEN, TBSTATE_ENABLED,
            TBSTYLE_BUTTON, { 0, 0 }, 0L, 0
        },
        {
            0, 0, TBSTATE_ENABLED, TBSTYLE_SEP,
            { 0, 0 }, 0L, 0
        },
        {
            2, IDM_ARROW, TBSTATE_ENABLED,
            TBSTYLE_BUTTON, { 0, 0 }, 0L, 0
        },
        {
            3, IDM_DRAWLINE, TBSTATE_ENABLED,
            TBSTYLE_BUTTON, { 0, 0 }, 0L, 0
        },
        {
            4, IDM_DRAW_RECTANGLE, TBSTATE_ENABLED,
            TBSTYLE_BUTTON, { 0, 0 }, 0L, 0
        },
        {
            5, IDM_ELLIPSE, TBSTATE_ENABLED,
            TBSTYLE_BUTTON, { 0, 0 }, 0L, 0
        }
    };

    HWND hWndToolbar =
        CreateToolbarEx(
            hWnd,
            WS_VISIBLE | WS_CHILD | WS_BORDER,
            IDB_BITMAP1,
            numberOfButtons,
            hInstance,
            IDB_BITMAP1,
            tbrButtons,
            numberOfButtons,
            16, 16, 16, 16,
            sizeof( TBBUTTON )
        );

    // Display the window
    ShowWindow( hWnd, SW_SHOWNORMAL );
    UpdateWindow( hWnd );

    MSG msg;
    // Message loop
    while( GetMessage( &msg, nullptr, 0, 0 ) )
    {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
    }

    return msg.wParam;
}

LRESULT CALLBACK windowProcedure( HWND hWnd,
                                  UINT uMsg,
                                  WPARAM wParam,
                                  LPARAM lParam )
{
    switch( uMsg )
    {
    case WM_DESTROY :
        PostQuitMessage( WM_QUIT );
        break;
    default :
        return DefWindowProc( hWnd, uMsg, wParam, lParam );
    }
    return 0;
}

Last edited on Dec 17, 2013 at 8:46am
Dec 17, 2013 at 4:02am
There is no such thing like 'libcomctl32', use 'comctl32' only.

As for your compiler error, define WINVER manually to target xp or higher (0x0501) and add a comctl32 v6 manifest to your resource file (this is optional, but otherwise it will look very bad style).
Dec 17, 2013 at 8:49am
#define WINVER 0x0501 didn't work, but i've found another solution in the net: #define _WIN32_IE 0x0300

i compiled it and now it says
comctl32.lib no such file or directory


do i have anything else to configure ?

EDIT Ignore this reply, it worked now, i've changed linker settings -> policy
Last edited on Dec 17, 2013 at 9:24am
Dec 17, 2013 at 9:26am
So now, it worked, but i am now having a segmentation fault

I've use the debugger and it stopped at the end of this code :
1
2
3
4
5
6
7
8
9
10
11
12
13
HWND hWndToolbar =
        CreateToolbarEx(
            hWnd,
            WS_VISIBLE | WS_CHILD | WS_BORDER,
            IDB_BITMAP1,
            numberOfButtons,
            hInstance,
            IDB_BITMAP1,
            tbrButtons,
            numberOfButtons,
            16, 16, 16, 16,
            sizeof( TBBUTTON )
        );


anything wrong ? ( i've also updated my code above in case someone would like to try )
Dec 18, 2013 at 3:38am
bump

please help, i'm new to this stuff and i cannot track the cause of SIGSEGV
Dec 19, 2013 at 1:23am
bump
Dec 19, 2013 at 4:52am
I can't find any info about SIGSEGV with your condition. There are quite a few versions of comctrl32.dll though. I wonder if:

- your application is linking to the version(s) you think, and

- if the TBBUTTON structure definition you ar using matches what the DLL thinks it ought to be.

Sorry I can't be of more help.
Dec 19, 2013 at 8:27pm
from Modoran ...


There is no such thing like 'libcomctl32', use 'comctl32' only.


I'm curious as to why you keep stating that modoran. I've checked several of my various laptops with MinGW installed, and that file, i.e. libcomctl32.a, is in the /lib directory on all of them.
Dec 19, 2013 at 9:55pm
@freddie1
You can put a name in a quote thus:

    [quote=Modoran]...[/quote]

Modoran wrote:
...
Dec 19, 2013 at 10:16pm
@freddie1:
Because on the G++'s command line, -lcomctl32 will search for libcomctl32.a .
Besides, InitCommonControlsEx is in Commctrl.h as of http://msdn.microsoft.com/en-us/library/windows/desktop/bb775697(v=vs.85).aspx

So, #include <Commctrl.h> at the beginning of your file.
Last edited on Dec 19, 2013 at 10:18pm
Dec 20, 2013 at 11:12am
Wait, i'm getting confused
There are quite a few versions of comctrl32.dll though.

Is comctrl32.dll ( w/c i found under system32/ ) is the one i should link to my application ?

and why are there 2 entities of comctrl32, a dynamically linked( found under system32 ) and statically linked one( libcomctrl32.a ) ?

So, #include <Commctrl.h> at the beginning of your file.

why is it capital c ?
Last edited on Dec 20, 2013 at 11:16am
Dec 20, 2013 at 2:30pm
@shadow fiend:
Capitalization is not important on Windows.
You can also have #include <cOmMcTrL.h> .
By the way, linking to libcomctrl32.a doesn't automatically mean statically linking.
I don't think there's any way to have a static link to windows' API.
libcomctrl32.a will redirect you to the right DLL, so you don't have to worry about that.
Pages: 12