Page History
[ |../../index.htm#lansa/l4wdev06_1115.htm]
現在地:
...
以下の例では、フォームはREFEX1とREFEX2です。
メイン・フォーム
FUNCTION options(*DIRECT)
BEGIN_COM role(*EXTENDS #PRIM_FORM) CAPTION('Main Form') HEIGHT(290) LEFT(318) TOP(128) WIDTH(386)* When we use REFERENCE(*DYNAMIC) we tell the application that an instance of the form* #REFEX2 (referred to as #AddressForm) will be created when we get round to it, not when this main form is loaded.* This means that before we can use this new reference, we have to create it using a SET_REF command:DEFINE_
...
COM class(#REFEX2)
...
name(#AddressForm)
...
reference(*dynamic)
...
DEFINE_COM class(#PRIM_PHBN) name(#PHBN_ADDR) CAPTION('Show Address Form') DISPLAYPOSITION(1) LEFT(248) PARENT(#COM_OWNER) TABPOSITION(1) TOP(16) WIDTH(112)DEFINE_COM class(#PRIM_STBR) name(#STBR_1) DISPLAYPOSITION(2) HEIGHT(24) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(239) WIDTH(378)DEFINE_COM class(#EMPNO.Visual) name(#EMPNO) DISPLAYPOSITION(3) HEIGHT(18) LEFT(22) MARGINLEFT(100) PARENT(#COM_OWNER) TABPOSITION(3) TOP(21) WIDTH(163)DEFINE_COM class(#PRIM_GRID) name(#GRID_1) DISPLAYPOSITION(4) HEIGHT(179) LEFT(24) NOTIFICATIONSTYLE(Default) PARENT(#COM_OWNER) SHOWBUTTONSELECTION(False) SHOWSELECTIONHIGHLIGHT(True) TABPOSITION(4) TOP(48) WIDTH(337)DEFINE_COM class(#PRIM_GDCL) name(#GDCL_1) DISPLAYPOSITION(1) PARENT(#GRID_1) SOURCE(#EMPNO) WIDTH(35)DEFINE_
...
COM class(#PRIM_GDCL)
...
name(#GDCL_2)
...
DISPLAYPOSITION(2)
...
PARENT(#GRID_1)
...
SOURCE(#SURNAME)
...
WIDTH(27)
...
WIDTHTYPE(Remainder)
...
EVTROUTINE handling(#com_owner.Initialize)SELECT fields(#GRID_1) from_file(PSLMST)ADD_ENTRY to_list(#GRID_1)ENDSELECTENDROUTINE
...
EVTROUTINE handling(#PHBN_ADDR.Click)* Create an instance of the AddressForm.After this statement we will be in basically the same position as we would have been had* we simply used a normal DEFINE_COM without the dynamic reference:SET_REF com(#AddressForm) to(*create_as #refex2) * Now that an instance of the AddressForm exists, we can run the methods in it.We invoke u_GetDetails passing in the employee* number and surname:INVOKE method(#AddressForm.u_GetDetails) U_WITHEMPNO(#EMPNO) U_WITHSURNAME(#SURNAME)ENDROUTINE
...
* This event signalled from the AddressForm tells this form that it has closed:EVTROUTINE handling(#AddressForm.u_Detail_form_closed)* When the instance of the AddressForm closes, remove it from memory by setting the reference to it to*NULL.* This says remove anything related to AddressForm from memory.In other words the form itself, the button* and the fields will all disappear from the system:SET_
...
REF com(#AddressForm)
...
to(*null)
...
ENDROUTINEEND_COM
...
アドレスフォーム
FUNCTION options(*DIRECT)
BEGIN_COM role(*EXTENDS #PRIM_FORM) CAPTION('Address Form') HEIGHT(211) LEFT(320) TOP(112) WIDTH(405)DEFINE_COM class(#PRIM_STBR) name(#STBR_1) DISPLAYPOSITION(1) HEIGHT(24) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(160) WIDTH(397)DEFINE_COM class(#EMPNO.Visual) name(#EMPNO) DISPLAYPOSITION(2) HEIGHT(18) LEFT(18) PARENT(#COM_OWNER) TABPOSITION(2) TOP(40) WIDTH(215)DEFINE_COM class(#SURNAME.Visual) name(#SURNAME) DISPLAYPOSITION(3) HEIGHT(19) LEFT(16) PARENT(#COM_OWNER) TABPOSITION(3) TOP(20) WIDTH(324)DEFINE_COM class(#PRIM_PHBN) name(#PHBN_1) CAPTION('Close') DISPLAYPOSITION(4) LEFT(304) PARENT(#COM_OWNER) TABPOSITION(4) TOP(128)DEFINE_COM class(#ADDRESS1.Visual) name(#ADDRESS1) DISPLAYPOSITION(5) HEIGHT(19) LEFT(16) PARENT(#COM_OWNER) TABPOSITION(5) TOP(72) WIDTH(363)DEFINE_COM class(#ADDRESS2.Visual) name(#ADDRESS2) DISPLAYPOSITION(6) HEIGHT(19) LEFT(16) PARENT(#COM_OWNER) TABPOSITION(6) TOP(88) WIDTH(363)DEFINE_
...
COM class(#ADDRESS3.Visual)
...
name(#ADDRESS3)
...
DISPLAYPOSITION(7)
...
HEIGHT(19)
...
LEFT(16)
...
PARENT(#COM_OWNER)
...
TABPOSITION(7)
...
TOP(104)
...
WIDTH(363)
...
* Define an event which will tell this form has closedDEFINE_
...
EVT name(u_Detail_form_closed)
...
* Published method which will get the #empno and #surname values from the main form, retreive the address information* from the PSLMST file and then show this formMTHROUTINE name(u_GetDetails)DEFINE_MAP for(*INPUT) class(#EMPNO) name(#u_WithEMPNO)DEFINE_MAP for(*INPUT) class(#SURNAME) name(#u_WithSURNAME)CHANGE field(#EMPNO) to('#U_WITHEMPNO.VALUE')
...
CHANGE field(#SURNAME)
...
to('#U_WITHSURNAME.VALUE')
...
IF cond('#EMPNO *NE *BLANKS')FETCH fields(#ADDRESS1 #ADDRESS2 #ADDRESS3) from_file(PSLMST) with_key(#EMPNO)ENDIFINVOKE method(#COM_OWNER.ShowForm)ENDROUTINE
...
EVTROUTINE handling(#PHBN_1.Click)INVOKE method(#com_owner.closeform)ENDROUTINE
...
EVTROUTINE handling(#COM_OWNER.Closing) options(*NOCLEARMESSAGES *NOCLEARERRORS)* signal an event to the parent form telling that this form has closedSIGNAL event(u_detail_form_closed)ENDROUTINEEND_COM
...