There are two questions being asked here.
First, OnResize
is triggered when the form resizes, in either direction. Period.
Second, on why Repaint
does not work when the form gets smaller is probably because you do your own painting. Normally, only Canvas.Cliprect
needs to be repainted. When the form gets smaller, the shown area is not changed and the clipping area is empty. After all, there is not more to paint than there was before. When the form gets bigger in one direction, a similar thing happens: the clipping area consists of only the part which is added to the form's surface. Again, the previous shown area remains intact and is not updated. Only when the form expands in both directions, the clipping area cannot be made of a single rectangle any more, and so it becomes the complete surface.
The solution for you is to signal Windows to repaint the whole contents of the form at any resize, by calling Invalidate
(or Update
when it has to be repainted instantly), and to perform your custom drawing in the OnPaint
event.
OnResize
event is triggered even when you resize the form to a smaller size. - TLama