Control - Realize Method

Creates the visual portion of dynamically created controls

Member of Control (PRIM_CTRL)

Details

The Realize method creates the UI portion of a control instance.  This only applies to desktop applications.
 
Visual components have 3 possible states
  1. Null
  2. Unrealized
  3. Realized
Null components are dead objects effectively. There is no instance as they are yet to be created.
 
Unrealized components have been created and are alive, but are not visible on the screen as no UI features of the control have been created
 
Realized components are fully alive.
 
Statically defined components are realized automatically by the LANSA runtime. However, components that are created dynamically need to be realized unless they are parented to a control that is being realized.
 
Realizing a component is comparatively slow, so it is best to realize components en masse.

Example

In this example, buttons and associated layout items are created dynamically.
 
The buttons are realized on creation if the Realized checkbox is checked.
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Caption('Dynamic Creation') Height(397) Left(227) Top(218) Width(512) Clientwidth(496) Clientheight(358) Layoutmanager(#TableLayout)
 
   Define_Com Class(#PRIM_TBLO) Name(#TableLayout)
   Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout) Width(112) Units(Pixels)
   Define_Com Class(#PRIM_TBLO.Column) Name(#Column2) Displayposition(2) Parent(#TableLayout) Width(1.64)
   Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout)
   Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Alignment(TopCenter) Column(#Column1) Flow(Down) Manage(#Create) Parent(#TableLayout) Row(#Row1) Sizing(None) Margintop(4)
   Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem2) Alignment(TopCenter) Column(#Column1) Flow(Down) Manage(#Realize) Parent(#TableLayout) Row(#Row1) Sizing(None) Margintop(4)
   Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem3) Alignment(TopCenter) Column(#Column1) Flow(Down) Manage(#RealizeAll) Parent(#TableLayout) Row(#Row1) Sizing(None)
 
   Define_Com Class(#PRIM_PHBN) Name(#Create) Caption('Create a button') Displayposition(1) Left(9) Parent(#COM_OWNER) Tabposition(1) Top(4) Width(95)
   Define_Com Class(#PRIM_CKBX) Name(#Realize) Caption('Realized') Displayposition(2) Left(9) Marginleft(2) Parent(#COM_OWNER) Tabposition(2) Top(33) Height(28) Width(95) Buttonstate(Checked)
   Define_Com Class(#PRIM_PHBN) Name(#RealizeAll) Caption('Realize All') Displayposition(3) Left(9) Parent(#COM_OWNER) Tabposition(3) Top(61) Width(95)
 
   Define_Com Class(#Prim_acol<#Prim_phbn>) Name(#Buttons)
   Define_Com Class(#Prim_acol<#Prim_TBLO.Item>) Name(#LayoutItems)
 
   Evtroutine Handling(#Create.Click)
 
      * Create a button instance
      #Buttons.Insert( (*New #prim_phbn) )
      #Buttons.Last.Caption := ("Button &1").Substitute( #Buttons.ItemCount.Asstring )
      #Buttons.Last.Parent <= #Com_owner
 
      * Create a layout item to manage the button position
      #LayoutItems.Insert( (*New #prim_tblo.Item) )
      #LayoutItems.Last.Column <= #Column2
      #LayoutItems.Last.Row <= #Row1
      #LayoutItems.Last.Alignment := TopLeft
      #LayoutItems.Last.Flow := Down
      #LayoutItems.Last.Sizing := None
      #LayoutItems.Last.MarginTop #LayoutItems.Last.MarginLeft := 4
      #LayoutItems.Last.Parent <= #TableLayout
      #LayoutItems.Last.Manage <= #Buttons.Last
 
      If (#Realize.ButtonState = Checked)
         #Buttons.Last.Realize
      Endif
 
   Endroutine
 
   Evtroutine Handling(#RealizeAll.Click)
 
      #Com_owner.Realize
 
   Endroutine
 
End_Com

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2