Dev-C++ and Windows Programming

I'm trying to accomplish what should be a simple task: I'm trying to create a toolbar. The code is good, yet the tool bar fails to load. I'm using the Dev-C++ package and am still learning how to use the tools. For some reason the CreateWindowEx() function isn't loading and returning a handle for the toolbar. There seems to be a problem with the header file because I have no other explanation for the program to fail as it does. If anybody knows a reason for this failure that better explains the problem and can offer a solution, I would like to hear from you.


//////////////////////////////////////////////////////////////
#include <commctrl.h>
...
...
...
case WM_CREATE:
{

hwndToolBar = CreateWindowEx(
0,
TOOLBARCLASSNAME,
(LPSTR)NULL,
WS_CHILD,
0,
0,
0,
0,
hwnd,
(HMENU)IDTB_TOOLBAR,
(HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE),
NULL);

/////////////////////////////////////////////////////////////////
1
2
CreateWindowEx(
0, 


0 should be the handle to the parent window for the Toolbar.
Also, you should be able to get getLastError() (or similar) to get the error that occurred during CreateWindowEx();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
HWND CreateWindowEx(

    DWORD dwExStyle,	// extended window style
    LPCTSTR lpClassName,	// pointer to registered class name
    LPCTSTR lpWindowName,	// pointer to window name
    DWORD dwStyle,	// window style
    int x,	// horizontal position of window
    int y,	// vertical position of window
    int nWidth,	// window width
    int nHeight,	// window height
    HWND hWndParent,	// handle to parent or owner window
    HMENU hMenu,	// handle to menu, or child-window identifier
    HINSTANCE hInstance,	// handle to application instance
    LPVOID lpParam 	// pointer to window-crea 
Ahhh yea, my bad =\ Been a while since I've done Win32 Window code.

Have you tried getlasterror?
I'm looking into working it into the file. Thanks
Error message says it cannot find window class, but I already knew that.
Thanks for the link. I have tried to use the InitCommonControls() function, but that makes the program crash. I've also tried InitCommonControlsEx. The results are the same. I'm wondering if the lib file "libcomctl32.a" is not corrupt. It truly is frustrating.

Thanks again for the link.
Got some exception handling around it?

IMO. I use a 3rd party GUI kit called wxWidgets (www.wxWidgets.org). But there are others you can use too (FLTK, QT etc). Make's it much easier.
Welp, I tried code sample from your above link... It worked. I don't understand why mine couldn't muster up even a handle, since it was pretty much the same thing. Anyway, I will be playing with it for a few days to get a better grip on it. Thanks for your help.
Topic archived. No new replies allowed.