Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:11:20+00:00 2026-06-01T13:11:20+00:00

My Application is recieving data from external hardware and plots it onto a panel

  • 0

My Application is recieving data from external hardware and plots it onto a panel (can be actually any other child of “Control”). The painting currently happens in a “OnPaint” callback. A List is used to store the recently recieved data to allow to redraw the whole graph in OnPaint to get the proportions right if e.g. the window gets resized.

The graph itself is drawn with the e->Graphics element using lines between two data points.

This is working fine, but when I have new data coming in every 50 ms (= repaint the whole graph), the graph soon begins to flicker. The flickering gets stronger the more data needs to be plotted (when the right side of the control is reached, the data cache gets cleared, so there is a finite max number of data points in the graph).

The main part of my code:

void Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
{
    Size^ s = m_Control->Size;
    Bitmap^ bmp = gcnew Bitmap(s->Width, s->Height);
    Graphics^ g = Graphics::FromImage(bmp);

    for each(double y in m_Data)
    {
        /* ...calculations etc... */
        g->DrawLine(Pens::Blue, recentX, recentY, currentX, currentY);
    }           

    e->Graphics->DrawImageUnscaled(bmp, 0, 0);
}

Any suggestion how I can optimize the painting to get rid of the flickering? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:11:21+00:00Added an answer on June 1, 2026 at 1:11 pm

    The flickering comes from WinForms erasing the background before calling your Paint handler.

    You need to write your own custom control inheriting from Panel, and override OnPaintBackground to do nothing (especially, do not call the base class version).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented an application to get the data from local mobile SQLite db
I'm writing a .NET 3.5 application (WinForms) which uses classes from an external DLL
I have a ListView control receiving data from BackgroundWorker through ReportProgress . The worker
I have an application which receives GPS data from a mobile device as well
I am building a WinForms application reading from a socket data and charting lines.
I am working on an application receiving data from a backend. The problem is,
I have made an application that is receiving location data from a few web
I am sending and receiving data using fsockopen and fwrite. My application receives the
I have a server application receiving messages from a JMS queue. And client applications
i want to start an application on receiving sms from a particular number. i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.