1

I've been working on an application that ties together a couple of processing tasks into one graphical interface. I've got three main functions, each operating in their own thread, in parallel. One processes raw data obtained from sensors, the second is the main win32 application, used to display data, and the third communicates with a separate computer.

The problem I have is displaying the information that I've received from the sensors, which changes every 25 milliseconds, in my graphical interface.

I've established that the data is being passed from one thread to the other successfully (as an integer).

In my GUI I have dialog boxes dedicated to displaying this information, my current tactic is using the SetDlgItemInt() function in the main message loop. This is what the while loop looks like at the moment;

while (GetMessage(&msg, NULL, 0, 0))
{
      SetDlgItemInt(hWnd, IDC_DISPBOX1,     *Value, True);
      if (!TranslateAccelerator(msg.hWnd, hAccelTable, &SMSFs))
      { 
            TranslateMessage(&msg);
            DispatchMessage(&msg);
      }
}

This displays the infomation, but it flashes constantly as it updates, and I was wondering if there is a better way to do this.

I'm new to win32 gui programming, and GUI programming in general, and I couldn't find an example of how to approach this way of displaying information, so this is what I've improvised using what I know of programming in this environment.

Gus10000
  • 11
  • 2
  • Try double-buffering the control where the data is displayed, if you can: http://stackoverflow.com/questions/1842377/double-buffer-common-controls – user253751 Apr 12 '16 at 04:34
  • 25ms update is overkill for a human eye. You better off throttling the visual update down significantly, that will have a good effect on your real data processing throughput well too: the GUI won't hold the processing back. Throttling can be done in different ways. You can introduce a timer and keep looking at it. Furthermore, you may want to introduce throttling in some earlier stage of your data visualization pipeline, not only at the end. – Csaba Toth Apr 12 '16 at 05:50
  • A combination of both approaches sounds good. Perform flicker-free updates, and do them less frequently (10 times a second ought to be _plenty_). – paddy Apr 12 '16 at 05:56
  • You're updating the dialog box far more often than every 25ms. – Raymond Chen Apr 12 '16 at 06:23
  • Thanks guy's, this all makes good sense to me, I'll try it out today. Cheers! – Gus10000 Apr 12 '16 at 22:05

0 Answers0