can't force redraw of my frame

Discussion in 'C++' started by Maik Wiege, Jan 19, 2004.

  1. Maik Wiege

    Maik Wiege Guest

    Hi!
    I want to show a blinking text over my derived CMDIChildWnd-class. The
    blinking is done by one view which is hold by my frame. I set up a timer and
    write text to the parent frame, which works fine. But I can't get the text
    away the next time the timer fires. Here is some code:

    void MyView::OnTimer(UINT nIDEvent)
    {
    if (nIDEvent!=1) return;
    showText = !showText;
    // Call base class handler.
    CView::OnTimer(nIDEvent);

    CUserFrame* frame = (CUserFrame*)(this->GetParentFrame());
    CRect clientRect;
    frame->GetClientRect(&clientRect);

    if (showText){
    // display the text --------- THIS WORKS FINE
    CFont font;
    CDC* dc = frame->GetDC();
    font.CreatePointFont (720, _T ("Arial"));
    CFont* oldFond = dc->SelectObject (&font);;
    dc->SetBkMode (TRANSPARENT);
    dc->SetTextColor(RGB(255,100,0));
    dc->DrawText(_T("blink"), clientRect, DT_SINGLELINE | DT_CENTER |
    DT_VCENTER);
    dc->SelectObject (oldFond);
    frame->ReleaseDC(dc);
    }else{
    // remove the text -------------- DOESN'T WORK

    // here are many things I tried, but without success
    ::InvalidateRect(frame->m_hWnd,0,TRUE);
    ::InvalidateRect(frame->m_hWnd,&clientRect,TRUE);
    ::UpdateWindow(frame->m_hWnd);
    frame->UnlockWindowUpdate();
    frame->Invalidate(true);
    frame->UpdateWindow();
    frame->RedrawWindow();
    frame->my2View->UnlockWindowUpdate(); /* my2View is anoter
    view that the frame holds (It has a static splitter)*/
    frame->my2View->InvalidateRect(&clientRect);
    frame->my2View->Invalidate(true);
    frame->my2View->UpdateWindow();
    frame->my2View->RedrawWindow();
    AfxGetMainWnd()->RedrawWindow();

    /* To be sure that the code is working corect I added a drawText
    here,
    which is displayed correctly above the first text and is under
    the "blink" after the next timer event */
    CDC* dc = frame->GetDC();
    dc->DrawText(_T("hello..."), clientRect, DT_SINGLELINE | DT_CENTER |
    DT_VCENTER);
    frame->ReleaseDC(dc);
    }
    }

    So the result of the above code is that "blink" is written on my window,
    then "hello" is written above it, than "blink" again... but the other text
    will never be deleted.
    Anyone any ideas why this is so, why the window is not redrawn, so the
    "blink" should disapear, becaus it is not in the frames OnPaint()?

    Thanks for any help
    Maik
    Maik Wiege, Jan 19, 2004
    #1
    1. Advertising

  2. "Maik Wiege" <> wrote in message
    news:bufq00$2ks$07$-online.com...
    > Hi!
    > I want to show a blinking text over my derived CMDIChildWnd-class.

    The
    > blinking is done by one view which is hold by my frame. I set up a

    timer and
    > write text to the parent frame, which works fine. But I can't get

    the text
    > away the next time the timer fires. Here is some code:
    >


    This is a very advanced subject. We cannot help you here. You should
    post in a newsgroup devoted to blinking text.

    Jonathan
    Jonathan Turkanis, Jan 19, 2004
    #2
    1. Advertising

  3. Maik Wiege

    Jorge Rivera Guest

    Jonathan Turkanis wrote:

    > "Maik Wiege" <> wrote in message
    > news:bufq00$2ks$07$-online.com...
    >
    >>Hi!
    >>I want to show a blinking text over my derived CMDIChildWnd-class.

    >
    > The
    >
    >>blinking is done by one view which is hold by my frame. I set up a

    >
    > timer and
    >
    >>write text to the parent frame, which works fine. But I can't get

    >
    > the text
    >
    >>away the next time the timer fires. Here is some code:
    >>

    >
    >
    > This is a very advanced subject. We cannot help you here. You should
    > post in a newsgroup devoted to blinking text.


    Actually, we can't help you here because it is and MFC question.
    Go to a VisualC newsgroup.

    :)

    Jorge L.

    >
    > Jonathan
    >
    >
    Jorge Rivera, Jan 23, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 6e
    Replies:
    0
    Views:
    546
  2. 6e
    Replies:
    0
    Views:
    1,993
  3. ~~~ .NET Ed ~~~

    How to force a Web XML control to redraw/repaint?

    ~~~ .NET Ed ~~~, Mar 19, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    148
    ~~~ .NET Ed ~~~
    Mar 19, 2005
  4. Force an FX redraw

    , Feb 19, 2005, in forum: Ruby
    Replies:
    6
    Views:
    116
    ritchie
    Feb 20, 2005
  5. Darcy
    Replies:
    5
    Views:
    209
    David Mark
    Jul 16, 2007
Loading...

Share This Page