Solved

Update in CListBox Instantaneously ???

Posted on 1998-04-25
13
487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

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

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.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

615 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