cdev
cdev Function entry for Control Panel Devices
Control Panel
long main( message, Item, numItems, CPanelID, theEvent, cdevValue,
CPDialog );
short message ; number indicating type of event (see below)
short Item ; which dialog item was clicked?
short numItems ; number of Control Panel's dialog items
short CPanelID ; control Panel driver's ID
EventRecord *theEvent ; was the Event a: hit, null, activate, deactivate, or
key?
long cdevValue ; most recent long returned by this call
DialogPtr CPDialog ; pointer to Control Panel dialog
returns One of three function values indicating: display or
not; error; data to be retained until next call
This is the main entry point for a code resource that implements a
Control Panel device.
message is chosen from a list of predefined values that lets the Control Panel
tell the cdev what action it should take. For more information, see
About the Control Panel.
Item is only used when the Control Panel delivers a hitDev message and
gives the Item Number of the dialog item that was clicked.
numItems tells how many Control Panel items are in 'DITL' and precede the
control device's dialog items.
CPanelID is the Control Panel driver's base resource ID.
theEvent is a pointer to the event record for the action that caused the
message.
cdevValue can be either the 32-bit long last returned by main or a return
message from the Control Panel, such as an error message.
CPDialog is a pointer to the Control Panel Dialog that the cdev is running
in.
Returns: a 32-bit long which indicates either: 1) whether or not the cdev can
run on this Macintosh or not; or 2) an error code; or 3) data (such
as state information) to be stored until the next call by the
Control Panel and passed back to the cdev in the cdevValue
parameter

Notes: This function is called with the active resource file set to the cdev file, the
active grafPort set to the Control Panel's dialog and the default volume set
to the System Folder on the startup disk. In order for a cdev to work
properly, it must leave these settings as they are.
If your control panel device uses dialogs or alert boxes the cdev function
may be called reentrantly. Both Alert and ModalDialog call SystemEvent
and SystemTask, possibly resulting in a nulDev or updateDev message
while your cdev is still running.