Form VL_SAM034: Remembering Form Size and Location

LANSA

Form VL_SAM034: Remembering Form Size and Location
Name: VL_SAM034

Description: The following RDMLX form demonstrates methods for:
  • Remembering grid column width details between form executions.
  • Remembering form size and location details between form executions.
  • Making a list or grid component change size as the parent form changes size.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM BORDERICONS(Maximize+Minimize+SystemMenu) HEIGHT(429) LEFT(302) TOP(154) WIDTH(499);
DEFINE_COM CLASS(#PRIM_GRID) NAME(#GRID_1) DISPLAYPOSITION(1) HEIGHT(322) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TOP(80) WIDTH(491);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#COL1) CAPTION(Number) CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#GRID_1) SOURCE(#EMPNO) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#COL2) CAPTION('Last Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(2) PARENT(#GRID_1) SOURCE(#SURNAME) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#COL3) CAPTION('First Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(3) PARENT(#GRID_1) SOURCE(#GIVENAME) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#COL4) CAPTION(Zip) CAPTIONTYPE(Caption) DISPLAYPOSITION(4) PARENT(#GRID_1) SOURCE(#POSTCODE) WIDTH(20);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#COL5) CAPTION(Salary) CAPTIONTYPE(Caption) DISPLAYPOSITION(5) PARENT(#GRID_1) SOURCE(#SALARY) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#LABL_1) CAPTION('Notes : (1). The column widths are remembered between executions') DISPLAYPOSITION(2) HEIGHT(22) LEFT(2) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(8) WIDTH(345);
DEFINE_COM CLASS(#PRIM_TIMR) NAME(#TIMER) INTERVAL(0);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#LABL_2) CAPTION('(2). The form size and location are remembered between executions ') DISPLAYPOSITION(3) HEIGHT(20) LEFT(43) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(28) WIDTH(347);
DEFINE_COM CLASS(#PRIM_LABL) NAME(#LABL_3) CAPTION('(3). The grid grows and shrinks as the form size is changed') DISPLAYPOSITION(4) HEIGHT(18) LEFT(44) PARENT(#COM_OWNER) TABPOSITION(4) TABSTOP(False) TOP(52) WIDTH(324);
* ;
* Grid and Grid Columns memory;
* ;
define #w_col1 reffld(#std_num) default(20);
define #w_col2 reffld(#std_num) default(20);
define #w_col3 reffld(#std_num) default(20);
define #w_col4 reffld(#std_num) default(20);
define #g_xwidth reffld(#std_num) ;
define #g_xheight reffld(#std_num) ;
* ;
* Form size and location memory;
* ;
define #f_width reffld(#std_num) default(499);
define #f_height reffld(#std_num) default(429);
define #f_top reffld(#std_num) default(140);
define #f_left reffld(#std_num) default(368);
define #t_width reffld(#std_num) ;
define #t_height reffld(#std_num) ;
* ;
* Form Initialization;
* ;
EVTROUTINE handling(#com_owner.Initialize);
SET #com_owner caption(*component_desc);
execute Layout (GetCurrentValues);
execute Layout (GetSavedValues);
execute Layout (SetForm);
execute Layout (SetGrid);
execute Layout (SetColumns);
select (#empno #surname #givename #postcode #salary) pslmst;
add_entry #grid_1;
endselect ;
set #timer interval(500);
ENDROUTINE ;
* ;
* Form Termination;
* ;
EVTROUTINE handling(#com_owner.Closing);
set #timer interval(0);
execute Layout (GetCurrentValues);
ENDROUTINE ;
* ;
* Check for change of form size;
* ;
EVTROUTINE HANDLING(#TIMER.Tick);
if '#com_owner.WindowState = Normal';
if '(#com_owner.height *ne #f_height) *or (#com_owner.width *ne #f_width)';
change #f_height #com_owner.height;
change #f_width #com_owner.width;
execute Layout (SetGrid);
endif ;
endif ;
ENDROUTINE ;
;
subroutine Layout((#std_textl *received));
case #std_textl;
when '= getcurrentvalues';
change #w_col1 #col1.Width;
change #w_col2 #col2.Width;
change #w_col3 #col3.Width;
change #w_col4 #col4.Width;
if '#com_owner.WindowState = Normal' ;
change #f_height #com_owner.height;
change #f_width #com_owner.width;
change #f_top #com_owner.top;
change #f_left #com_owner.left;
endif ;
change #g_xwidth '#grid_1.width - #f_width';
change #g_xheight '#grid_1.height - #f_height';
when '= getsavedvalues';
change (#w_col1 #w_col2 #w_col3 #w_col4 #f_width #f_height #f_top #f_left) *remembered_value_for_user;
when '= setform';
set #com_owner width(#f_width) height(#f_Height) top(#f_top) left(#f_left) ;
when '= setcolumns';
set #col1 width(#w_col1);
set #col2 width(#w_col2);
set #col3 width(#w_col3);
set #col4 width(#w_col4);
set #col5 widthtype(remainder);
when '= setgrid';
change #t_width '#f_width + #g_xwidth';
change #t_height '#f_height + #g_xheight';
set #grid_1 width(#t_width) height(#t_height);
endcase ;
endroutine ;
;
END_COM ;