| Framework | Carbon/Carbon.h |
| Declared in | Dialogs.h |
Your application can use the Dialog Manager to alert users to unusual situations and to solicit information from users. For example, in some situations your application might not be able to carry out a command normally, and in other situations the user must specify multiple parameters before your application can execute a command. For circumstances like these, the Macintosh user interface includes these two features:
alerts–including alert sounds and alert boxes–which warn the user whenever an unusual or potentially undesirable situation occurs within your application
dialog boxes, which allow the user to provide additional information or to modify settings before your application carries out a command
Virtually all applications need to implement alerts and dialog boxes. To avoid needless development effort, use the Dialog Manager to implement alerts and to create most dialog boxes. It is possible, however–and sometimes desirable–to bypass the Dialog Manager and instead use Window Manager, Control Manager, QuickDraw, and Event Manager routines to create or respond to events in complex dialog boxes.
Carbon supports the majority of the Dialog Manager. However, your application must access Dialog Manager data structures only through the supplied accessor functions. Furthermore, your application must use the functions provided for creating and disposing of Dialog Manager data structures.
ParamText
SetDialogItemText
GetDialogItemText
SelectDialogItemText
DialogCut
DialogCopy
DialogPaste
DialogDelete
SetDialogCancelItem
GetDialogCancelItem
SetDialogDefaultItem
GetDialogDefaultItem
GetDialogItemAsControl
GetDialogItem
SetDialogItem
GetDialogKeyboardFocusItem
SetDialogTracksCursor
FindDialogItem
MoveDialogItem
SizeDialogItem
AutoSizeDialog
AppendDialogItemList
AppendDITL
ShortenDITL
CountDITL
CloseStandardSheet
CreateStandardAlert
CreateStandardSheet
DisposeModalFilterUPP
DisposeModalFilterYDUPP
DisposeUserItemUPP
GetDialogFromWindow
GetDialogPort
GetDialogTextEditHandle
GetDialogWindow
GetParamText
GetStandardAlertDefaultParams
InsertDialogItem
InvokeModalFilterUPP
InvokeModalFilterYDUPP
InvokeUserItemUPP
NewModalFilterUPP
NewModalFilterYDUPP
NewUserItemUPP
RemoveDialogItems
RunStandardAlert
SetPortDialogPort
Displays an alert box and/or plays an alert sound.
DialogItemIndex Alert ( SInt16 alertID, ModalFilterUPP modalFilter );
The resource ID of an alert resource and extended alert resource. If the alert resource is missing, the Dialog Manager returns to your application without creating the requested alert. See ‘alrx’ for a description of the extended alert resource.
A universal procedure pointer for a filter function that responds to events not handled by the ModalDialog function. If you set this parameter to null, the Dialog Manager uses the standard event filter function.
If no alert box is to be drawn at the current alert stage or the 'ALRT' resource is not found, Alert returns –1 otherwise, it creates and displays the alert box and returns the item number of the control selected by the user see “Alert Button Constants.” See the description of the DialogItemIndex data type.
The Alert function displays an alert box or, if appropriate for the alert stage, plays an alert sound instead of or in addition to displaying the alert box. The Alert function creates the alert defined in the specified alert resource and its corresponding extended alert resource. The function calls the current alert sound function and passes it the sound number specified in the alert resource for the current alert stage. If no alert box is to be drawn at this stage, Alert returns –1 otherwise, it uses the NewDialog function to create and display the alert box. The default system window colors are used unless your application provides an alert color table resource with the same resource ID as the alert resource. The Alert function uses the ModalDialog function to get and handle most events for you.
The Alert function does not display a default icon in the upper-left corner of the alert box you can leave this area blank, or you can specify your own icon in the alert’s item list resource, which in turn is specified in the alert resource.
The Alert function continues calling ModalDialog until the user selects an enabled control (typically a button), at which time the Alert function removes the alert box from the screen and returns the item number of the selected control. Your application then responds as appropriate when the user clicks this item.
Your application should never draw its own default rings. Prior to Mac OS 8, the Alert function would only redraw the default button ring once and never redraw it on an update event. However, when Appearance is available, default rings do redraw when you call Alert.
See also the functions NoteAlert , CautionAlert , and StopAlert.
If you need to display an alert box while your application is running in the background or is otherwise invisible to the user, call AEInteractWithUser
The Dialog Manager uses the system alert sound as the error sound unless you change it by calling the ErrorSound function .
This function was changed with Appearance Manager 1.0 to support the extended alert ('alrx') resource.
Dialogs.h
Adds items to an existing dialog box while your program is running.
OSErr AppendDialogItemList ( DialogRef dialog, SInt16 ditlID, DITLMethod method );
A pointer to the dialog box to which the items in the item list resource specified in the ditlID parameter are to be appended.
The resource ID of the item list resource whose items are to be appended to the dialog box specified in the dialog parameter.
The manner in which the new items are to be displayed in the dialog box.
If you use the overlayDITL constant, AppendDialogItemList superimposes the appended items over the dialog box by interpreting the coordinates of the display rectangles for the appended items (as specified in their item list resource) as local coordinates within the dialog box.
If you use the appendDITLRight constant, AppendDialogItemList appends the items to the right of the dialog box by positioning the display rectangles of the appended items relative to the upper-right coordinate of the dialog box. The AppendDialogItemList function automatically expands the dialog box to accommodate the new dialog items.
If you use the appendDITLBottom constant, AppendDialogItemList appends the items to the bottom of the dialog box by positioning the display rectangles of the appended items relative to the lower-left coordinate of the dialog box. The AppendDialogItemList function automatically expands the dialog box to accommodate the new dialog items.
You can append a list of items relative to an existing item by passing a negative number. The absolute value of this number is interpreted as the item in the dialog box relative to which the new items are to be positioned. For example, if you pass -2, the display rectangles of the appended items are offset relative to the upper-left corner of item number 2 in the dialog box.
A result code. See “Dialog Manager Result Codes.”
To be Appearance-compliant, your program should use the AppendDialogItemList function rather than the AppendDITL function. Unlike AppendDITL, the AppendDialogItemList function takes a 'DITL' resource ID instead of a handle as the parameter describing the dialog item list to be appended, and it properly appends entries from a dialog font table ( 'dftb') resource, if there is a 'dftb' resource with the same resource ID as the 'DITL' resource.
The AppendDialogItemList function adds the items in the item list resource specified in the parameter ditlID to the items of a dialog box. This is especially useful if several dialog boxes share a single item list resource, because you can use AppendDialogItemList to add items that are appropriate for individual dialog boxes. Your application can use the Resource Manager function GetResource to get a handle to the item list resource whose items you wish to add.
You typically create an invisible dialog box, call the AppendDialogItemList function, then make the dialog box visible by using the Window Manager function ShowWindow.
This function is available with Appearance Manager 1.0 and later.
Dialogs.h
Adds items to an existing dialog box while your application is running.
void AppendDITL ( DialogRef theDialog, Handle theHandle, DITLMethod method );
A pointer to a dialog structure. This is the dialog structure to which you will add the item list resource specified in the parameter theHandle.
A handle to the item list resource whose items you want to append to the dialog box. To avoid item number conflicts, AppendDITL assigns new numbers to the items you are adding. For example, if you have a dialog with item numbers 1-5, and you use AppendDITL to add a 'DITL' resource containing item numbers 1-3, those become item numbers 6-8 in the dialog.
The manner in which you want the new items to be displayed in the existing dialog box. You can pass a negative value to offset the appended items from a particular item in the existing dialog box. You can also pass one of the values defined by the DITLMethod constant. See “Dialog Item List Display Constants” for possible values.
The AppendDITL function adds the items specified in the theHandle parameter to the items of a dialog box (handle-based). This function is especially useful if several dialog boxes share a single item list resource, because you can use AppendDITL to add items that are appropriate for individual dialog boxes. Your application can use the Resource Manager function GetResource to get a handle to the item list resource whose items you wish to add.
In the parameter method, you specify how to append the new items, as follows:
If you use the overlayDITL constant, AppendDITL superimposes the appended items over the dialog box. That is, AppendDITL interprets the coordinates of the display rectangles for the appended items (as specified in their item list resource) as local coordinates within the dialog box.
If you use the appendDITLRight constant, AppendDITL appends the items to the right of the dialog box by positioning the display rectangles of the appended items relative to the upper-right coordinate of the dialog box. The AppendDITL function automatically expands the dialog box to accommodate the new dialog items.
If you use the appendDITLBottom constant, AppendDITL appends the items to the bottom of the dialog box by positioning the display rectangles of the appended items relative to the lower-left coordinate of the dialog box. The AppendDITL function automatically expands the dialog box to accommodate the new dialog items.
You can also append a list of items relative to an existing item by passing a negative number in the parameter method. The absolute value of this number is interpreted as the item in the dialog box relative to which the new items are to be positioned. For example, if you pass –2, the display rectangles of the appended items are offset relative to the upper-left corner of item number 2 in the dialog box.
You typically create an invisible dialog box, call the AppendDITL function, then make the dialog box visible by using the Window Manager function ShowWindow.
The AppendDITL function modifies the contents of the dialog box (for instance, by enlarging it). To use an unmodified version of the dialog box at a later time, your application should use the Resource Manager function ReleaseResource to release the memory occupied by the appended item list resource. Otherwise, if your application calls AppendDITL to add items to that dialog box again, the dialog box remains modified by your previous call—for example, it will still be longer at the bottom if you previously used the appendDITLBottom constant.
Before calling AppendDITL, you should make sure that it is available by using the Gestalt function with the gestaltDITLExtAttr selector. Test the bit indicated by the gestaltDITLExtPresent constant in the response parameter. If the bit is set, then AppendDITL is available.
Dialogs.h
Automatically resizes static text fields and their dialog boxes to accommodate changed static text.
OSErr AutoSizeDialog ( DialogRef inDialog );
A pointer to a dialog box.
A result code. See “Dialog Manager Result Codes.”
The AutoSizeDialog function is useful in situations such as localization, where the size of a static text field (and the dialog box that contains it) may need to be altered to accommodate a change in the size of the static text.
For each static text item AutoSizeDialog finds in the item list resource, it adjusts the static text field and the bottom of the dialog box window to accommodate the text. Any items below a static text field are moved down. If the dialog box is visible when this function is called, it is hidden, resized, and then shown. If the dialog box has enough room to show the text as is, no resizing is done.
Note that the AutoSizeDialog function does not process update events for your dialog box, so your program must call the DrawDialog function or the DialogSelect function to process the update event generated from showing the window.
This function is available with Appearance Manager 1.0 and later.
Dialogs.h
Displays an alert box with a caution icon and/or plays an alert sound.
DialogItemIndex CautionAlert ( SInt16 alertID, ModalFilterUPP modalFilter );
The resource ID of an alert resource and extended alert resource. If the alert resource is missing, the Dialog Manager returns to your application without creating the requested alert. See ‘alrx’ for a description of the extended alert resource.
A universal procedure pointer for a filter function that responds to events not handled by the ModalDialog function. If you set this parameter to null, the Dialog Manager uses the standard event filter function.
If no alert box is to be drawn at the current alert stage, CautionAlert returns –1 otherwise, it uses NewDialog to create and display the alert box and returns the item hit; see “Alert Button Constants.” See the description of the DialogItemIndex data type.
Displays an alert box with a caution icon in its upper-left corner or, if appropriate for the alert stage, to play an alert sound instead of or in addition to displaying the alert box.
The CautionAlert function is the same as the Alert function except that, before drawing the items in the alert box, CautionAlert draws the caution icon in the upper-left corner. The caution icon has resource ID 2, which you can also specify with the constant kCautionIcon. By default, the Dialog Manager uses the standard caution icon from the System file. You can change this icon by providing your own 'ICON' resource with resource ID 2.
Use a caution alert to alert the user of an operation that may have undesirable results if it’s allowed to continue. Give the user the choice of continuing the action (by clicking an OK button) or stopping it (by clicking a Cancel button).
Your application should never draw its own default rings or alert icons. Prior to Mac OS 8, the CautionAlert function would only redraw the alert icon and default button ring once and never redraw them on an update event. However, when Appearance is available, alert icons and default rings do redraw when you call CautionAlert.
See also the functions NoteAlert and StopAlert.
This function was changed with Appearance Manager 1.0 to support the extended alert ('alrx') resource.
Dialogs.h
Dismisses a dialog box without disposing of the dialog structure.
void CloseDialog ( DialogRef theDialog );
A pointer to a dialog structure.
The CloseDialog function removes a dialog box from the screen and deletes it from the window list. The CloseDialog function releases the memory occupied by
the data structures associated with the dialog box (such as its structure, content, and update regions)
all the items in the dialog box (except for pictures and icons, which might be shared by other resources) and any data structures associated with them
Generally, you should provide memory for the dialog structure of modeless dialog boxes when you create them. (You can let the Dialog Manager provide memory for modal and movable modal dialog boxes.) You should then use CloseDialog to close a modeless dialog box when the user clicks the close box or chooses Close from the File menu.
Because CloseDialog does not dispose of the dialog resource or the item list resource, it is important to make these resources purgeable. Unlike GetNewDialog , NewColorDialog does not use a copy of the item list resource. Thus, if you use NewColorDialog to create a dialog box, you may want to use CloseDialog to keep the item list resource in memory even if you didn’t supply a pointer to the memory.
The CloseDialog function is not supported because developers do not allocate their own memory for dialog boxes in Carbon. Use the DisposeDialog function to dismiss a dialog box instead.
Dialogs.h
OSStatus CloseStandardSheet ( DialogRef inSheet, UInt32 inResultCommand );
A result code. See “Dialog Manager Result Codes.”
Dialogs.h
Determines the number of items in a dialog box.
DialogItemIndex CountDITL ( DialogRef theDialog );
A pointer to a dialog structure.
The number of current items in a dialog box. See the description of the DialogItemIndex data type.
You typically use CountDITL in conjunction with ShortenDITL to remove items from a dialog box.
Before calling CountDITL, you should make sure that it is available by using the Gestalt function with the gestaltDITLExtAttr selector. Test the bit indicated by the gestaltDITLExtPresent constant in the response parameter. If the bit is set, then CountDITL is available.
Dialogs.h
Creates an alert containing standard elements and using standard formatting rules.
OSStatus CreateStandardAlert ( AlertType alertType, CFStringRef error, CFStringRef explanation, const AlertStdCFStringAlertParamRec *param, DialogRef *outAlert );
The type of alert to create. For a list of possible values, see “Alert Type Constants.”
The error string to display.
The explanation string to display. May be NULL or empty to display no explanation.
The parameter block describing how to create the alert. May be NULL.
A pointer to a variable that, on return, refers to the new alert.
A result code. See “Dialog Manager Result Codes.”
This function should be used in conjunction with RunStandardAlert. After CreateStandardAlert returns, the alert is still invisible. RunStandardAlert shows the alert and runs a modal dialog loop to process events in the alert.
Dialogs.h
Creates an alert containing standard elements and using standard formatting rules, and prepares it to be displayed as a sheet.
OSStatus CreateStandardSheet ( AlertType alertType, CFStringRef error, CFStringRef explanation, const AlertStdCFStringAlertParamRec *param, EventTargetRef notifyTarget, DialogRef *outSheet );
The type of alert to create. For a list of possible values, see “Alert Type Constants.”
The error string to display.
The explanation string to display. May be NULL or empty to display no explanation.
The parameter block describing how to create the alert. May be NULL.
The event target to be notified when the user dismisses the sheet. The caller should install an event handler on this target for the kEventProcessCommand event. May be NULL if the caller does not need the command event to be sent to any target. For more information, see the Discussion below.
A pointer to a variable that, on return, refers to the new alert.
A result code. See “Dialog Manager Result Codes.”
This function should be used in conjunction with ShowSheetWindow. After CreateStandardSheet returns, the alert is still invisible. ShowSheetWindow will show the alert as a sheet and then return. Events in the sheet are handled asynchronously; the application should be prepared for the sheet window to be part of its window list while running its own event loop.
When a button in the sheet is pressed, the event target passed to CreateStandardSheet will receive a command event with one of the following commands: kHICommandOK, kHICommandCancel, or kHICommandOther. The system takes care of closing the sheet and releasing the alert. Therefore after using ShowSheetWindow, you do not need to call HideSheetWindow or DisposeDialog.
Typically, the event target you pass in the notifyTarget parameter is the parent window of the sheet. A standard practice is to install a command event handler on the parent window just before showing the sheet window, and to remove the handler from the parent window after the sheet has been closed.
It is also possible to install a handler on the sheet window itself, in which case you would pass NULL in the notifyTarget parameter, since the command event is automatically sent to the sheet window already. If you install a handler on the sheet itself, make sure to return eventNotHandledErr from your handler, because CreateStandardSheet installs its own handler on the sheet and that handler must be allowed to run to close the sheet window and release the alert.
Dialogs.h
Handles the Copy editing command when a dialog box containing an edit text item is active.
void DialogCopy ( DialogRef theDialog );
A pointer to a dialog structure.
The DialogCopy function checks whether the dialog box has any edit text items and, if so, applies the TextEdit function TECopy to the selected text. Your application should test whether a dialog box is the frontmost window when handling mouse-down events in the Edit menu and then call this function when appropriate.
Dialogs.h
Handles the Cut editing command when a dialog box containing an edit text item is active.
void DialogCut ( DialogRef theDialog );
On input, a pointer to a dialog structure.
The DialogCut function checks whether the dialog box has any edit text items and, if so, applies the TextEdit function TECut to the selected text. Your application should test whether a dialog box is the frontmost window when handling mouse-down events in the Edit menu and then call this function when appropriate.
Dialogs.h
Handles the Delete editing command when a dialog box containing an edit text item is active.
void DialogDelete ( DialogRef theDialog );
A pointer to a dialog structure.
The DialogDelete function checks whether the dialog box has any edit text items and, if so, applies the TextEdit function TEDelete to the selected text. Your application should test whether a dialog box is the frontmost window when handling mouse-down events in the Edit menu and then call this function when appropriate.
Dialogs.h
Handles the Paste editing command when a dialog box containing an edit text item is active.
void DialogPaste ( DialogRef theDialog );
On input, a pointer to a dialog structure.
The DialogPaste function checks whether the dialog box has any edit text items and, if so, applies the TextEdit function TEPaste to the selected edit text item. Your application should test whether a dialog box is the frontmost window when handling mouse-down events in the Edit menu and then call this function when appropriate.
Dialogs.h
Handles most of the events inside the dialog box after you have determined that an event related to an active modeless dialog box or an active movable modal dialog box has occurred.
Boolean DialogSelect ( const EventRecord *theEvent, DialogRef *theDialog, DialogItemIndex *itemHit );
A pointer to an event structure returned by an Event Manager function such as WaitNextEvent.
A pointer to a dialog structure for the dialog box where the event occurred.
A pointer to a short integer. DialogSelect returns a number corresponding to the position of an item within the item list resource of the active dialog box.
A Boolean value. If the event is an activate or update event for a dialog box, DialogSelect activates or updates it and returns false. If the event involves an enabled item, DialogSelect returns a function result of true.
The DialogSelect function handles most of the events relating to a dialog box. Through its itemHit parameter, it returns the item number of the item selected by the user. Through the parameter theDialog, it returns a pointer to the dialog structure for the dialog box where the event occurred. In all other cases, the DialogSelect function returns false. When DialogSelect returns true, do whatever is appropriate as a response to the event involving that item in that particular dialog box; when it returns false, do nothing.
Generally, only controls should be enabled in a dialog box; therefore your application should normally respond only when DialogSelect returns true after the user clicks an enabled control, such as the OK button.
The DialogSelect function first obtains a pointer to the window containing the event. For update and activate events, the event structure contains the window pointer. For other types of events, DialogSelect calls the Window Manager function FrontWindow. The Dialog Manager then makes this window the current graphics port by calling the QuickDraw function SetPort. Then DialogSelect prepares to handle the event by setting up text information if there are any edit text items in the active dialog box.
When an item is a control defined in a control resource, the rectangle added to the update region is the rectangle defined in the control resource, not the display rectangle defined in the item list resource.
The DialogSelect function handles the event as follows:
In response to an activate or update event for the dialog box, DialogSelect activates or updates its window and returns false.
If a key-down event or an auto-key event occurs and there’s an edit text item in the dialog box, DialogSelect uses TextEdit to handle text entry and editing, and DialogSelect returns true for a function result. Through its itemHit parameter, DialogSelect returns the item number.
If a key-down event or an auto-key event occurs and there’s no edit text item in the dialog box, DialogSelect returns false.
If the user presses the mouse button while the cursor is in an edit text item, DialogSelect responds to the mouse activity as appropriate—that is, either by displaying an insertion point or by selecting text. If the edit text item is disabled, DialogSelect returns false. If the edit text item is enabled, DialogSelect returns true and through its itemHit parameter returns the item number. Normally, edit text items are disabled, and you use the GetDialogItemText function to read the information in the items only after the OK button is clicked.
If the user presses the mouse button while the cursor is in a control, DialogSelect tracks the control. If the user releases the mouse button while the cursor is in an enabled control, DialogSelect returns true for a function result and through its itemHit parameter returns the control’s item number. Your application should respond appropriately—for example, by performing a command after the user clicks the OK button.
If the user presses the mouse button while the cursor is in any other enabled item in the dialog box, DialogSelect returns true for a function result and through its itemHit parameter returns the item’s number. Generally, only controls should be enabled. If your application creates a complex control—such as one that measures how far a dial is moved—your application must handle mouse events in that item before passing the event to DialogSelect.
If the user presses the mouse button while the cursor is in a disabled item, or if it is in no item, or if any other event occurs, DialogSelect does nothing.
If the event isn’t one that DialogSelect specifically checks for (if it’s a null event, for example), and if there’s an edit text item in the dialog box, DialogSelect calls the TextEdit function TEIdle to make the insertion point blink.
Because DialogSelect handles only mouse-down events in a dialog box and key-down events in a dialog box’s edit text items, you should handle other events as appropriate before passing them to DialogSelect. Likewise, when DialogSelect calls the Control Manager function TrackControl , it does not allow you to specify any action function necessary for anything more complex than a button, radio button, or checkbox. If you need a more complex control (for example, one that measures how long the user holds down the mouse button or how far the user has moved an indicator), you can create your own control or a picture or an application-defined item that draws a control-like object in your dialog box. You must then test for and respond to those events yourself.
Within dialog boxes, use the functions DialogCut, DialogCopy, DialogPaste, and DialogDelete to support Cut, Copy, Paste, and Clear commands in edit text boxes.
Dialogs.h
Dismisses a dialog box for which the Dialog Manager supplies memory and disposes of the dialog structure.
void DisposeDialog ( DialogRef theDialog );
A pointer to a dialog structure.
The DisposeDialog function calls CloseDialog and, in addition, releases the memory occupied by the dialog box’s item list resource and the dialog structure. Call DisposeDialog when you’re done with a dialog box if you pass null in the dStorage parameter to GetNewDialog , NewColorDialog , or NewDialog.
Dialogs.h
void DisposeModalFilterUPP ( ModalFilterUPP userUPP );
Dialogs.h
void DisposeModalFilterYDUPP ( ModalFilterYDUPP userUPP );
This function is supported in Carbon because several QuickTime routines require it.
Dialogs.h
void DisposeUserItemUPP ( UserItemUPP userUPP );
Dialogs.h
Draws the entire contents of a specified dialog box.
void DrawDialog ( DialogRef theDialog );
A pointer to a dialog structure.
The DrawDialog function draws all dialog items, calls the Control Manager function DrawOneControl to draw all controls, and calls the TextEdit function TEUpdate to update all static and edit text items and to draw their display rectangles. The DrawDialog function also calls the application-defined items’ draw functions if the items’ rectangles are within the update region.
DialogSelect , ModalDialog , Alert , StopAlert , NoteAlert , and CautionAlert use DrawDialog automatically. If you use GetNewDialog to create a dialog box but don’t use any of these other Dialog Manager functions when handling events in the dialog box, you can use DrawDialog to redraw the contents of the dialog box when it’s visible. If the dialog box is invisible, first use the Window Manager function ShowWindow and then use DrawDialog.
Dialogs.h
Determines the item number of an item at a particular location in a dialog box.
DialogItemIndexZeroBased FindDialogItem ( DialogRef theDialog, Point thePt );
A pointer to a dialog structure.
The point (in local coordinates) where the mouse-down event occurred.
When an embedding hierarchy is established, the FindDialogItem function returns the deepest control selected by the user corresponding to the point specified in the thePt parameter. When an embedding hierarchy does not exist, FindDialogItem performs a linear search of the item list resource and returns a number corresponding to the hit item’s position in the item list resource. For example, it returns 0 for the first item in the item list, 1 for the second, and 2 for the third. If the mouse is not over a dialog item, FindDialogItem returns –1. See the description of the DialogItemIndexZeroBased data type.
The function FindDialogItem is useful for changing the cursor when the user moves the cursor over a particular item.
To get the proper item number before calling the GetDialogItem function or the SetDialogItem function, add 1 to the result of FindDialogItem, as shown here:
theItem = FindDialogItem(theDialog, thePoint) + 1;
Note that FindDialogItem returns the item number of disabled items as well as enabled items.
This function was changed with Appearance Manager 1.0 to support embedding hierarchies.
Dialogs.h
Determines the stage of the last occurrence of an alert.
SInt16 GetAlertStage ( void );
A number from 0 to 3 as the stage of the last occurrence of an alert.
You can use the GetAlertStage function to ensure that your application deactivates the active window only if an alert box is to be displayed at that stage.
Dialogs.h
Returns the item number of the cancel item previously set with SetDialogCancelItem.
SInt16 GetDialogCancelItem ( DialogRef dialog );
On input, a pointer to the dialog structure for the dialog box whose cancel item you want to get.
The item number of the cancel item previously set with the SetDialogCancelItem function.
If you don’t explicitly call GetDialogCanceltItem, the standard filter function treats item 2 as the cancel item.
Dialogs.h
Returns the item number of the default item currently set for the standard filter function.
SInt16 GetDialogDefaultItem ( DialogRef dialog );
On input, a pointer to the dialog structure for the dialog box whose default item you want to get.
The item number of the default item currently set for the standard filter function.
If you don’t explicitly call GetDialogDefaultItem, the standard filter function treats item 1 as the default item.
Dialogs.h
DialogRef GetDialogFromWindow ( WindowRef window );
See the description of the DialogRef data type.
Dialogs.h
Obtains a handle to a dialog item.
void GetDialogItem ( DialogRef theDialog, DialogItemIndex itemNo, DialogItemType *itemType, Handle *item, Rect *box );
A pointer to the dialog box to examine.
The position of the item in the dialog box’s item list resource use FindDialogItem to determine this value.
A pointer to a short value. On return, the value identifies the item type of the dialog item requested in the itemNo parameter.
A pointer to an item handle. On return the handle refers to the item specified in the itemNo parameter or, for application-defined draw functions, a pointer (coerced to a handle) to the draw function.
A pointer to a rectangle. On return, the rectangle specifies the display rectangle (described in coordinates local to the dialog box), for the item specified in the itemNo parameter.
The GetDialogItem function produces the item type, a handle to the item (or, for application-defined draw functions, the function pointer), and the display rectangle for a specified item in an item list resource. When a control hierarchy is present in the dialog box, GetDialogItem gets the appropriate information (for example, a text handle) from the controls. If you wish to get a control handle for a dialog item in an embedding hierarchy, see GetDialogItemAsControl.
You should call GetDialogItem before calling functions such as SetDialogItemText that need a handle to a dialog item.
See also the function SetDialogItem.
This function was changed with Appearance Manager 1.0 to support retrieving item information from controls.
Dialogs.h
Obtains the control handle for a dialog item in an embedding hierarchy.
OSErr GetDialogItemAsControl ( DialogRef inDialog, DialogItemIndex inItemNo, ControlRef *outControl );
A pointer to the dialog box to examine.
The position of an item in the dialog box’s item list.
A pointer to a control handle that, on return, refers to the embedded control.
A result code. See “Dialog Manager Result Codes.” The Control Manager result code errItemNotControl indicates that the specified dialog item is not a control.
When an embedding hierarchy is established, GetDialogItemAsControl produces a handle to the embedded controls (except Help items). It should be used instead of GetDialogItem when an embedding hierarchy is established.
This function is available with Appearance Manager 1.0 and later.
Dialogs.h
Obtains the text string contained in an edit text or a static text item.
void GetDialogItemText ( Handle item, Str255 text );
On input, a handle to an edit text or a static text item. To get this handle, call the “Alert Button Constants” function.
On output, a string containing the text of the item that is specified by the item parameter.
The GetDialogItemText function will only return the first 255 characters in an edit text item.
Dialogs.h
Returns the item number of the editable text item in a dialog box that has keyboard focus.
SInt16 GetDialogKeyboardFocusItem ( DialogRef dialog );
On input, a pointer to the dialog structure for the dialog box whose currently focused item you want to identify.
The number of the editable text item in a dialog box that currently has keyboard focus.
When the Appearance Manager is available and an embedding hierarchy is established, you should call the Control Manager function GetKeyboardFocus instead of GetDialogKeyboardFocusItem to return the item number of the item in a dialog box that has keyboard focus.
The GetDialogKeyboardFocusItem function accesses the edit field in the dialog structure. GetDialogKeyboardFocusItem should only be called when there is no embedding hierarchy in the dialog box.
This function is not recommended with Appearance Manager 1.0 and later.
Dialogs.h
CGrafPtr GetDialogPort ( DialogRef dialog );
See the QuickDraw Manager documentation for a description of the CGrafPtr data type.
Dialogs.h
TEHandle GetDialogTextEditHandle ( DialogRef dialog );
See the TextEdit documentation for a description of the TEHandle data type.
Dialogs.h
Obtains the original countdown duration, the time remaining, and the item selection to be simulated for a specified modal dialog box.
OSStatus GetDialogTimeout ( DialogRef inDialog, DialogItemIndex *outButtonToPress, UInt32 *outSecondsToWait, UInt32 *outSecondsRemaining );
A pointer to the dialog box to be examined.
On input, a pointer to a signed 16-bit integer. On return, a value representing the number within the item list of the item that is to be selected. You may pass NULL for the outButtonToPress parameter if you do not desire this information.
On input, a pointer to an unsigned 32-bit integer. On return, a value specifying the number of seconds that were originally set to elapse before the Dialog Manager simulates an item selection. You may pass NULL for the outSecondsToWait parameter if you do not desire this information.
On input, a pointer to an unsigned 32-bit integer. On return, a value specifying the number of seconds remaining before the Dialog Manager simulates an item selection. You may pass NULL for the outSecondsRemaining parameter if you do not desire this information.
A result code. See “Dialog Manager Result Codes.”
Also see the function SetDialogTimeout.
Dialogs.h
WindowRef GetDialogWindow ( DialogRef dialog );
See the QuickDraw Manager documentation for a description of the WindowRef data type.
Dialogs.h
Obtains the events to be received by the ModalDialog function.
OSStatus GetModalDialogEventMask ( DialogRef inDialog, EventMask *outMask );
A pointer to the dialog box for which you wish to obtain the event mask.
On input, a pointer to a unsigned 16-bit integer of type EventMask. On return, your application may test the bits of this value to determine the event(s) that the dialog box is currently set to receive.
A result code. See “Dialog Manager Result Codes.”
Also see the function SetModalDialogEventMask.
This function is available with Mac OS 8.5 and later.
Dialogs.h
Creates a dialog box from a resource-based description.
DialogRef GetNewDialog ( SInt16 dialogID, void *dStorage, WindowRef behind );
The resource ID of a dialog resource and an extended dialog resource. The resource IDs for both resources must be identical. If the dialog resource is missing, the Dialog Manager returns to your application without creating the requested dialog box. See ‘DLOG’ and ‘dlgx’ for a description of the dialog resource and the extended dialog resource, respectively.
A pointer to the memory for the dialog structure. If you set this parameter to null, the Dialog Manager automatically allocates a nonrelocatable block in your application heap.
A pointer to the window behind which the dialog box is to be placed on the desktop. Set this parameter to the window pointer (WindowPtr)-1L to bring the dialog box in front of all other windows.
Returns a pointer to a dialog box. If none was created, returns null. See the description of the DialogRef data type.
The GetNewDialog function creates a dialog structure from information in a dialog resource and an extended dialog resource (if it exists) and returns a pointer to the dialog structure. You can use this pointer with Window Manager or QuickDraw functions to manipulate the dialog box. If the dialog resource specifies that the dialog box should be visible, the dialog box is displayed. If the dialog resource specifies that the dialog box should initially be invisible, use the Window Manager function ShowWindow to display the dialog box.
The dialog resource contains a resource ID that specifies both the dialog box’s item list ( 'DITL') resource and its dialog font table ( 'dftb') resource. After calling the Resource Manager to read these resources into memory (if they are not already in memory), GetNewDialog makes a copy of the 'DITL' resource and uses that copy; thus you may have several dialog boxes with identical items.
If you supply a dialog color table ( 'dctb') resource with the same resource ID as the dialog resource, GetNewDialog uses NewColorDialog and returns a pointer to a color graphics port. If no dialog color table resource is present, GetNewDialog uses NewDialog to return a pointer to a black-and-white graphics port, although system software draws the window frame using the system’s default colors. However, if the Appearance Manager is available and the kDialogFlagsUseThemeBackground feature bit of the extended dialog resource is set, then the 'dctb' resource is ignored and a color graphics port is created.
The GetNewDialog function doesn’t release the memory occupied by the resources. Therefore, your application should mark all resources used for a dialog box as purgeable or you should release the resources yourself.
If either the dialog resource or the item list resource can’t be read, the function result is null; your application should test to ensure that null is not returned before performing any more operations with the dialog box or its items.
As with all other windows, dialogs are created with an update region equal to their port rectangle. However, if the dialog’s 'DLOG' resource specifies that the dialog be made visible upon creation, the Dialog Manager draws the controls immediately and calls ValidRgn for each of their bounding rectangles. Other items are not drawn until the first update event for the dialog box is serviced.
If you need to display an alert box while your application is running in the background or is otherwise invisible to the user, call AEInteractWithUser
This function was changed with Appearance Manager 1.0 to support the extended dialog ('dlgx') resource and the dialog font table ('dftb') resource.
Dialogs.h
void GetParamText ( StringPtr param0, StringPtr param1, StringPtr param2, StringPtr param3 );
Dialogs.h
Fills out an AlertStdCFStringAlertParamRec with default values: - not movable - no help button - default button with title "OK" - no cancel or other buttons.
OSStatus GetStandardAlertDefaultParams ( AlertStdCFStringAlertParamPtr param, UInt32 version );
The parameter block to initialize.
The parameter block version; pass kStdCFStringAlertVersionOne.