KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Create dynamic form with View Pro
PRODUCT: 4D View Pro | VERSION: 16 R6 (64-bit) | PLATFORM: Mac & Win
Published On: July 20, 2018

The ability to create dynamic forms is possible in v16R6. What is also possible is to dynamically create a 4D View Pro object on a dynamic form. Here is a simple method to create a dynamic form with a 4D View Pro object:

// -----------------------------------------------------------------
// Name: CREATE_DYNAMIC_FORM_WITH_VP_OBJ
// Description: Method will create a form with a 4D View Pro object
// that needs to specify the top and left coordinate with the width
// and height as well as the 4D View Pro object passed.
//
// Input Parameters:
// $1 (LONGINT) - Left coord in the form for 4D View Pro object
// $2 (LONGINT) - Top coord in the form for 4D View Pro object
// $3 (LONGINT) - Width size in pixels for 4D View Pro object.
// $4 (LONGINT) - Height size in pixels for 4D View Pro object.
// $5 (POINTER) - Pointer 4D View Pro object.
// ------------------------------------------------------------------
C_LONGINT($1;$left;$window)
C_LONGINT($2;$top)
C_LONGINT($3;$width)
C_LONGINT($4;$height)
C_POINTER($5;$vpObj;vpObj)
C_OBJECT($vp;$page;$form)

If (Count parameters=5)
  $left:=$1
  $top:=$2
  $width:=$3
  $height:=$4
  $vpObj:=$5
  vpObj:=$vpObj
  
  $vp:=New object("type";"view";"text";"ViewPro";"top";$top;"left";$left;\
  "width";$width;"height";$height;"sizingX";"grow";"sizingY";"grow";\
  "events";New collection("onVPReady");"method";"CREATE_DYNAMIC_FORM_WITH_VP_OBJ")
  
  $page:=New object("objects";New object("view";$vp))
  $form:=New object("pages";New collection(Null;$page);"rightMargin";0;\
  "bottomMargin";0)
  
  $window:=Open form window($form)
  DIALOG($form)
  CLOSE WINDOW($window)
  
Else
  
  If (Form event=On VP Ready)
   VP IMPORT FROM OBJECT ("view";vpObj->)
  End if
  
End if


Here is a sample of running the method:

QUERY([TABLE_1];[TABLE_1]ID=1)
CREATE_DYNAMIC_FORM_WITH_VP_OBJ(0;0;650;500;->[TABLE_1]Field_obj) // View Pro Object