Skip to main content
gamedev.net
🔒 Locked

HELLSPAWN window...

Started by Caramelo Dec 31, 2002 at 6:05 AM 2 replies 350+ views
Original Post
Caramelo
Caramelo
Dear, sweat grandma''...Yesterday I installed the DX8 SDK and guess what? I can no more create windows.Why? No error messages! Please check out this code, try to compile it.Am I goin'' nuts?
  
// ara.cpp : Defines the entry point for the application.

//


#include "stdafx.h"

#define ID_CLASS   "WHAT"

LONG FAR PASCAL WINAPI WndProc( HWND hwnd, UINT msg, WPARAM lParam, LPARAM wParam )
{

 switch ( msg )
 {
   case WM_KEYDOWN:
     if ( wParam == VK_F12 ) PostMessage ( hwnd, WM_QUIT, 0L , 0L );
   break;
   

   case WM_DESTROY:
     PostQuitMessage(0);
   break;
 }

 return DefWindowProc(hwnd, msg, wParam, lParam);
}


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
	
	MSG	 msg;
    WNDCLASS wc;
    HWND hwnd;
   
	wc.style = 0;
	wc.lpfnWndProc = (WNDPROC)WndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon( NULL, IDI_WINLOGO);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = "MyWindow";

	if (!RegisterClass(&wc))    			// register the  class

    {
        MessageBox (NULL, "Error registering class!", NULL, MB_OK);
        return -1;
    }


	hwnd = CreateWindow(
        ID_CLASS,
        "HELLSPAWN",
        WS_POPUP,
        0,0,
        640,
        480,
        HWND_DESKTOP,
        NULL,
        hInstance,
        NULL
        );


    // window check

	if ( hwnd == NULL ) 
	{
 		LPSTR mychar;
		mychar = new char[10];

		wsprintf( mychar, "%d", GetLastError()); 
		MessageBox (NULL , mychar, NULL, MB_OK );
	
		delete[] mychar;
		
		return -2; 
	}

   ShowWindow( hwnd, nCmdShow );
   UpdateWindow( hwnd );

   while (GetMessage( &msg, hwnd, 0, 0 ))
   {
	TranslateMessage(&msg);
	DispatchMessage(&msg);
	
   }
	
	return 0;
}



  
It just fails to create a window...
.
Caramelo
Caramelo
thanks, but CreateWindow() still returns null....
btw, GetLastError() returns error code 87 which is for ERROR_INVALID_PARAMETER.

what's with this damn NULL !?


[edited by - Pro-XeX on December 31, 2002 7:58:35 AM]
.
Caramelo
Caramelo
thank you so much A.P.
and now the moral of the day: "The first thing to do in the mornings is...washing your eyes..."
.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.