Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

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

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.

1 Solution
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now