How to refer to a formowner when use the Showform method

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Taku Izumi
Posts: 70
Joined: Thu Dec 15, 2016 2:03 pm

How to refer to a formowner when use the Showform method

Post 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
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

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

Post 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.
Taku Izumi
Posts: 70
Joined: Thu Dec 15, 2016 2:03 pm

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

Post 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?
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

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

Post by atostaine »

Does it work if you change to formstyle to Owned or OwnedChild?

Art
Art Tostaine
Taku Izumi
Posts: 70
Joined: Thu Dec 15, 2016 2:03 pm

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

Post by Taku Izumi »

Hi Art,

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

Thanks,
Taku
Post Reply