>Hello everybody,
>
>
>I have a problem with calling second modal form from another modal form.
>Usualy I have the following code to run second moddal form:
>
>if type([thisform.roObj])=[O] and !isnull(thisform.roObj)
>else
>thisform.roObj=createobj([secondmodalform])
>endif
>thisform.roObj.Show()
>
>
>instead of releasing second form I just Hide() it, so, it could be reused on next button click
>this code works just fine for first time but then on second or third run second modal form shows up active but BEHIND the first form.
>
>So, the question is how to avoid this, is there any way to bring second modal form to top in any case?
>
Yes; save the hWnd of the Form to a Form property (call it nhWnd) introduced at RunTIme, the first time it's actually displayed by:
* In Show and Activate methods, add the following code:
=DODEFAULT()
DECLARE INTEGER GetActiveWindow IN WIN32API
IF TYPE('thisform.nhWnd') = 'U'
thisform.AddProperty('nhWnd',GetActiveWindow())
ENDIF
DECLARE INTEGER SetForegroundWindow IN WIN32API INTEGER
=SetForegroundWindow(thisform.nhWnd)