Discussion:
Problems getting CStatic to refresh
(too old to reply)
Eddie
2005-05-09 15:45:47 UTC
Permalink
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.

VERIFY(m_LoadTitleTxt.Create(szTemp, WS_CHILD | WS_VISIBLE,
CRect(10,10,130,30), this));

Thanks
Eddie.
Doug Harrison [MVP]
2005-05-09 16:21:30 UTC
Permalink
Post by 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:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_cwnd.3a3a.onctlcolor.asp
Post by Eddie
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++
RainMan
2005-05-09 19:50:01 UTC
Permalink
Is static control part of dialog resource used by CFormView derived class or
you embed it in another CView derived?
Could you post more details?
Post by 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.
VERIFY(m_LoadTitleTxt.Create(szTemp, WS_CHILD | WS_VISIBLE,
CRect(10,10,130,30), this));
Thanks
Eddie.
Naren
2005-05-10 06:44:01 UTC
Permalink
hi,
i worked on the sample dialog applicaton, and it is refreshing properly. BUt
i got the same kind of problem when developing one application for my
company. At that time becasue of timely deadlines i couldn;t look on that
more. To get the quilk solution what i did was i invalidated the view, and in
the onpaint of that view i manually refreshed the previous content of static
control. If i came to know the solution, i ll let u know

naren
Post by 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.
VERIFY(m_LoadTitleTxt.Create(szTemp, WS_CHILD | WS_VISIBLE,
CRect(10,10,130,30), this));
Thanks
Eddie.
Loading...