Does anyone know why this won't run properly?

Started by
0 comments, last by GBGames 22 years, 3 months ago
I know it might sound like a newbie question, but I made a simple Windows app using a great book, "OpenGL Game Programming" (I really do like it!), and it compiles, builds, and runs in VC++ 6.0...for the debug version. When I try to make it a release version, I get an error when I try to run the program. I wrote it based on what I read in chapter 2 of that book, but when I use the actual source provided (although the zip files on the CD were EMPTY!! I had to download the source), it run fine in the release version. I don''t think there is much different, but if someone can point out exactly why or at least give me some idea to start out with, that would be greatly appreciated. Files in project: main.cpp WinStuff.cpp WinStuff.h main.cpp: // // My first attempt at a Windows program // // #include "WinStuff.h" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Define_Window(hInstance); HWND hwnd = Create_Window(hInstance); ShowWindow(hwnd,nCmdShow); UpdateWindow(hwnd); bool done=false; MSG msg; while (!done) { PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE); if (msg.message == WM_QUIT) { done=true; } else { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; } WinStuff.h: // WinStuff.h // // #include <windows.h> #define WIN32_LEAN_AND_MEAN LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); //Defines the window void Define_Window(HINSTANCE hinstance); HWND Create_Window(HINSTANCE hInstance); WinStuff.cpp: #include "WinStuff.h" #include <assert.h> LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hDC; char string[]="Hello World!"; switch (message) { case WM_CREATE: { return 0; break; } case WM_CLOSE: { PostQuitMessage(0); return 0; break; } case WM_PAINT: { hDC=BeginPaint(hwnd,&ps); SetTextColor(hDC, COLORREF(0x00FF0000)); TextOut(hDC,150,150,string,sizeof(string)-1); EndPaint(hwnd,&ps); return 0; break; } default: return DefWindowProc(hwnd,message,wParam,lParam); } } void Define_Window(HINSTANCE hinstance) { WNDCLASSEX windowClass; windowClass.cbSize=sizeof(WNDCLASSEX); windowClass.nostyle=CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = (WNDPROC)WndProc; windowClass.cbClsExtra=0; windowClass.cbWndExtra=0; windowClass.hInstance=hinstance; windowClass.hIcon=NULL; windowClass.hCursor=LoadCursor(NULL, IDC_ARROW); windowClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH); windowClass.lpszMenuName=NULL; windowClass.lpszClassName="MyClass"; windowClass.hIconSm=NULL; RegisterClassEx(&windowClass); } HWND Create_Window(HINSTANCE hInstance) { HWND hwnd= CreateWindowEx(NULL, "MyClass", "My Windows Application!", WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0,0, 200,200, NULL, NULL, hInstance, NULL); return hwnd; }
-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
Advertisement
Have you checked to see if you''ve got all the links sorted out and the LIB files.
That''s usually the problem with these types of errors.

Hope that helps, if not then (Oh well!)

Later Days!!

This topic is closed to new replies.

Advertisement