Menu

problem with win32 api

Dr deo
2009-10-23
2012-09-26
  • Dr deo

    Dr deo - 2009-10-23

    i am trying to add a toolbar to my application by using an image list.

    SendMessage(hToolBar, TB_SETIMAGELIST, 0, hImgLst);

    i have #included<commctrl.h> and linked the program with libcomctl32
    by adding this to project>parameters>linker -lcomctl32

    my surprise is that the above function seems not to be recorgnised yet i got
    it from msdn.Here is the link

    http://msdn.microsoft.com/en-
    us/library/bb787433%28VS.85%29.aspx

    compile log

    g++.exe -c main.cpp -o main.o -I"C:/Dev-
    Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-
    Cpp/include/c++/3.4.2/backward" -I"C:/Dev-
    Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2"
    -I"C:/Dev-Cpp/include"

    main.cpp: In function LRESULT WindowProcedure(HWND__*, UINT, WPARAM, LPARAM)': main.cpp:112: error:TB_SETIMAGELIST' undeclared (first use this function)
    main.cpp:112: error: (Each undeclared identifier is reported only once for
    each function it appears in.)

    make.exe: *** Error 1

    Execution terminated

    Any help will be appreciated.
    Thanks
    from Dr Deo

     
  • cpns

    cpns - 2009-10-23

    The Windows API headers provided with MinGW are Open Source and not
    Microsoft's official SDK files, and may not be perfect. The message is not
    complaining about the function not being present but merely the symbol
    TB_SETIMAGELIST. You should open commctrl.h directly and search the file to
    see if it exists and if it does to see if it is dependent on any conditional
    compilation macros. If it does not exist, you might try installing teh latest
    Win32API component from www.mingw.org. Failing all that, you could simply find
    out (from Microsoft's SDK for example) how the symbol is defined and add it ot
    the commctrl.h header yourself.

    Clifford

     
  • Dr deo

    Dr deo - 2009-10-28

    you are right :) . i had to manually open commctrl.h and i found this line

    define TB_SETIMAGELIST (WM_USER+48)

    Manually adding this line to my source made the toolbar appear without any
    problems. But i wonder why i have to manually redefine the symbol
    TB_SETIMAGELIST yet its defined in the commctrl.h header.... I am going to try
    the latest win32 api and compare the results

    Dr Deo
    Thanks anyway. Appreciate your help.

     
  • cpns

    cpns - 2009-10-28

    I may have been right, but that is not what I suggested you do!

    > But i wonder why i have to manually
    > redefine the symbol TB_SETIMAGELIST
    You don't

    > yet its defined in the commctrl.h header.
    Because it's not (at least not unconditionally). You obviously missed my point
    about conditional compilation. I have not installed Dev-C++, but looking at
    the Microsoft SDK version, that macro is dependent on:

    _WIN32_IE >= 0x0300
    !defined NOUSER
    !defined NOTOOLBAR

    Now it seems unlikely that those conditions are not true under normal
    circumstances, but you may have something in your code that makes it so, or
    possibly the MinGW header's have other conditions onm definition of this
    macro.

     
  • cpns

    cpns - 2009-10-28

    I wonder when SourceForge will fix this abysmal mark-down implementation! The
    quoted sections got merged with my text despite appearing correct in the
    preview. (I'm guessing that you did not even look at teh preview judging you
    the mark-up in your post!). Any way, the above should have read:

    > But i wonder why i have to manually
    > redefine the symbol TB_SETIMAGELIST

    You don't

    > yet its defined in the commctrl.h header.

    Because it's not (at least not unconditionally).

     
  • Dr deo

    Dr deo - 2009-10-31

    Got it :)
    Its true that the problem was with conditional compilation. I got your point
    when i saw the two lines below in commctrl.h
    -----------------------------------------------------------------------------


    #ifndef _WIN32_IE

    / define _WIN32_IE if you really want it /

    #if 0 //which means this is never implemented

    #define _WIN32_IE 0x0300

    #endif

    #endif

    #if (_WIN32_IE >= 0x0300)

    #define TB_SETIMAGELIST (WM_USER+48)

    -----------------------------------------------------------------------------

    //this means that _WIN32_IE 0x0300 is NEVER defined for me and i should have
    #defined _WIN32_IE

    PS: This markdown syntax is starting to piss me off :(

    i hope it does not mess up my post

     
  • cpns

    cpns - 2009-10-31

    \&gt; i hope it does not mess up my post

    It did ;). However your did not use code mark-up there - that at least works
    better that nothing when applied carefully; best method is to select the text
    and click the code button.

    It is not mark-down that is the problem, but rather SourceForge's
    implementation of it. It works perfectly at StackOverflow. This may make you
    laugh:

    : http://www.codinghorror.com/blog/archives/001306.html

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.