CEdit window update problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stefaan
    New Member
    • Jul 2007
    • 5

    #1

    CEdit window update problem

    Hi all,

    I have a CEdit window in my application which I use as a sort of output console for text generated by my program.

    Each subsection writes to its own string buffer and every 2 seconds I update the window. for this I use the following code. this is code I found on the internet.


    Code:
    CEdit ctrlPad;
    
    Frame::update(){
            string all = output + searchOutput + nl + resultOutput + nl;
            ctrlPad.SetWindowText(Text::toT(all).c_str());
            UpdateLayout();
    }
    
    Frame::UpdateLayout()
    {
    	CRect rc;
    
    	GetClientRect(rc);
    
    	rc.bottom -= 1;
    	rc.top += 1;
    	rc.left +=1;
    	rc.right -=1;
    	ctrlPad.MoveWindow(rc);
    }

    the code works in the way that it indeed updates the window. the problem is that it also puts the current view of the document at the top. this is rather irritating if the output stretches a couple of pages and every 2 seconds you get booted back to the top of the first page.

    the question is how do I modify this code so that additional text is added to the window without the view jumping to the top.

    I hope the problem is clear, it is not easy to explean without actualy seeing it :)

    anyway thanks in advance for helping :p,
    stefaan
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The MoveWindow is inherited from CWnd. There are two overloads. The one you are using requires a struct and it calls Win32 MoveWindow with a repaint argumnet set to true. The repaint is most likely causing you windows to move on top.

    Try the other overload:
    [code=cpp]
    Frame::UpdateLa yout()
    {
    CRect rc;

    GetClientRect(r c);

    rc.bottom -= 1;
    rc.top += 1;
    rc.left +=1;
    rc.right -=1;
    ctrlPad.MoveWin dow(rc.left, rc.top, rc.right, rc.bottom, FALSE);
    }
    [/code]

    You will need to redraw as necessary.

    This is just a guess. Let me know what happens.

    Comment

    • stefaan
      New Member
      • Jul 2007
      • 5

      #3
      I have tried it, and it doesn't seem to make a difference :(

      anymore idea's out there?

      thanks,
      stefaan

      Comment

      Working...