I get no errors when I run this code, but my error message pops up. I tried taking the error message out, and no window popped up and nothing happened. What is wrong!
main.cpp
resource.hCode:#include <windows.h> #include "resource.h" LRESULT CALLBACK WinProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam); HWND MakeWindow(HINSTANCE hInstance); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR iCmdLine, int iShow) { HWND hWnd; hWnd = MakeWindow(hInstance); if(!hWnd) { MessageBox(hWnd,"Failed to Create Window!","Fatal Error!",MB_ICONERROR); UnregisterClass("Boodle",hInstance); return NULL; } MSG iMsg; while(1) { if(PeekMessage(&iMsg,NULL,0,0,PM_REMOVE)) { TranslateMessage(&iMsg); DispatchMessage(&iMsg); } } UnregisterClass("Boodle",hInstance); return iMsg.wParam; } LRESULT CALLBACK WinProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam) { switch(iMsg) { case WM_DESTROY: { PostQuitMessage(0); break; } } return DefWindowProc (hWnd, iMsg, wParam, lParam); } HWND MakeWindow(HINSTANCE hInstance) { WNDCLASSEX wndClassEx; wndClassEx.cbSize = sizeof(wndClassEx); wndClassEx.style = CS_HREDRAW | CS_VREDRAW; wndClassEx.cbClsExtra = 0; wndClassEx.cbWndExtra = 0; wndClassEx.hIconSm = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,0,0,LR_DEFAULTSIZE); wndClassEx.lpszMenuName = NULL; wndClassEx.lpfnWndProc = WinProc; wndClassEx.hInstance = hInstance; wndClassEx.hIcon = (HICON)LoadImage(hInstance,MAKEINTRESOURCE(IDI_ICON1),IMAGE_ICON,0,0,LR_DEFAULTSIZE); wndClassEx.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndClassEx.lpszClassName = "Boodle"; RegisterClassEx(&wndClassEx); HWND hWnd; hWnd = CreateWindow("Boodle","Might of the Boodle!",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,650,600,NULL,NULL,hInstance,NULL); if(!hWnd) return NULL; return hWnd; }
The resource file just has my icon. I'm using MSVS .NET so I cannot give you the source for resource.rc because it won't show you.Code://{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by resource.rc // #define IDI_ICON1 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif



LinkBack URL
About LinkBacks




