[Lazarus] Form event

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Feb 20 11:36:59 CET 2013


Antonio Fortuny schrieb:
> 
> 
> Le 19/02/2013 19:34, Hans-Peter Diettrich a écrit :
>> Antonio Fortuny schrieb:
>>> Hi folks.
>>>
>>> Do you know an event or any other trick I could use when a form
>>> re-gains control, i.e. is focused again ?
>>> Events OnShow, OnActivate fire only once after OnCreate.
>>
>> These were my candiates as well.
>>
>>> The form is brought to the foreground by the means of a
>>> MyForm.BringToFront once a OtherForm.ShowModal returns. The reason is
>>> because the WindowsCE forms stack control seems to be rubbish.
>>
>> Sorry, I don't know how WinCE behaves in this case.
> Very simple: when yo exit a modal displayed form you are not always sure 
> to have on the screen the form which displayed the closed one. That's 
> why I guess that forms stack is not very well managed

These are two problems. One is the Z order maintenance, and another one 
which messages are sent. I only know from working on one program (C++), 
that WinCE differs from traditional Windows behaviour.

>  But when ShowModal
>> returns, you can do whatever is needed - e.g. invoke FormActivate or
>> whatever handler contains your specific code.
> Yes, but the problem is that this main form shows two dozens of other 
> forms ! It's easy to gain control after ShowModal returns but the code 
> has to be repeated as many times as ther are forms to process.

AFAIR the LCL maintains a forms list in Z order (Application.Forms?), 
which may be useful to establish the wanted Z order.

DoDi





More information about the Lazarus mailing list