Re: listbox updating problem
Thanks, but I found a simpler answer from a Test Engineer where I work. He
suggested using UpdateWindow(). I knew about the UpdateData and ShowWindow,
but I was unaware of UpdateWindow. That seems to have done the trick from
displaying the message before I even open the serial port. I may have to
use your method though after I open the serial port. Again, thanks a lot
for the info. I really need to learn how to use threads more than what I do
now.
Z.K.
"Tom Serface" <tom.nospam@camaswood.com> wrote in message
news:%23ieFNGZkHHA.4188@TK2MSFTNGP02.phx.gbl...
Your routine to read the port is probably blocking the messaging. You
could put the query routine in a thread and post messages to the UI that
updates the listbox, or put something in your reading loop like:
//
// 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++ ))
;
}
to allow messages to be processed at different times. You could do
something like:
while(myDataIsBeingRead) {
ReadOneBlockOfData();
UpdateListBox();
GiveTime();
}
Tom
"Z.K." <nospam@nospam.net> wrote in message
news:%23mbMhCZkHHA.4936@TK2MSFTNGP03.phx.gbl...
I have a routine that goes out and queries a access point, but I write a
message to a listbox first. The routine works fine, but I am having
trouble displaying the message at the proper time. It only displays the
message after the serial port routine is complete and displays all the
data at one time. Is there a way to display the data when I actually want
it displayed? I tried the listbox methods .ShowWindow() and .UpdateData()
, but these did not work.
Z.K>