CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2012
    Posts
    20

    MFC UpdateWindow()???

    Inside my CRichEditCtrl class,

    I have a loop that changes the text using
    SetWindowText(a);
    UpdateWindow();

    But the window is not being updated to the text. I know this because when I'm in debugging mode, updatewindow does not change the text after the debug step. I'm I using UpdateWindow() wrong?
    Last edited by printz0r; June 19th, 2012 at 04:57 PM.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: MFC UpdateWindow()???

    You shouldn't need it. Show your real code. Is your SetWindowText call in a tight loop?

  3. #3
    Join Date
    Jun 2012
    Location
    India
    Posts
    5

    Re: MFC UpdateWindow()???

    SetWindowText does not require a call to UpdateWindow() to show the updated content. CWnd itself take care of that and you no need to specify that explicitly.

  4. #4
    Join Date
    Jul 2002
    Posts
    2,543

    Re: MFC UpdateWindow()???

    Window is redrawn only when current message handler exits. Don't expect window to be redrawn on every loop iteration.
    UpdateWindow is not required after SetWindowText.
    Replace loop with timer, changing window text on every timer tick.

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: MFC UpdateWindow()???

    Quote Originally Posted by Alex F View Post
    Replace loop with timer, changing window text on every timer tick.
    I'm not following the thinking on that one.

  6. #6
    Join Date
    Mar 2012
    Posts
    20

    Re: MFC UpdateWindow()???

    Quote Originally Posted by Alex F View Post
    Window is redrawn only when current message handler exits. Don't expect window to be redrawn on every loop iteration.
    UpdateWindow is not required after SetWindowText.
    Replace loop with timer, changing window text on every timer tick.
    Using SetEventMask(GetEventMask()|ENM_UPDATE); fixed the problem, so directly after UpdateWindow() is called, the text gets displayed. But how would I do a timer tick method?? That seems more efficient.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured