Page 1 of 1

How to refer to a formowner when use the Showform method

Posted: Tue Apr 24, 2018 3:25 pm
by Taku Izumi
Hi,

When a member form is opened by the ShowForm method, the FormOwner of that form is NULL.

The following two codes are samples for confirming this behavior.

Code: Select all

* Owner Form code
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(301) Componentversion(2) Left(652) Top(212)
Define_Com Class(#PRIM_PHBN) Name(#Button1) Caption('Show MemberForm') Displayposition(1) Left(40) Parent(#COM_OWNER) Tabposition(1) Top(29)
Define_Com Class(#FormB) Name(#FormB)
Evtroutine Handling(#Button1.Click)
#FormB.FormOwner <= #COM_OWNER
#FormB.ShowForm
Endroutine
End_Com

Code: Select all

* Member form code
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(301) Componentversion(2) Left(577) Top(288)
Define_Com Class(#PRIM_LABL) Name(#Label1) Caption('Label1') Displayposition(1) Ellipses(Word) Height(25) Left(83) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(102) Verticalalignment(Center) Width(334)

Evtroutine Handling(#com_owner.CreateInstance)

Set Com(#com_owner) Caption(*component_desc)

If Cond(#COM_OWNER.FormOwner *Is *NULL)
#Label1.Caption := 'FormOwner is Null'
Else
#Label1.Caption := 'FormOwner is ' + #COM_OWNER.FormOwner.Name
Endif

Endroutine
End_Com
How to refer to the FormOwner in a member form when use the ShowForm method?

Regards,
Taku Izumi

Re: How to refer to a formowner when use the Showform method

Posted: Tue Apr 24, 2018 4:40 pm
by MarkD
Does using Evtroutine Handling(#com_owner.Initialize) produce a different result?

I think that Evtroutine Handling(#com_owner.CreateInstance) executes before the setting of the FormOwner property.

Re: How to refer to a formowner when use the Showform method

Posted: Wed Apr 25, 2018 2:26 pm
by Taku Izumi
#Com_owner.Initialize routine also is same result.

For comparison, when a member form is opened by ShowModalForm method, the owner form is set to the FormOwner property of a member form.

Do you think this is a defect of the ShowForm method?

Re: How to refer to a formowner when use the Showform method

Posted: Wed Apr 25, 2018 11:43 pm
by atostaine
Does it work if you change to formstyle to Owned or OwnedChild?

Art

Re: How to refer to a formowner when use the Showform method

Posted: Thu Apr 26, 2018 11:39 am
by Taku Izumi
Hi Art,

After changing a member form to other than 'Normal', it became to refer the FormOwner property.

Thanks,
Taku