A generic control that can be placed on a form.

Syntax

[<oRef> =] new PaintBox(<container> [,<name expC>])

<oRef>

A variable or property—typically of <container>—in which to store a reference to the newly created PaintBox object.

<container>

The container—typically a Form object—to which you’re binding the PaintBox object.

<name expC>

An optional name for the PaintBox object. If not specified, the PaintBox class will auto-generate a name for the object.

Properties

The following tables list the properties and events of interest in the PaintBox class. (No particular methods are associated with this class.)

Property

Default

Description

allowDrop

false

Whether dragged objects can be dropped in the PaintBox

baseClassName

PAINTBOX

Identifies the object as an instance of the PaintBox class

className

(PAINTBOX)

Identifies the object as an instance of a custom class. When no custom class exists, defaults to baseClassName

colorNormal

BtnText/BtnFace

The color of the paintbox

transparent

false

Whether the paintbox background is the same as the background color or image of its container

 

Event

Parameters

Description

onChar

<char expN>,
<repeat expN>,
<flags expN>

After a non-cursor key or key combination is pressed

onClose

 

After the form containing the PaintBox object has been closed

onDragEnter

<left expN>
<top expN>
<type expC>
<name expC>

When the mouse enters the paintbox display area during a Drag&Drop operation

onDragLeave

 

When the mouse leaves the paintbox display area without having dropped an object

onDragOver

<left expN>
<top expN>
<type expC>
<name expC>

While the mouse drags an object over the paintbox display area during a Drag&Drop operation

onDrop

<left expN>
<top expN>
<type expC>
<name expC>

When the mouse button is released over the paintbox display area during a Drag&Drop operation

onFormSize

 

After the form containing the paintbox is resized

onKeyDown

<char expN>,
<repeat expN>,
<flags expN>

After any key is pressed

onKeyUp

<char expN>,
<repeat expN>,
<flags expN>

After any key is released

onPaint

 

Whenever the paintbox needs to be redrawn

 

The following table lists the common properties, events, and methods of the PaintBox class:

Property

 

Event

 

Method

before
borderStyle

dragEffect

enabled

form

height

hWnd

id

left

mousePointer

name
pageno

parent

printable

speedTip

statusMessage

systemTheme

tabStop

top

visible

width

beforeRelease
onClose

onDesignOpen

onDragBegin

onGotFocus

onLeftDblClick

onLeftMouseDown

onLeftMouseUp

onLostFocus

onMiddleDblClick

onMiddleMouseDown
onMiddleMouseUp

onMouseMove

onMouseOut
onMouseOver
onOpen

onRightDblClick

onRightMouseDown

onRightMouseUp

drag( )
move( )

release( )

setFocus( )

Description

The PaintBox object is a generic control you can use to create a variety of objects. It is designed for advanced developers who want to create their own custom controls using the Windows API. It is simply a rectangular region of a form that has all the standard control properties such as height, width, and before, as well as all the standard mouse events.

In addition to the standard events or properties, the PaintBox object has three events that let you detect keystrokes entered when it has focus: onChar, onKeyDown, and onKeyUp. These let you create customized editing controls. The onPaint and onFormSize events let you modify the appearance of the object based on user interaction.