Re: Text window not displaying inside loop

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



But why? Why not just use an OnTimer handler, and it all comes free?
joe

On Fri, 29 Jun 2007 15:18:47 -0700, "Tom Serface" <tom.nospam@xxxxxxxxxxxxx> wrote:

oops hit wrong key... sorry:

//
// Release main thread for background processing
//
void GiveTime()
{
// Idle until the screen redraws itself, et. al.
MSG msg;
while (::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) {
if (!AfxGetThread()->PumpMessage( )) {
::PostQuitMessage(0);
break;
}
}
// let MFC do its idle processing
LONG lIdle = 0;
while (AfxGetApp()->OnIdle(lIdle++ ))
;
}

So in your example you could do something like:

CString Output;
while (CountDown--) {
Output.Empty();

// extract figures and format into Output


m_DriveList.SetWindowText (Output); // display figures
GiveTime(); // Allow UI to update
}


Tom

"Lilith" <lilith@xxxxxxxxx> wrote in message
news:q6va831t2ksp0o3ehdl643cggurail6cgn@xxxxxxxxxx
I have a utilty I'm in the process of writing for montoring the amount
of remaining space on a number of network drives. I'm adding
functionality to loop every X-seconds then checking the figures again.
Eventually these figures will be written to a file but for now I'm
trying to display them fresh on each loop to a text box.

CString Output;
while (CountDown--) {
Output.Empty();
.
. // extract figures and format into Output
.

m_DriveList.SetWindowText (Output); // display figures
Sleep (1000); // wait a second
}

In the current configuration this should accumulate the figures and
put them in Output. I can vouch that this is being done. My problem
is that the text window won't display until the while loop is
finished. Due to an earlier glitch, when I hadn't emptied Output at
the top of the loop, I could tell that the text was being placed in
the text box because I watched the vertical scroll bar react. But it
never displayed.

Is there something I need to do to force the display? Or is this
expected behavior?

--
TIA,
Lilith
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Interpreting the colon operator
    ... I tried this by using the print statement inside the loop. ... What follows then would be a display of ... is apparently affected by the fact that matlab is aware that 'Av' ... three-dimensional matrix even though the first index is restricted ...
    (comp.soft-sys.matlab)
  • Re: Text window not displaying inside loop
    ... // Idle until the screen redraws itself, ... MSG msg; ... functionality to loop every X-seconds then checking the figures again. ... trying to display them fresh on each loop to a text box. ...
    (microsoft.public.vc.mfc)
  • Re: Sorry, but need more help
    ... >> I tried the code below in a loop calling it. ... > most often refers to a tcl program running in the tcl web browser ... window with that data and have it stay on top and display the changes as the ... > load in the showMessage proc definition with a timeout of 10000 ...
    (comp.lang.tcl)
  • Re: Text window not displaying inside loop
    ... // Idle until the screen redraws itself, ... MSG msg; ... functionality to loop every X-seconds then checking the figures again. ... trying to display them fresh on each loop to a text box. ...
    (microsoft.public.vc.mfc)
  • Re: using a for loop to determine maximum value of an int variable
    ... With a for loop like so: ... 2145,000,000 all future increments don't generate an error. ... I'm using INT as my starting variable for exploration. ... way that I can display the value of j every, say, 10 thousand ...
    (microsoft.public.dotnet.languages.csharp)