Avoidance of calling ProcessMessages

I have a component that I created that includes a hardware rendering accelerator in TWinControl, so you can put it in a form. In most cases, it works very well, but if I try to resize the control, everything will be empty until the message loop starts and calls WndProc for rendering, which is located in an external DLL. This means that I need to call Application.ProcessMessages explicitly after I resized the control in the code, which, as I know, is considered bad practice.

Is there a way to put some logic in the control itself to make it call WndProc in the DLL when I resize the control, so I won’t need to call ProcessMessages to make things display correctly?

+7
controls delphi
source share
2 answers

Instead, you can call TWinControl.Update , which should just send a Messenger WM_PAINT message so that you don't process arbitrary messages.

+10
source share

The correct solution is to call InvalidateRect when resizing. Windows will then display the WM_PAINT message. For reference, you should pull Petzold off the shelf and read his chapter on painting.

+3
source share

All Articles