0

Delphi 10.2 behavior is very strange. When I move the cursor over any input control (TCheckBox, TEdit,...) the OnPaint message called on the form. I have a TPanel on the form witch is a canvas for custom drawing (TControlCanvas is used). How could I disable the unwanted OnPaint messages because the custom draw could take a while (thousands of elements may draw themselves on it).

I just want it to repaint on form resize or on after invalidate.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
User007
  • 187
  • 10
  • 3
    The obvious approach is to stop doing things in the form's `OnPaint`. – David Heffernan Aug 27 '18 at 10:02
  • Also, I fixed issues with your tagging and the versions. For future reference, note that you aren't using XE, that was the version released after Delphi 2010 and before XE2. And also note that there is not XE10, when they moved to version 10 they dropped using XE. – David Heffernan Aug 27 '18 at 10:27
  • @DavidHeffernan Then where should I repaint the custom draw TPanel? Could you maybe give an example or just tease with the users? – User007 Aug 27 '18 at 11:10
  • 2
    Change your drawing routine to draw on a in-memory bitmap and only do a bitblt of that bitmap to the panel when panel needs to update. Thus your long lasting drawing may spend time as needed, but the visual update is faster than a blink. If the drawing on the bitmap takes awful long time, you may need to use 2 bitmaps, one to update the form and one to draw on. – Tom Brunberg Aug 27 '18 at 11:14
  • 2
    What @TomBrunberg suggests is a good idea. Rather than a panel though, shouldn't you be using a `TPaintBox`? – David Heffernan Aug 27 '18 at 11:16
  • @TomBrunberg Thanks the idea. I will consider about that. It seems very useful to me. You got an up-vote from me ;) – User007 Aug 27 '18 at 11:40

0 Answers0