Has anyone encountered this problem when trying to make WinAPI toolbars? when I did this, I got errors that said that the Initcommoncontrols function and structure were missing. I think that this is due to either the header file or library file for commctrl.h file being corrupted. Does anyone know where I can get the following files or have the files working correctly in their system, as in you are able to successfully produce the status and toolbar for winapi? The files I need are commctrl.h, libcommctrl32.h, and the comctrl32.dll (this was missing in my program) control files. Please, I would greatly appreciate it if so moene could provide me with their copy and tell me how to add it into the program. Also, can someone forward this information to the developers of the program? Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could you, before working the assumption that things are missing, please post your Basic 3? The Basic 3 are covered in the thread titled "Please Read Before Posting a Question".
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The error messages are useful, but in case like this, it is also very important to see how
the libraries in question are linked, so please post your full Basic 3, and please do not
simply post the errors.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You may want to remember that C and C++ are case sensitive, and I think your capitalization of:
INITCOMMONCONTROLSEX
is not correct.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-06-18
commctrl.h is just a text file, it is a no-brainer to simply open it and see if it is "corrupted" or search for the structure. I am willing to bet that had you simply posted the Compile Log and posted nothing else the problem would have been solved in one response. You spent rather a long time posting no useful information whatsoever! It just takes a copy & paste.
Of the three files you mentioned:
>> commctrl.h
Already discussed. If there is a problem here, a compiler error will result.
>> libcommctrl32.h
Surely you mean "libcomctl32.a" - one 'm', no 'r'!? If there is a problem here, a linker error will result. But a 'missing structure' could only be a compiler error, so the problem is not here.
>> comctrl32.dll
It is "comctl32.dll" (no 'r'). It is provided by the operating system, not Dev-C++, and cannot cause a compilation or link error, it would be a runtime error. But that is unlikely, just about every program on your system requires this DLL so if it were broken or missing you would know about it.
As a rule, operating system DLLs, headers and libraries do not exceed the 8.3 file name format (an MS-DOS/Win16 hangover), but GNU adds the 'lib' prefix not used in Microsoft export libraries. So not count in the prefix, if you have more characters than eight characters, you probably have the file name wrong. If this is not the problem, and you simply mistyped the names in the post, then that is all the more reason to copy & paste the log - it is far harder to mistype!
If you did just screw up the post (as well as your code), then my bet is either that you mistyped structure identifier (since you seem prone to that), or that you are using a structure that is defined only for later versions of Windows. You have to correctly set the _WIN32_WINNT macro to the minimum version level you wish your code to support. Finding the structure in commctrl.h and checking which conditional compilation is in force for it, or just checking the documentation for the structure on MSDN should tell you the answer.
I am willing to bet that one or more of the above is your problem (or will become your problem once you have solved your current problem). All of them could have been precisely diagnosed from the compile log rather than guessed from verbose waffle. Which is why we ALWAYS ask for it!
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
case WM_SIZE:
// Resize the toolbar
SendMessage(hToolbar,msg,wParam,lParam);
break;
case WM_DESTROY:
// User closed the window
PostQuitMessage(0);
break;
default:
// Call the default window handler
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
// Creates main window
HWND CreateMainWindow(HINSTANCE hInstance)
{
HWND hTmp; // Temporary handle to a window
WNDCLASSEX wcx; // WINDOW class information
// Initialize the struct to zero
ZeroMemory(&wcx,sizeof(WNDCLASSEX));
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = CS_HREDRAW|CS_VREDRAW |CS_DBLCLKS ; // Class styles
wcx.lpfnWndProc = (WNDPROC)MainWndProc; // Pointer to the callback proc
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance; // Instance of the application
wcx.hIcon = NULL; // Class Icon
wcx.hCursor = LoadCursor(NULL, IDC_ARROW); // Class Cursor
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW); // Background brush
wcx.lpszMenuName = NULL; // Menu resource
wcx.lpszClassName = "Draw"; // Name of this class
wcx.hIconSm = NULL; // Small icon for this class
// Register this window class with MS-Windows
if (!RegisterClassEx(&wcx))
return 0;
// Create the window
hTmp = CreateWindowEx(0, //Extended window style
"Draw", // Window class name
"Draw v0.1", // Window title
WS_OVERLAPPEDWINDOW, // Window style
CW_USEDEFAULT,CW_USEDEFAULT, // (x,y) pos of window
CW_USEDEFAULT,CW_USEDEFAULT, // Width, height of window
HWND_DESKTOP, // HWND of the parent
NULL, // Handle to menu
hInstance, // Handle to application instance
NULL); // Pointer to window creation data
// TIP : We dont want to make the window visible yet so that all the
// controls can be placed and sized
// Ensure common control DLL is loaded
icx.dwSize = sizeof(INITCOMMONCONTROLSEX);
icx.dwICC = ICC_BAR_CLASSES; // Specify BAR classes
InitCommonControlsEx(&icx); // Load the common control DLL
F:/ServerScripts/DevFile/lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
make.exe: *** [toolbarexample.exe] Error 1
Execution terminated
When I removed this part --#define _WIN32_IE 0x0500 // To support INITCOMMONCONTROLSEX, which is what I've seen others do, I got the following erors
Compiler: Default compiler
Building Makefile: "F:\ServerScripts\DevFile\Makefile.win"
Executing make...
make.exe -f "F:\ServerScripts\DevFile\Makefile.win" all
gcc.exe -c maintool.c -o maintool.o -I"F:/ServerScripts/DevFile/include"
maintool.c: In function CreateMainWindowToolbar':
maintool.c:72: error:INITCOMMONCONTROLSEX' undeclared (first use in this function)
maintool.c:72: error: (Each undeclared identifier is reported only once
maintool.c:72: error: for each function it appears in.)
maintool.c:72: error: syntax error before "icx"
maintool.c:75: error: `icx' undeclared (first use in this function)
make.exe: *** [maintool.o] Error 1
Execution terminated
The Version of Developer I am using is Version 4.9.9.2 and the operating system is Windows XP Home edition SP1.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Has anyone encountered this problem when trying to make WinAPI toolbars? when I did this, I got errors that said that the Initcommoncontrols function and structure were missing. I think that this is due to either the header file or library file for commctrl.h file being corrupted. Does anyone know where I can get the following files or have the files working correctly in their system, as in you are able to successfully produce the status and toolbar for winapi? The files I need are commctrl.h, libcommctrl32.h, and the comctrl32.dll (this was missing in my program) control files. Please, I would greatly appreciate it if so moene could provide me with their copy and tell me how to add it into the program. Also, can someone forward this information to the developers of the program? Thanks
Could you, before working the assumption that things are missing, please post your Basic 3? The Basic 3 are covered in the thread titled "Please Read Before Posting a Question".
Wayne
I doubt that the files are corrupted. It is more likely a coding error in the program.
Post the error message you received for the Initcommoncontrols function and the code for creating the toolbar.
The error messages are useful, but in case like this, it is also very important to see how
the libraries in question are linked, so please post your full Basic 3, and please do not
simply post the errors.
Wayne
You may want to remember that C and C++ are case sensitive, and I think your capitalization of:
INITCOMMONCONTROLSEX
is not correct.
Wayne
commctrl.h is just a text file, it is a no-brainer to simply open it and see if it is "corrupted" or search for the structure. I am willing to bet that had you simply posted the Compile Log and posted nothing else the problem would have been solved in one response. You spent rather a long time posting no useful information whatsoever! It just takes a copy & paste.
Of the three files you mentioned:
>> commctrl.h
Already discussed. If there is a problem here, a compiler error will result.
>> libcommctrl32.h
Surely you mean "libcomctl32.a" - one 'm', no 'r'!? If there is a problem here, a linker error will result. But a 'missing structure' could only be a compiler error, so the problem is not here.
>> comctrl32.dll
It is "comctl32.dll" (no 'r'). It is provided by the operating system, not Dev-C++, and cannot cause a compilation or link error, it would be a runtime error. But that is unlikely, just about every program on your system requires this DLL so if it were broken or missing you would know about it.
As a rule, operating system DLLs, headers and libraries do not exceed the 8.3 file name format (an MS-DOS/Win16 hangover), but GNU adds the 'lib' prefix not used in Microsoft export libraries. So not count in the prefix, if you have more characters than eight characters, you probably have the file name wrong. If this is not the problem, and you simply mistyped the names in the post, then that is all the more reason to copy & paste the log - it is far harder to mistype!
If you did just screw up the post (as well as your code), then my bet is either that you mistyped structure identifier (since you seem prone to that), or that you are using a structure that is defined only for later versions of Windows. You have to correctly set the _WIN32_WINNT macro to the minimum version level you wish your code to support. Finding the structure in commctrl.h and checking which conditional compilation is in force for it, or just checking the documentation for the structure on MSDN should tell you the answer.
I am willing to bet that one or more of the above is your problem (or will become your problem once you have solved your current problem). All of them could have been precisely diagnosed from the compile log rather than guessed from verbose waffle. Which is why we ALWAYS ask for it!
Clifford
To saraku - Please pay attention to WHERE you post things, you put this in completely the wrong thread. I moved it for you:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
This is an example I copied from the web. I tried to run this in my Dev C++ program.
define _WIN32_IE 0x0500 // To support INITCOMMONCONTROLSEX
include <windows.h>
include <commctrl.h>
HWND hToolbar;
// Callback procedure
LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch (msg)
{
case WM_SIZE:
// Resize the toolbar
SendMessage(hToolbar,msg,wParam,lParam);
break;
case WM_DESTROY:
// User closed the window
PostQuitMessage(0);
break;
default:
// Call the default window handler
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
// Creates main window
HWND CreateMainWindow(HINSTANCE hInstance)
{
HWND hTmp; // Temporary handle to a window
WNDCLASSEX wcx; // WINDOW class information
// Initialize the struct to zero
ZeroMemory(&wcx,sizeof(WNDCLASSEX));
wcx.cbSize = sizeof(WNDCLASSEX);
wcx.style = CS_HREDRAW|CS_VREDRAW |CS_DBLCLKS ; // Class styles
wcx.lpfnWndProc = (WNDPROC)MainWndProc; // Pointer to the callback proc
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance; // Instance of the application
wcx.hIcon = NULL; // Class Icon
wcx.hCursor = LoadCursor(NULL, IDC_ARROW); // Class Cursor
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW); // Background brush
wcx.lpszMenuName = NULL; // Menu resource
wcx.lpszClassName = "Draw"; // Name of this class
wcx.hIconSm = NULL; // Small icon for this class
// Register this window class with MS-Windows
if (!RegisterClassEx(&wcx))
return 0;
// Create the window
hTmp = CreateWindowEx(0, //Extended window style
"Draw", // Window class name
"Draw v0.1", // Window title
WS_OVERLAPPEDWINDOW, // Window style
CW_USEDEFAULT,CW_USEDEFAULT, // (x,y) pos of window
CW_USEDEFAULT,CW_USEDEFAULT, // Width, height of window
HWND_DESKTOP, // HWND of the parent
NULL, // Handle to menu
hInstance, // Handle to application instance
NULL); // Pointer to window creation data
// TIP : We dont want to make the window visible yet so that all the
// controls can be placed and sized
// Create Toolbar
HWND CreateMainWindowToolbar(HWND hParent)
{
HWND hTmp; // Temporary HWND
INITCOMMONCONTROLSEX icx;
// Ensure common control DLL is loaded
icx.dwSize = sizeof(INITCOMMONCONTROLSEX);
icx.dwICC = ICC_BAR_CLASSES; // Specify BAR classes
InitCommonControlsEx(&icx); // Load the common control DLL
// Create the toolbar window
hTmp = CreateWindowEx(0, TOOLBARCLASSNAME, (LPSTR) NULL,
WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hParent,
(HMENU) NULL, NULL, NULL);
}
// Create Statusbar
// return value
return hTmp;
}
When I compiled it, I got the following error in the error log:
Compiler: Default compiler
Building Makefile: "F:\ServerScripts\DevFile\Makefile.win"
Executing make...
make.exe -f "F:\ServerScripts\DevFile\Makefile.win" all
gcc.exe -c maintool.c -o maintool.o -I"F:/ServerScripts/DevFile/include"
gcc.exe maintool.o -o "toolbarexample.exe" -L"F:/ServerScripts/DevFile/lib" -mwindows lib/libcomctl32.a
F:/ServerScripts/DevFile/lib/libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
make.exe: *** [toolbarexample.exe] Error 1
Execution terminated
When I removed this part --#define _WIN32_IE 0x0500 // To support INITCOMMONCONTROLSEX, which is what I've seen others do, I got the following erors
Compiler: Default compiler
Building Makefile: "F:\ServerScripts\DevFile\Makefile.win"
Executing make...
make.exe -f "F:\ServerScripts\DevFile\Makefile.win" all
gcc.exe -c maintool.c -o maintool.o -I"F:/ServerScripts/DevFile/include"
maintool.c: In function
CreateMainWindowToolbar': maintool.c:72: error:INITCOMMONCONTROLSEX' undeclared (first use in this function)maintool.c:72: error: (Each undeclared identifier is reported only once
maintool.c:72: error: for each function it appears in.)
maintool.c:72: error: syntax error before "icx"
maintool.c:75: error: `icx' undeclared (first use in this function)
make.exe: *** [maintool.o] Error 1
Execution terminated
The Version of Developer I am using is Version 4.9.9.2 and the operating system is Windows XP Home edition SP1.
Thanks