1

I have implemented a Scroll box that dynamically adds TCharts dependent on the number of channels available on an input device. The charts repaint on a loop to show the value of the voltage through the channel, so that the display outputs effectively a "real-time" view of the voltages being applied to each channel.

Currently I have an Application.ProcessMessages function to prevent the application becoming unresponsive during a run, but I would like to be able to scroll through the box whilst the channels are being displayed, without disturbing the display, which currently pauses whilst the scroll bar is clicked.

Is this possible?

1 Answers1

2

Yes, this is possible.

The charts repaint on a loop ...

Repaints driven by an own loop indeed ensures respiratory distres on the system, which exactly is the reason for the need of Application.ProcessMessages. Try not to use it. Instead, you should just ask the charts to repaint themselves with Invalidate when new data comes in, and let the system decide when it is convenient to do so.

NGLN
  • 43,011
  • 8
  • 105
  • 200
  • 2
    Note that `Refresh` is a call to `Repaint`, which is an immediate paint for windowed controls (`UpdateWindow` after `InvalidateRect` which results in a `WM_PAINT` that bypasses the message queue), not much different than the design in the question . – Sertac Akyuz Sep 20 '17 at 12:42
  • 2
    @Sertac Yep, thanks for the reminder. I removed it from the answer. – NGLN Sep 20 '17 at 18:44