rombo 0 Newbie Poster

I'm doing a Win32 video application and I've started with the SimplePlay sample of last Windows SDK v7.0.

When I want to release the video and display a picture through an WM_KEYDOWN event the last video
frame remains until an WM_SIZE or an WM_MOVE event is received.

Namely, I have to press a key and move or resize the window for refresh.

I've tried with InvalidateRect(hwnd, NULL, TRUE), RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE), UpdateWindow(hwnd), ShowWindow(hwnd, SW_SHOW) but the problem persist.

Here is my WM_PAINT handle:

//-------------------------------------------------------------------
// OnPaint
//
// Handles the WM_PAINT message.
//-------------------------------------------------------------------

bool releaseVideo = false;

void OnPaint(HWND hwnd)
{
	PAINTSTRUCT ps;
	HDC hdc = 0;

	hdc = BeginPaint(hwnd, &ps);
    

	if (releaseVideo)
	{
		if (g_pPlayer)
		{
			g_pPlayer->Shutdown();
			g_pPlayer->Release();
			g_pPlayer = NULL;
		}

		if (g_pPlayerCB)
		{
			g_pPlayerCB->Release();
			g_pPlayerCB = NULL;
		}
		FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
		releaseVideo = false;
	}
	else if (g_pPlayer && g_bHasVideo)
	{
		// Playback has started and there is video. 

		// Do not draw the window background, because the video 
		// frame fills the entire client area.

		g_pPlayer->UpdateVideo();
	}
	else
	{
		// There is no video stream, or playback has not started.
		// Paint the entire client area.

		FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
	}

	int ww = ps.rcPaint.right - ps.rcPaint.left;	//Window width
	int wh = ps.rcPaint.bottom - ps.rcPaint.top;	//Window height
	int iw, ih;
	pbitmap->GetSize(iw, ih);		//Image width/height
	float k;
	if (iw > ih)
	{
		k = (float)ww / (float)iw;
	}
	else
	{
		k = (float)wh / (float)ih;
	}

	pbitmap->draw(hdc, &ps, 0, 0, iw * k, ih * k);


	EndPaint(hwnd, &ps);
 
}

And here the WM_ONKEYDOWN handle:

//-------------------------------------------------------------------
// OnKeyDown
//
// Handles the WM_KEYDOWN message.
//-------------------------------------------------------------------

void OnKeyDown(HWND hwnd, UINT vk, BOOL /*fDown*/, int /*cRepeat*/, UINT /*flags*/)
{
	HRESULT hr = S_OK;

	switch (vk)
	{
	case VK_SPACE:

		// Toggle between playback and paused/stopped.
		if (g_pPlayer)
		{
			MFP_MEDIAPLAYER_STATE state = MFP_MEDIAPLAYER_STATE_EMPTY;
            
			hr = g_pPlayer->GetState(&state);

			if (SUCCEEDED(hr))
			{
				if (state == MFP_MEDIAPLAYER_STATE_PAUSED || state == MFP_MEDIAPLAYER_STATE_STOPPED)
				{
					hr = g_pPlayer->Play();
				}
				else if (state == MFP_MEDIAPLAYER_STATE_PLAYING)
				{
					hr = g_pPlayer->Pause();
				}
			}
		}
		break;

	case VK_RETURN:
		releaseVideo = true;
		InvalidateRect(hwnd, NULL, TRUE);
//		RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
//		UpdateWindow(hwnd);
//		ShowWindow(hwnd, SW_SHOW);
		break;
	}

	if (FAILED(hr))
	{
		ShowErrorMessage(TEXT("Playback Error"), hr);
	}
}

I'm doing that on Windows 7 with Microsoft Visual C++ 2010