Original Post
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?
It just fails to create a window...
// 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;
}