Solved

Update in CListBox Instantaneously ???

Posted on 1998-04-25
13
461 Views
Last Modified: 2013-11-19
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
Comment
Question by:sllsgl
  • 5
  • 3
  • 3
  • +1
13 Comments
 
LVL 8

Expert Comment

by:gelbert
ID: 1302205
Tyr to call Invalidate() and UpdateWindow() for ListBox after AddString()
0
 

Author Comment

by:sllsgl
ID: 1302206
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
 
LVL 23

Expert Comment

by:chensu
ID: 1302207
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:sllsgl
ID: 1302208
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
 
LVL 23

Expert Comment

by:chensu
ID: 1302209
I think the Invalidate & UpdateWindow should work.
0
 

Author Comment

by:sllsgl
ID: 1302210
Thanks but I have tried them before & they don't, so could be really my failing PC's fault, I guess :(
0
 
LVL 8

Expert Comment

by:gelbert
ID: 1302211
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
 

Author Comment

by:sllsgl
ID: 1302212
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
 
LVL 8

Expert Comment

by:gelbert
ID: 1302213
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
 
LVL 1

Accepted Solution

by:
Blondie050798 earned 20 total points
ID: 1302214
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
 
LVL 1

Expert Comment

by:Blondie050798
ID: 1302215
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
 

Author Comment

by:sllsgl
ID: 1302216
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
 
LVL 1

Expert Comment

by:Blondie050798
ID: 1302217
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question