Important: The information in this document is obsolete and should not be used for new development.
MyMntrExt
You provide a monitors extension function to implement the features that allow users to set the controls for your video card. Your function should respond appropriately to any messages sent to it by the Monitors control panel. In themessage
parameter, the Monitors control panel passes a value indicating which action your function should perform. Here's how you declare a monitors extension function calledMyMntrExt
:
FUNCTION MyMntrExt (message, item, numItems: Integer; monitorValue: LongInt; mDialog: DialogPtr; theEvent: EventRecord; screenNum: Integer; VAR screens: ScrnRsrcHandle; VAR scrnChanged: Boolean): LongInt;
message
- A value that identifies the event or action to which your monitors extension function should respond. See Table 8-4 on page 8-81 for the values your function can receive in this parameter.
item
- For
hitDev
messages, the number of the item that the user clicked. The Monitors control panel appends your item list to its own. So, although you begin numbering your item list with 1 in your item list resource, the Monitors control panel adds the number of standard items in the Options dialog box's item list to your item. Therefore, to get the actual number of the clicked item, your monitors extension function should always subtractnumItems
fromitem
.- For the
startupMsg
message, theitem
parameter indicates whether the user has selected superuser status. If so, theitem
parameter is 1; if not, it is 0.numItems
- The item list number of the last standard item in the Options dialog box.
monitorValue
The first time the Monitors control panel calls your monitors extension function, that is, when themessage
parameter equalsstartupMsg
, the value of themonitorValue
parameter is 0. After the first call, this parameter contains the result your monitors extension function returned the last time the Monitors control panel called it. Because control panel routines, including a monitors extension function, cannot use global variables to store data between calls, your function can use its function result to return a handle to any memory it allocates. The next time the Monitors control panel calls your monitors extension function, it passes the handle back to your function in themonitorValue
parameter.- If your monitors extension function returns a function result in the range 1 through 255, the Monitors control panel interprets this result as an error and closes your Options dialog box. Therefore, your monitors extension function will not receive a value in this range in the
monitorValue
parameter.mDialog
- The dialog pointer for the Options dialog box. See the chapter "Dialog Manager" in Inside Macintosh: Macintosh Toolbox Essentials for a description of dialog pointers.
theEvent
- The event record for an event that caused the Monitors control panel to pass a
hitMsg
,nulMsg
, orkeyEvtMsg
message to your monitors extension function. See the chapter "Event Manager" in Inside Macintosh: Macintosh Toolbox Essentials for a description of events and event records.screenNum
- The number of the screen device (that is, the monitor) that the user selected. The Monitors control panel numbers monitors consecutively, in the same order as the slots in which the cards are installed, starting with 1.
screens
- A handle to a screen (
'scrn'
) resource. See Inside Macintosh: Devices for information on the screen resource.scrnChanged
- A Boolean value that you can use to indicate whether you have modified the screen (
'scrn'
) resource. Set this parameter toTRUE
if you have modified the screen resource. When you set thescrnChanged
parameter toTRUE
, the Monitors control panel checks whether the values in the screen resource are still valid; if there is a problem, the Monitors control panel tries to correct it.- This parameter makes it easier to implement a control that changes the apparent area displayed on the screen. For example, your monitor might be able to display either two pages of a document or a magnified view of a single page. If the user changes the area displayed on one screen in a system with multiple screens, the displays on adjacent screens could overlap or show gaps. When you change the screen resource to implement this change, the coordinates of the global rectangles for adjacent screens are no longer contiguous. In this case, if you have set the
scrnChanged
parameter toTRUE
, the Monitors control panel shifts the virtual locations of the screens to eliminate the gaps or overlaps.DESCRIPTION
The Monitors control panel calls your monitors extension function repeatedly with messages requesting your function to perform an action or handle an event that occurs while the Options dialog box is displayed. Table 8-4 lists the constant names for the values that the Monitors control panel passes in themessage
parameter and provides a description of the action your function should perform.Your monitors extension function can return either an error code or a value that you want to have available the next time the Monitors control panel calls your function. For example, if your monitors extension function allocates memory, it can return a handle to the memory as its function result. Each time the Monitors control panel calls your monitors extension function, the
monitorValue
parameter contains the value that your function returned the last time it was called.Your monitors extension function must also detect and recover from any error conditions or report them to the user. If it cannot recover from an error, your monitors extension function should display an error dialog box and then return a value between 1 and 255. If your function returns a value in this range, the Monitors control panel closes the Options dialog box immediately and does not call your function again. If your function returns an error in response to the
initMsg
orstartupMsg
message, the Monitors control panel does not display the Options dialog box. Your function can display an alert box describing the error before returning control to the Monitors control panel.SEE ALSO
For more information about the messages the Monitors control panel sends to your monitors extension function and how to handle them, see "Writing a Monitors Extension Function" beginning on page 8-61.