Original Post
Hey everyone,
I have spent the last several hours attempting to figure out why my win32 application I wrote for practice earlier decided to stop working.
What I mean by stop working is this:
After it registers the windows class via RegisterClassEx(), I use CreateWindowEx() to attempt creating the window. I have never had a problem until earlier tonight, when for no apparent reason it began return a NULL hwnd each time.
The odd thing is, any Win32 code that I have written before tonight still compiles and runs perfectly.
I decided to write a short application for testing and as an example to show my problem.
I would appreciate any help that I recieve, because as of right now I am completely stumped as to why this is going on.
I am running this on Windows2k Professional with all of the Service Packs.
Thanks!
Michael Bartman
[edited by - TheRealBartman on January 26, 2003 2:25:35 AM]
[edited by - TheRealBartman on January 26, 2003 2:31:50 AM]
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd,msg, NULL, NULL);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
WNDCLASSEX WndClsEx;
MSG msg;
memset(&WndClsEx, 0, sizeof(WndClsEx));
WndClsEx.cbSize = sizeof(WndClsEx);
WndClsEx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
WndClsEx.hInstance = hInstance;
WndClsEx.lpfnWndProc = WndProc;
WndClsEx.lpszClassName = "TEST";
WndClsEx.style = CS_HREDRAW|CS_VREDRAW;
RegisterClassEx(&WndClsEx);
HWND hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "TEST", "TEST", WS_OVERLAPPED, 0, 0, 640, 480, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, SW_SHOW);
while(GetMessage(&msg, hWnd, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}