   Window losing focus
  The problem is, when my successfully initialized DirectX Window goes aut of focus (for example, when typed ALT + TAB), and afterwards I refocus the window, I see the blank window I used to register with RegisterClassEx and CreateWindow, because DirectX does not refresh the Display anymore. What should I do in order to fix this?Here is the DirectX init, in case it does matter...//////////////////////////////////////////////////////// InitD3D()//////////////////////////////////////////////////////HRESULT direct3D::InitD3D(){    HRESULT hResult = CreateD3DObject();    if (hResult != D3D_OK)   return hResult;    hResult = CheckDisplayMode();    if (hResult != D3D_OK)   return hResult;    hResult = CreateD3DDevice();    if (hResult != D3D_OK)   return hResult;    hResult = m_pD3DDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_pBackBuffer);    m_pD3DDevice->Clear(0, 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 0, 0);    m_pD3DDevice->Present(NULL, NULL, NULL, NULL);    return hResult;}//////////////////////////////////////////////////////// CreateD3DObject()//////////////////////////////////////////////////////HRESULT direct3D::CreateD3DObject(){    m_pD3D = Direct3DCreate8(D3D_SDK_VERSION);    if (m_pD3D == NULL)    {   MessageBox(m_hWnd, "Couldn’t create DirectX object.",  "DirectX Error", MB_OK);   strcpy(m_szErrorMsg, "CreateD3DObject()");   return E_FAIL;    }    return D3D_OK;}//////////////////////////////////////////////////////// CheckDisplayMode()//////////////////////////////////////////////////////HRESULT direct3D::CheckDisplayMode(){    HRESULT hResult = m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,   D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8, FALSE);    if (hResult != D3D_OK)    {   MessageBox(m_hWnd, "The required display mode is   not available on this system.",  "DirectX Error", MB_OK);   strcpy(m_szErrorMsg, "CheckDisplayMode()");   return hResult;    }    return D3D_OK;}//////////////////////////////////////////////////////// CreateD3DDevice()//////////////////////////////////////////////////////HRESULT direct3D::CreateD3DDevice(){    D3DPRESENT_PARAMETERS D3DPresentParams;    ZeroMemory(&D3DPresentParams, sizeof(D3DPRESENT_PARAMETERS));    D3DPresentParams.Windowed = FALSE;    D3DPresentParams.BackBufferCount = 1;    D3DPresentParams.BackBufferWidth = 1024;    D3DPresentParams.BackBufferHeight = 768;    D3DPresentParams.BackBufferFormat = D3DFMT_X8R8G8B8;    D3DPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;    D3DPresentParams.hDeviceWindow = m_hWnd;    HRESULT hResult = m_pD3D->CreateDevice(D3DADAPTER_DEFAULT,   D3DDEVTYPE_HAL, m_hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &D3DPresentParams, &m_pD3DDevice);    if (FAILED(hResult))    {   MessageBox(m_hWnd, "Failed to create Direct3D device.", "DirectX Error", MB_OK);   strcpy(m_szErrorMsg, "CreateD3DDevice()");   return hResult;    }    return hResult;}
  When you alt + tab away from fullscreen DirectX apps, the device gets "lost" and you can't render anything until it's been reset. The DirectX documentation shows you how to reset the device (Here). Basically you have to Release() anything that's been created with the D3DPOOL_DEFAULT flag and then call the device's Reset() function. Everything you need should be in that link [smile].   