[Lazarus] Exception in OnResize event handler
Jürgen Hestermann
juergen.hestermann at gmx.de
Sun Nov 6 12:27:52 CET 2016
In one of my Windows programs I use a splitter to separate two VirtualTreeView components on a Form.
The relation of the heights of these two VirtualTreeView components should be constant
even if the height of the Form changed.
To achieve this, the two VirtualTreeView components are anchored to the splitter and
I use the OnResize event to move the splitter in case the height of the form has changed.
This works well except for one very special case:
If I type (on Windows 8.1) Windows key + arrow down three times and then go to the (now invisible program)
with Alt+Tab then the program is shown again but consists of the Windows header with the
standard icons for minimize, maximize and close only.
If I then click on the icon to maximize the program I get an exception in
TControl.InvalidatePreferredSize where RaiseLoop is executed.
This only happens when I use the above key combinations.
I don't know what the exception actually means and how I can avoid this crash.
Any ideas?
BTW:
The help in Lazarus about the OnResize event says:
"This event is triggered after the Width, Height, ClientWidth or ClientHeight of the control has changed,
and before the LCL sends the new size to the widgetset.
The size of the underlying widget (e.g. unit LCLIntf function GetWindowSize and GetClientRect) may
differ from the control's Width/Height/ClientRect during OnResize.
During autosize the size can change multiple times, but only the last change triggers the OnResize."
[...]
"Especially it is not sufficient to write only a TForm.OnResize handler
to resize all controls on the form. This is a common bug in Delphi applications."
What does the last sentence mean?
What else is needed to resize all controls on the form?
More information about the Lazarus
mailing list