I have Visual Studio 2012 Ultimate. I tried creating a Win32 Program and there are no debugging errors. However, when I debug it, the window I am creating should be shown on screen, but there is no window. All I see is my code. Why would this happen?
#include <Windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prev, PSTR cmd, int show)
{
HWND hWnd;
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpszClassName = "MyWindow";
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
RegisterClass(&wc);
hWnd = CreateWindow("MyWindow", "My First Window", WS_OVERLAPPEDWINDOW, 300, 300, 480, 600, NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, show);
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
case WM_QUIT:
DestroyWindow(hWnd);
return 0;
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}