User-Drawn Controls in DataWindow Objects

The Paint expression functions allow you to draw objects in the DataWindow such as polygons, arrow tips, pie slices, and so on.

The Paint expression function takes one string expression argument and returns the same string. This allows you to paint inside a DataWindow in a way that respects the position and z-order of other DataWindow objects.

Syntax

Paint(expr) where expr can be any valid DataWindow expression. It should contain a function call to a drawing global function with rendering logic. If expr is a string expression and the value is not null, the Computed Field will render the evaluated string expression.

This feature also provides the following supporting functions:
  • GetPaintDC()
  • GetPaintRectX()
  • GetPaintRectY()
  • GetPaintRectWidth()
  • GetPaintRectHeight()

GetPaintDC() returns the GDI context to which to draw. The clip region of the GDI context is guaranteed to be the same as the rectangle defined by the other functions.

GetPaintRectX(), GetPaintRectY(), GetPaintRectWidth(), and GetPaintRectWidth() return the bounds of the computed field. The device context is clipped within these bounds.

Example 1

This example instantiates the drawing functions and, if the drawing function returns false, the text "Bail out" displays.
Paint 
( 
        MyDrawPieSlice 
        ( 
                GetPaintDC(), 
                GetPaintRectX(), 
                GetPaintRectY(), 
                GetPaintRectWidth(), 
                GetPaintRectHeight(), 
                GetRow()*100/RowCount() 
        ) 
) 
Paint
(
        MyDrawPieSlice 
        ( 
                GetPaintDC(), 
                GetRow()*100/RowCount() 
Paint
( 
if (MyDrawPieSlice(getpaintdc()),"","Bail out")
)