您的位置:首页 > 其它

Winodows SDK开发与对话框Dialog Box相关内容

2010-03-17 23:17 316 查看

Dialog Box Controls

The template specifies the position, width, height, style, identifier, and window class for each control in the dialog box. The system creates each control by passing this data to the CreateWindowEx function. Controls are created in the order they are specified in the template. The template should specify the appropriate number, type, and order of controls to ensure that the user can enter the input needed to complete the task associated with the dialog box.

For each control, the template specifies style values that define the appearance and operation of the control. Every control is a child window and therefore must have the WS_CHILD style. To ensure that the control is visible when the dialog box is displayed, each control must also have the WS_VISIBLE style. Other commonly used window styles are WS_BORDER for controls that have optional borders, WS_DISABLED for controls that should be disabled when the dialog box is initially created, and WS_TABSTOP and WS_GROUP for controls that can be accessed using the keyboard. The WS_TABSTOP and WS_GROUP styles are used in conjunction with the dialog keyboard interface described later in this topic.

The template may also specify control styles specific to the control's window class. For example, a template that specifies a button control must give a button control style such as BS_PUSHBUTTON or BS_CHECKBOX. The system passes the control styles to the control window procedure through the WM_CREATE message, allowing the procedure to adapt the appearance and operation of the control.

The system converts the position coordinates and the width and height measurements from dialog base units to pixels, before passing these to CreateWindowEx. When the system creates a control, it specifies the dialog box as the parent window. This means the system always interprets the position coordinates of the control as client coordinates, relative to the upper left corner of the dialog box's client area.

The template specifies the window class for each control. A typical dialog box contains controls belonging to the predefined control window classes, such as the button and edit control window classes. In this case, the template specifies window classes by supplying the corresponding predefined atom values for the classes. When a dialog box contains a control belonging to a custom control window class, the template gives the name of that registered window class or the atom value currently associated with the name.

Each control in a dialog box must have a unique identifier to distinguish it from other controls. Controls send information to the dialog box procedure through WM_COMMAND messages, so the control identifiers are essential for the procedure to determine which control sent a specified message. The only exception to this rule are control identifiers for static controls. Static controls do not require unique identifiers because they send no WM_COMMAND messages.

To permit the user to close the dialog box, the template should specify at least one push button and give it the control identifier IDCANCEL. To permit the user to choose between completing or canceling the task associated with the dialog box, the template should specify two push buttons, labeled OK and Cancel, with control identifiers of IDOK and IDCANCEL, respectively.

A template also specifies optional text and creation data for a control. The text typically provides labels for button controls or specifies the initial content of a static text control. The creation data is one or more bytes of data that the system passes to the control window procedure when creating the control. Creation data is useful for controls that require more information about their initial content or style than is specified by other data. For example, an application can use creation data to set the initial setting and range for a scroll bar control.









Dialog Box Functions

The following functions are used to create and manage dialog boxes and controls within dialog boxes.

FunctionDescription
CreateDialogCreates a modeless dialog box from a dialog box template resource.
CreateDialogIndirectCreates a modeless dialog box from a dialog box template in memory.
CreateDialogIndirectParamCreates a modeless dialog box from a dialog box template in memory.
CreateDialogParamCreates a modeless dialog box from a dialog box template resource.
DefDlgProcCalls the default dialog box window procedure to provide default processing for any window messages that a dialog box with a private window class does not process.
DialogBoxCreates a modal dialog box from a dialog box template resource.
DialogBoxIndirectCreates a modal dialog box from a dialog box template in memory.
DialogBoxIndirectParamCreates a modal dialog box from a dialog box template in memory.
DialogBoxParamCreates a modal dialog box from a dialog box template resource.
DialogProcAn application-defined callback function used with the CreateDialog and DialogBox families of functions.
EndDialogDestroys a modal dialog box.
GetDialogBaseUnitsRetrieves the system's dialog base units.
GetDlgCtrlIDRetrieves the identifier of the specified control.
GetDlgItemRetrieves a handle to a control in the specified dialog box.
GetDlgItemIntTranslates the text of a specified control in a dialog box into an integer value.
GetDlgItemTextRetrieves the title or text associated with a control in a dialog box.
GetNextDlgGroupItemRetrieves a handle to the first control in a group of controls that precedes (or follows) the specified control.
GetNextDlgTabItemRetrieves a handle to the first control that has the WS_TABSTOP style that precedes (or follows) the specified control.
IsDialogMessageDetermines whether a message is intended for the specified dialog box.
MapDialogRectConverts the specified dialog box units to screen units (pixels).
MessageBoxCreates, displays, and operates a message box.
MessageBoxExCreates, displays, and operates a message box.
MessageBoxIndirectCreates, displays, and operates a message box.
SendDlgItemMessageSends a message to the specified control in a dialog box.
SetDlgItemIntSets the text of a control in a dialog box to the string representation of a specified integer value.
SetDlgItemTextSets the title or text of a control in a dialog box.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: