Tech Tip: How to return View Pro offscreen area object
PRODUCT: 4D View Pro | VERSION: 19 | PLATFORM: Mac & Win
Published On: June 20, 2022
When working with a View Pro offscreen area, the first step is create the object attributes of the offscreen area. There are 4 main attributes:
The object containing these attributes is then passed as an argument to the method VP Run offscreen area as shown below:
C_OBJECT($param_o) C_VARIANT($offscreenResult_v) $param_o:=New object $param_o.area:="TestArea" // Name of VP object $param_o.autoQuit:=False // Boolean for autoclosing the offscreen area $param_o.timeout:=30 // Number of seconds before offscreen area autocloses $param_o.onEvent:=Formula(onEvent) // Callback method $offscreenResult_v:=VP Run offscreen area($param_o) // Result from callback method |
For the onEvent callback method, it will simply create a new VP document, add some text to cell 0 0, then return the offscreen area as an object as shown below:
// Method: onEvent Case of : (Form event code =On VP Ready) C_OBJECT($range_o) // Create new document VP NEW DOCUMENT(This.area) // Modifying new document by editting cell 0 0 $range_o:=VP Cell(This.area; 0; 0) VP SET TEXT VALUE($range_o; "This is cell 0 0") // Export object to result This.result:=VP Export to object(This.area) ACCEPT End case |
The VP object is now returned in the local variable $offscreenResult_v which can now be used to display on a form's View Pro area if needed using VP IMPORT FROM OBJECT.
// Import offscreen result object to form's "ViewProArea" VP IMPORT FROM OBJECT("ViewProArea"; $offscreenResult_v) |