Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Update in CListBox Instantaneously ???

Posted on 1998-04-25
13
Medium Priority
?
517 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

916 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