locked
The Complete Code to Create the Window Couldn't Debug RRS feed

  • Question

  • As what have said on Creating a Window (Windows) at http://msdn.microsoft.com/en-us/library/windows/desktop/ff381397%28v=vs.85%29.aspx “Congratulations, you've created a window! Right now, the window does not contain any content or interact with the user.” But I couldn't debug the complete code to create the window. This is the Source.cpp:

        #include <windows.h>
        
        // Register the window class.
        const wchar_t CLASS_NAME[]  = L"Sample Window Class";
        
        WNDCLASS wc = { };
    
        wc.lpfnWndProc   = WindowProc;
        wc.hInstance     = hInstance;
        wc.lpszClassName = CLASS_NAME;
    
        RegisterClass(&wc);
    
        // Create the window.
    
        HWND hwnd = CreateWindowEx(
            0,                              // Optional window styles.
            CLASS_NAME,                     // Window class
            L"Learn to Program Windows",    // Window text
            WS_OVERLAPPEDWINDOW,            // Window style
    
            // Size and position
            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
    
            NULL,       // Parent window    
            NULL,       // Menu
            hInstance,  // Instance handle
            NULL        // Additional application data
            );
    
        if (hwnd == NULL)
        {
            return 0;
        }
    
        ShowWindow(hwnd, nCmdShow);

    I'm using Visual Studio Express 2012 for Windows Desktop. Starting with New Project, and choosing Visual C++, Empty Project. I tried to #include <Windows.h>, and even to #include <iostream> without and with using namespace std; hoping a little bit, but still no luck.

    The problems looks like "wc":

        wc.lpfnWndProc   = WindowProc;
        wc.hInstance     = hInstance;
        wc.lpszClassName = CLASS_NAME;
    
        RegisterClass(&wc);

    Please help. I'm just beginning..


    Saturday, June 8, 2013 8:12 AM

All replies