getting fed up with CreateWindow

This is a discussion on getting fed up with CreateWindow within the Windows Programming forums, part of the Platform Specific Boards category; i havent had this problem before, with either the CreateWindow or CreateWindowEx functions, but suddenly my window wont create and ...

  1. #1
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465

    getting fed up with CreateWindow

    i havent had this problem before, with either the CreateWindow or CreateWindowEx functions, but suddenly my window wont create and ive tried everything i can think of to no avail.

    this is my setup:
    Code:
    WNDCLASS wnd;
    
    	wnd.style = CS_HREDRAW | CS_VREDRAW;
    	wnd.cbClsExtra = 0;
    	wnd.cbWndExtra = 0;
    	wnd.lpfnWndProc = (WNDPROC)WndProc;
    	wnd.hInstance = hInstance;
    	wnd.hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_CURSOR1));
    	wnd.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1));
    	wnd.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    	wnd.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
    	wnd.lpszClassName = "MyClass";
    	
    
    	if ( ! RegisterClass( &wnd ) )
    	{
    		MessageBox(NULL, "Window Registration Failed!", "Error", MB_OK);
    		return 0;
    	}
    
    	HWND hWnd = CreateWindow( wnd.lpszClassName, "Window", WS_OVERLAPPEDWINDOW, 
    		0, 0, 500, 500, NULL, NULL, hInstance, NULL);
    
    	if ( !hWnd )
    	{
    		MessageBox(NULL, "Window Creation Failed!", "Error", MB_OK);
    		return 0;
    	}
    it compiles fine and i cant find anything wrong with it, but i get the "creation failed" popup every time.

    any thoughts?
    I came up with a cool phrase to put down here, but i forgot it...

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Did you return 0 when handling WM_CREATE in your Window Procedure?

  3. #3
    ...
    ... is offline
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    oh, duh... i dont even have a create or a default in my wndproc... :P

    thanks...
    I came up with a cool phrase to put down here, but i forgot it...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 12
    Last Post: 03-27-2006, 07:03 AM
  2. CreateWindow failure
    By TheDan in forum Windows Programming
    Replies: 6
    Last Post: 07-08-2005, 08:49 AM
  3. CreateWindow LPVOID
    By Mithoric in forum Windows Programming
    Replies: 1
    Last Post: 04-13-2004, 10:46 PM
  4. CreateWindow() help!
    By nextus in forum Windows Programming
    Replies: 3
    Last Post: 03-05-2003, 02:56 AM
  5. how do you make a group box with CreateWindow?
    By pinkcheese in forum Windows Programming
    Replies: 0
    Last Post: 08-17-2002, 09:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21