I'm having problems trying to update the contents a CStatic control
that exists in a SDI application. Whenever I try to update the control,
the new text appears to sit on top of the existing text. It seems that
the control does not get refreshed after the call to SetWindowText(). I
have tried calling CStatic::Invalidate() and CStatic::RedrawWindow()
directly but nothing seems to work.
My only solution is to call CView::Invalidate() every couple of
seconds, but this causes a very anoying flicker. Here is the call to
CStatic::Create(). Maybe I'm missing something? Any help would be
appreciated.
VERIFY(m_LoadTitleTxt.Create(szTemp, WS_CHILD | WS_VISIBLE,
CRect(10,10,130,30), this));
Thanks
Eddie.
> Hi,
>
> I'm having problems trying to update the contents a CStatic control
> that exists in a SDI application. Whenever I try to update the control,
> the new text appears to sit on top of the existing text. It seems that
> the control does not get refreshed after the call to SetWindowText(). I
> have tried calling CStatic::Invalidate() and CStatic::RedrawWindow()
> directly but nothing seems to work.
>
> My only solution is to call CView::Invalidate() every couple of
> seconds, but this causes a very anoying flicker. Here is the call to
> CStatic::Create(). Maybe I'm missing something? Any help would be
> appreciated.
I think your parent window need to handle WM_CTLCOLORSTATIC. In MFC, see
OnCtlColor:
> VERIFY(m_LoadTitleTxt.Create(szTemp, WS_CHILD | WS_VISIBLE,
> CRect(10,10,130,30), this));
FWIW, I've always had misgivings about the VERIFY macro. For something that
can legitimately fail at runtime due to forces beyond your control, it
seems to me you should handle the error. That is, the successful execution
of your Create call in debug mode does not necessarily imply successful
execution in release mode, so checking it with VERIFY is thus rather bogus,
IMO.
--
Doug Harrison
Microsoft MVP - Visual C++
naren