Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 530
  • Last Modified:

Update in CListBox Instantaneously ???

I have used MSCOMM Ole in VC++5 (WinNT) to create a Serial Data Capturing program.  I am extracting a complete line of text from the received block & AddString() the string onto the ListBox in my modeless dialog for each COM port setup.  Although my code is supposed to add one line at a time onto the ListBox, but all the time, it's not showed this way.  It seems like the CPU will process all the receiver block buffer before dealing with the display portion, thereby after some delay, pouring out all the lines of processed string in one shot.  This is not ideal if many ports have been setup for logging & there are lots of data coming in.

How then can I make sure the display is instantaneous, showing one line of string when the code is supposed to?  Is there a flush statement I can use?

Thanks for any guide given :)
0
sllsgl
Asked:
sllsgl
  • 5
  • 3
  • 3
  • +1
1 Solution
 
gelbertCommented:
Tyr to call Invalidate() and UpdateWindow() for ListBox after AddString()
0
 
sllsglAuthor Commented:
Sorry gelbert, it does not help.  The display still comes out in a whole block :(
Dunno why, might be because of the slow 486 PC & the lousy 1MB qv-compatible display card.

Anyway, thanks for your suggestion :)
0
 
chensuCommented:
Did you use CWnd::SetRedraw(TRUE) on the list box? This causes the content of the list box is updated after each change. The default should be TRUE. Maybe your computer is too slow. How quickly do you AddString?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
sllsglAuthor Commented:
I didn't use SetRedraw before, hence the default should still be TRUE.  The speed of AddString is indefinite, it may be one in a few minutes or twenty plus in a few seconds.

Anyway, I will try inserting SetRedraw first.  So how about the Invalidate & UpdateWindow, do I still bother about them since they don't seems to work?

Thanks for your suggestion :)
0
 
chensuCommented:
I think the Invalidate & UpdateWindow should work.
0
 
sllsglAuthor Commented:
Thanks but I have tried them before & they don't, so could be really my failing PC's fault, I guess :(
0
 
gelbertCommented:
Just to try. If you set time interval after which you call AddString() to not less than some value X and test with different values. See at which point system starts to behave wrong way. this test will show you if something wrong with your algoriphm or it listbox problem.
0
 
sllsglAuthor Commented:
I don't quite get you gelbert, do u mean calling AddString repeatively within prefixed timing  X or try to repeatively recall AddString for prefixed X times? And determine at which X does the program show up the block of data all at once?
0
 
gelbertCommented:
I mean to call AddString once in X seconds and try to see with which X program starts to show up the block of data all at once.
0
 
Blondie050798Commented:
I have had a similar problem when trying to display ui feedback whilst decoding mpeg...the trouble you are having is that you are gets comms info. very quickly, and the CListBox is not getting enough time to redraw itself (even though the AddString will be adding it ok).  The best way is to do the communications on a thread, and post a message to your main UI thread from the communications thread passing it the status information that you want.
0
 
Blondie050798Commented:
Thanks alot for your info :) And since my project is ending, I will not wish to change my code drastically to adopt your suggestion ;) not unless u can provide me with a more detailed procedures on how to do it & it must be simple, at least to me a beginner ;)


0
 
sllsglAuthor Commented:
well the simple way would be to call the following function after calling addstring...but as I have said this may cause your code to slow down...

void CCISDBProgressDialog::PumpMessages()
{
    // Must call Create() before using the dialog
    ASSERT(m_hWnd!=NULL);

    MSG msg;
    // Handle dialog messages
    while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {
      if(!IsDialogMessage(&msg))
      {
        TranslateMessage(&msg);
        DispatchMessage(&msg);  
      }
    }
}
0
 
Blondie050798Commented:
Slow down ! I will think twice, since I am only given a pathetic 486 to run my app in NT environment, anyway thanks for your info.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now