Form VL_SAM026: Example of Extended Form Initialization Handling

LANSA

Form VL_SAM026: Example of Extended Form Initialization Handling
Name: VL_SAM026

Description: The following RDMLX form emulates a form with a complex and long running initialization logic. It presents a bitmap and then uses status messages and a progress bar to inform the user of the progress of the form initialization logic.

You should create and compile form VL_SAM025 and VL_SAM029 before attempting to create or compile this form.

FUNCTION OPTIONS(*DIRECT);
BEGIN_COM FORMPOSITION(ScreenCenter) HEIGHT(416) LEFT(274) TOP(154) WIDTH(602);
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(2) HEIGHT(22) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(2) TOP(367) WIDTH(594);
DEFINE_COM CLASS(#PRIM_PGBR) NAME(#PROGBAR) DISPLAYPOSITION(1) HEIGHT(16) LEFT(417) MAXIMUMVALUE(100) MINIMUMVALUE(0) PARENT(#STBR_1) TABPOSITION(1) TOP(4) VALUE(0) VISUALSTYLE(#VS_NORM) VISUALSTYLEOFPARENT(False) WIDTH(161);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#TEXT) CAPTION('The extended form initialization logic is now complete. This example form is now ready to perform work. ') DISPLAYPOSITION(1) HEIGHT(65) LEFT(40) PARENT(#COM_OWNER) TABPOSITION(1) TABSTOP(False) TOP(104) VISIBLE(False) VISUALSTYLE(#VS_TITLE) WIDTH(521);
DEFINE_COM CLASS(#VL_SAM025) NAME(#BITMAP) BORDERICONS(Maximize+Minimize+SystemMenu);
DEFINE_COM CLASS(#VL_SAM029) NAME(#CLOSER) BORDERICONS(Maximize+Minimize+SystemMenu);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#BTN_CLOSE) BUTTONDEFAULT(True) CAPTION('Close this Application ') DISPLAYPOSITION(3) LEFT(184) PARENT(#COM_OWNER) TABPOSITION(2) TOP(240) VISIBLE(False) VISUALSTYLEOFPARENT(False) WIDTH(193);
EVTROUTINE handling(#com_owner.Initialize);
SET #com_owner caption(*component_desc);
* Show the startup bitmap.;
* Change to your bitmap name as required. ;
* Bitmap must be in x_win95\x_lansa\x_ppp\source (where ppp is the partition) at execution time. ;
Invoke #BitMap.uShowImage uFileName(lansa2.bmp) ;
* Emulate Start Up Extended Task 1 ;
Message 'Performing Start Up Extended Task 1' Type(*Status);
Set #ProgBar Value(20);
Execute ExtendedOp;
* Emulate Start Up Extended Task 2 ;
Message 'Performing Start Up Extended Task 2' Type(*Status);
Set #ProgBar Value(40);
Execute ExtendedOp;
* Emulate Start Up Extended Task 3 ;
Message 'Performing Start Up Extended Task 3' Type(*Status);
Set #ProgBar Value(60);
Execute ExtendedOp;
* Emulate Start Up Extended Task 4 ;
Message 'Performing Start Up Extended Task 4' Type(*Status);
Set #ProgBar Value(80);
Execute ExtendedOp;
* Emulate Start Up Extended Task 5 ;
Message 'Performing Start Up Extended Task 5' Type(*Status);
Set #ProgBar Value(100);
Execute ExtendedOp;
* Finished ---- Ready to Work;
Invoke #Bitmap.uFinished;
Message 'Ready' ;
Set #ProgBar Value(0) Visible(False);
Set (#Text #Btn_Close) Visible(True);
ENDROUTINE ;
* ;
* Sub Routine to emulate a Start Up Extended Task by looping to 5,000,000 ;
* ;
Subroutine ExtendedOp;
Begin_loop from(1) to(5000000);
End_Loop ;
EndRoutine ;
*;
* Handle a CloseQuery request;
*;
EvtRoutine Handling(#Com_Owner.CloseQuery) Continue(#Option);
Define #QResult Reffld(#Std_Code);
Invoke #Closer.ConfirmClose;
Change #QResult #Closer.Result ;
Case #QResult;
When '= CNL';
Invoke #Com_Owner.RestoreForm;
Set #Option Value(FALSE);
When '= MIN';
Invoke #Com_Owner.MinimizeForm;
Set #Option Value(FALSE);
OtherWise ;
Set #Option Value(TRUE);
EndCase;
EndRoutine;
*;
* Initiate a close from the button ;
*;
EVTROUTINE HANDLING(#BTN_CLOSE.Click);
Invoke #Com_Owner.CloseFormQuery ;
ENDROUTINE;
END_COM ;