My program needs to display a large number of shapes with text written on them. The number of shapes can be up to 20 thousand. Such a big scheme will turn out. For the speed of work I would like to implement my own kind of shape.

I implemented a class in which one of the fields was a shape object. After in the paint method I wrote text on it. But the problem is that due to the call of this method, when the panel on which the shape is created is invisible, the program will loop.

Total It is necessary either to understand how quickly to display quickly display these shapes with the creation of an inscription in the method of points, or to write something similar. Tell me how to be? and maybe it makes sense to do it on the canvas? I could not get. Rather, not everything was drawn, and when the screen was minimized, everything was blurred. Drawn in a paintbox.

    1 answer 1

    Create a TBitmap of the desired size.

    Erase it before starting a scene (TCanvas.FillRect)

    Draw everything into it using TCanvas functions.

    When the scene is finished, call the PaintBox redraw (for example, Refresh).

    In OnPaint PaintBox, output a bitmap to it.

    (When redrawing the form, OnPaint will be called automatically)

    • Thanks, I'll try. Will it be faster than with the shapes? - Masha Malevich
    • And what is the difference between drawing in a bitmap or drawing in a paintbox? I just do not quite understand how this solves the problem) Could you explain a little about your solution? - Masha Malevich
    • Yes, a little faster - no need to create and maintain thousands of objects. - MBo
    • one
      This is called double buffering. The output is made only for the finished image, there is no flicker, constant updating of win-controls is not required. - MBo
    • one
      Ie, let's summarize) I need to do all my machinations in the bitmap and then redraw on the paintbox, right?) Thank you so much at once) - Masha Malevich