Tech Tip: Create a dynamic form with 4D Write Pro object
PRODUCT: 4D | VERSION: 16 R6 | PLATFORM: Mac & Win
Published On: June 1, 2018
The ability to create dynamic forms is possible in v16R6. What is also possible is to dynamically create a 4D Write Pro object on a dynamic form. Here is a simple method to create a dynamic form with a 4D Write Pro object:
// ----------------------------------------------------------------- // Name: CREATE_DYNAMIC_FORM_WITH_WP_OBJ // Description: Method will create a form with a 4D Write Pro object // that needs to specify the top and left coordinate with the width // and height as well as the 4D Write Pro object passed. // // Input Parameters: // $1 (LONGINT) - Left coord in the form for 4D Write Pro object // $2 (LONGINT) - Top coord in the form for 4D Write Pro object // $3 (LONGINT) - Width size in pixels for 4D Write Pro object. // $4 (LONGINT) - Height size in pixels for 4D Write Pro object. // $5 (POINTER) - Pointer 4D Write Pro object. // ------------------------------------------------------------------ C_LONGINT($1;$left;$window) C_LONGINT($2;$top) C_LONGINT($3;$width) C_LONGINT($4;$height) C_POINTER($5;$wpObj) C_OBJECT($wp;$page;$form) If (Count parameters=5) $left:=$1 $top:=$2 $width:=$3 $height:=$4 $wpObj:=$5 $wp:=New object("type";"write";"text";"WritePro";"top";$top;"left";$left;\ "width";$width;"height";$height;"sizingX";"grow";"sizingY";"grow";\ "dataSource";"$wpObj->") $page:=New object("objects";New object("write";$wp)) $form:=New object("pages";New collection(Null;$page);"rightMargin";0;\ "bottomMargin";0) $window:=Open form window($form) DIALOG($form) CLOSE WINDOW($window) End if |
Here is a sample of running the method:
QUERY([TABLE_1];[TABLE_1]ID=1) CREATE_DYNAMIC_FORM_WITH_WP_OBJ(0;0;650;500;->[TABLE_1]Field_obj) // Write Pro Object |
![](https://kb.4d.com:443/kbase/assets/images/78039-1.jpg)