I tested the sample code for a few hours. Now I reproduced the same problem
athough it occurs rarely.
window. Then
video/image. Do I have to derive a subclass from the Picture Control?
Can you give me trustable example for my application? Thanks.
Here is the beginning of the snippet. It doesn't claim it is correct.
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
"Joseph M. Newcomer" wrote:
More and more we find that Doug Harrison's post is dead-on accurate. See
http://www.flounder.com/msdn_documentation_errors_and_omissions.htm#Harrison
If I could have read the example you cited I might be able to say more about why it is
completely inappropriate, but as you have already been advised, using BeginPaint() is
deeply suspect, and if you are calling your RePaint() method from anyplace other than an
OnPaint/OnDraw handler (in which case the secondary CPaintDC is *absolutely* incorrect!)
then your code is dead wrong. You cannot show us some random out-of-context piece of code
and expect us to say much about it, except the obvious facts that it makes no sense
whatsoever in either branch of the if-statement. But we can't tell you how to fix it. You
need to give us more information to allow that.
joe
On Sat, 2 May 2009 04:51:01 -0700, Kai <Kai@discussions.microsoft.com> wrote:
Hi All,
Thank you for your help. I posted my snippet from MyWnd::RePaint(). But
HWND hWnd;
GetDlgItem(IDC_PREVIEW_WINDOW, &hWnd);
PAINTSTRUCT ps;
HDC hdc;
RECT rcClient;
::GetClientRect(hWnd, &rcClient);
hdc = ::BeginPaint(hWnd, &ps);
if(m_pWC)
m_pWC->RepaintVideo(hWnd, hdc);
::EndPaint(hWnd, &ps);
is copied from windowless.cpp from a DirectShow sample code as follows
C:\Program Files\Microsoft
SDKs\Windows\v6.1\Samples\Multimedia\DirectShow\VMR9\Windowless
"Kai" wrote:
I use the following Repaint function to redraw my image
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND,
reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
HWND hWnd;
GetDlgItem(IDC_PREVIEW_WINDOW, &hWnd);
PAINTSTRUCT ps;
HDC hdc;
RECT rcClient;
::GetClientRect(hWnd, &rcClient);
hdc = ::BeginPaint(hWnd, &ps);
if(m_pWC)
m_pWC->RepaintVideo(hWnd, hdc);
::EndPaint(hWnd, &ps);
CDialog::OnPaint();
}
m_pWC is non zero after initialization.
for safety, I added OnActivate function
CDialog::OnActivate(nState, pWndOther, bMinimized);
// TODO: Add your message handler code here
if(nState != WA_INACTIVE)
UpdateWindow();
It doesn't seem UpdateWindow repaints window immediately.
Any better solution?
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm