How do I update continuosly an edit box with my serial port information?

Posted on 2003-02-19
Medium Priority
Last Modified: 2007-12-19
Begineer here:

I have a dialog box with an edit box and a connect button and I would like to update the data on my edit box continuosly. I am using the Serial class found here:


I am having difficulty putting my code after the OnConnect in a loop(the program locks up):

//m_data is the variable of my edit box

nBytesToRead = serial.ReadDataWaiting();
char *buffer = new char[nBytesToRead];
nBytesRead = serial.ReadData(buffer ,nBytesToRead);
m_data = buffer;

I have tried using sleep but it doesn't work either.Anyhelp would be appreciated. Thank you.

Question by:cttsao
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
1 Comment

Accepted Solution

MDarling earned 150 total points
ID: 7986406
You can't put it in your onconnect because that is a message handler.  No messages can be processed until you return from that function.  You need to return to allow other messages to be handled, such as paints or mouse clicks etc.

You could use SetTimer, KillTimer and OnTimer to process your messages periodically.

Set a timer to fire every few milliseconds and handle one (or more if you can handle it without locking your application up) addition to your edit box each OnTimer call.

- Mike

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

777 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