Win32处理内部绘制消息

时间:2014-01-05 03:08:44

标签: c++ winapi messages directx-9

我正在使用Visual Studio在调试模式下运行Win32应用程序。切换到Visual Studio以调试我的应用程序后,不会继续其消息循环...没有消息正在发送...如何处理焦点/激活消息以恢复消息循环?

编辑: 此应用程序使用DirectX9。我有2个视口(设备交换链),我渲染几何。如果,在运行时,我单击一个不同的窗口,然后尝试返回到我的应用程序,两个视口都是黑色(没有渲染到)。我在消息循环中设置断点,并发现一条消息(WM_PAINT)不断被翻译和分派,从而阻止我的应用程序呈现。下面是消息循环。将焦点返回到我的应用程序后,'bGotMsg'始终为真......

编辑:问题似乎是一个没有被处理的内部WM_PAINT消息...我已经检查了不断被调度的消息,窗口句柄不是我的应用程序之一...可能是一些内部句柄? MSDN在此指示将发送WM_PAINT消息,而队列中没有其他消息或处理内部绘制消息...如何处理此消息?

HRESULT WINAPI GDEMainLoop( HACCEL hAccel )
{
    HRESULT hr =S_OK;
    HWND hWnd = DXUTGetHWND();

    // Now we're ready to receive and process Windows messages.
    bool bGotMsg;
    MSG msg;
    msg.message = WM_NULL;
    PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE );

    while( WM_QUIT != msg.message )
    {
        // Use PeekMessage() so we can use idle time to render the scene. 
        bGotMsg = ( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) != 0 );

        if( bGotMsg )
        {
            // Translate and dispatch the message
            if( /*!TranslateAccelerator( hWnd, hAccel, &msg )*/
                !IsDialogMessage( wnd.GetWindow( CWindowManager::EXPLORERBAR ), &msg )
                && !IsDialogMessage( wnd.GetSceneOutliner()->GetHWND(), &msg )
                && !IsDialogMessage( wnd.GetResourceOutliner()->GetHWND(), &msg )
                && !IsDialogMessage( wnd.GetProjectOutliner()->GetHWND(), &msg )
                && !IsDialogMessage( wnd.GetProjectDialog()->GetHWND(), &msg )
                && !IsDialogMessage( wnd.GetSceneDialog()->GetHWND(), &msg ) )
            {
                TranslateMessage( &msg );
                DispatchMessage( &msg );
            }
        }
        else
        {
            if( FAILED( hr = GDERender3DEnvironment() ) )
            {
                DebugStringDX( MainClassName, "Failed to GDERender3DEnvironment() at GDEMainLoop()", __LINE__, hr );
                Alert( NULL, 
                    L"A failure occured while trying to render the 3D environment!",
                    L"Render Failure" );    

                PostQuitMessage( 0 );
            }
        }
    }
    return S_OK;
}

0 个答案:

没有答案