Error 1400 Invalid window handle
<p>I have code:</p>

<pre><code>......
    g_hWnd = CreateWindow( L"Urok6WindowClass", L"TitleWindow", WS_OVERLAPPEDWINDOW,
                           CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance,
                           NULL );
    if( !g_hWnd )
        return E_FAIL;

    ShowWindow(g_hWnd, nCmdShow );
</code></pre>

<p>All works fine. But if I add:</p>

<pre><code>    LPTSTR tilte_old= L"Old title";
    int gettus = GetWindowText(g_hWnd, tilte_old, 100);
    DWORD error = GetLastError();
    WCHAR szTest[10];
    swprintf_s(szTest, 10, L"%d", error); 
    MessageBox(NULL, szTest, L"TEST2", MB_OK); 
</code></pre>

<p>MessageBox >> 1400 </p>

<p>gettus >> ''</p>

<p>Why is this happening? Why windows handle is invalid?</p>
