Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The program compiles and runs successfully but does not show a window, it simply ends immediately.

#include <Windows.h>

LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR CmdLine, int CmdShow )

    WNDCLASSEX wndClass = {0};

    wndClass.cbSize = sizeof(WNDCLASSEX); = CS_HREDRAW | CS_VREDRAW;
    wndClass.lpfnWndProc = WndProc;
    wndClass.hInstance = hInstance;
    wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wndClass.lpszMenuName= NULL;
    wndClass.lpszClassName= "DX11BookWindowClass";

        return -1;

        RECT rc = {0,0,640,480};

        HWND hwnd = CreateWindowA( "DX11BookWindowClass", "FirstWinProgram", WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom -,
                                NULL, NULL, hInstance, NULL );

            return -1;


        MSG msg = {0};

        while( msg.message != WM_QUIT )
            if( PeekMessage(&msg,0,0,0,PM_REMOVE) )
                TranslateMessage( &msg );
                DispatchMessage( &msg );

        //Demo ShutDown

        return static_cast<int>(msg.wParam);

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    PAINTSTRUCT paintstruct;
    HDC hDC;

    case WM_PAINT:
        hDC = BeginPaint( hwnd,&paintstruct);
    case WM_DESTROY:
        PostQuitMessage( 0 );
        return DefWindowProc( hwnd, message, wParam, lParam);

    return 0;
share|improve this question

closed as too localized by Byte56, Le Comte du Merde-fou, Sean Middleditch, Josh Petrie, bummzack Apr 9 '13 at 7:58

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Practice some basic debugging. Ensure what you're expecting matches with what the program is actually coded to do. Put print statements or even better set break points and see why the program exits when you think it should keep going. I'm voting to close this question as too localized, since it's essentially a "debug my code for me" question. Read up on the FAQ to learn what types of questions to ask here (and what kind not to). – Byte56 Apr 7 '13 at 16:07
up vote 0 down vote accepted

oh dear...classic typo

if(!RegisterClassEx(&wndClass)); <---- typo, remove the ; that it works
return -1;

this means that the program always returns there

work on your coding style (i recommend to use everytime braces)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.