ok im learning opengl and im of corse running msvc 6.0 enterprise edition blah blah blah anywho this code(below) seemed to do nothing untill i added a messagebox to to the if(!registerclassex...). the message box tells me that obviously it cant register the class. why is this? does it have to do with the fact im running windowsxp? what do i do?!
Code:
#include "asdf.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
PAINTSTRUCT paintStruct;
HDC hDC;
char str[]="Hello World";
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
{
return 0;
}
case WM_CLOSE:
{
PostQuitMessage(0);
return 0;
break;
}
case WM_PAINT:
{
hDC= BeginPaint(hwnd, &paintStruct);
SetTextColor(hDC, COLORREF(0x00FF0000));
TextOut(hDC, 150,150, str, sizeof(str)-1);
EndPaint(hwnd, &paintStruct);
}
default:
break;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX windowClass;
bool done;
HWND hwnd;
MSG msg;
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.lpfnWndProc = WndProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = NULL;
windowClass.hbrBackground=NULL;
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName="MyClass";
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
windowClass.style = CS_VREDRAW | CS_HREDRAW;
//windowClass.hCursor LoadCursor(NULL, IDC_ARROW);
if(!RegisterClassEx(&windowClass))
{
MessageBox(NULL, "ERROR", "ERROR", NULL);
return 0;
}
hwnd = CreateWindowEx(NULL, "MyClass", "My Windows Application!", WS_OVERLAPPEDWINDOW |WS_CLIPSIBLINGS | WS_CLIPCHILDREN |WS_VISIBLE |WS_SYSMENU, 100,100, 400,400,NULL,NULL, hInstance, NULL);
if (hwnd == NULL)
return 0;
done = false;
//ShowWindow(hwnd, nCmdShow);
//UpdateWindow();
while(!done)
{
if(PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
{
done=true;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return msg.wParam;