Your forms may need to be changed depending on your customer or user needs. For example, the color black might be perfect for one user but not so much for another user (who sees blue as the ultimate perfection). Luckily, dynamic forms (introduced with 4D v16 R6) are here to help you handle your users’ preferences. But rewriting an existing form to a dynamic form could be a difficult task, and it’s not always easy to start with a blank page. Ideally, it’d be best to have a draft that can be modified and improved. With 4D v17 R3, it’s now possible to easily convert a classic 4D form (stored in .4DB file) to a dynamic form.
For this, a new command is available. Pass the form name and you’ll receive an object describing the form.
$oForm:=FORM Convert to dynamic("myProjectForm")
Then you can make changes to the form quickly and easily. For example, you can change the font color for all objects with the “Cancel” label in your form by code:
// iterate on all objects of first page
$pageObjects:=$oForm.pages[1].objects
For each ($object;$pageObjects)
If (String($pageObjects[$object].text)="@Cancel@") // all widgets with a "Cancel" caption text
$pageObjects[$object].stroke:="red" // change it to red color
End if
End for each
DIALOG($oForm)
Other example, you can save the dynamic form in a file on the user’s computer and do a implement personalized modifications for this specific user only.
The font color was just a simple example. But that’s not all … font, font size, enterable, format, position, resize, resizing option, assigned object method or form events, and much more. You can completely redesign a form on the fly. The possibilities are endless!