Solved

Update in CListBox Instantaneously ???

Posted on 1998-04-25
13
442 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
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.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now