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.Function | Description |
---|---|
CreateDialog | Creates a modeless dialog box from a dialog box template resource. |
CreateDialogIndirect | Creates a modeless dialog box from a dialog box template in memory. |
CreateDialogIndirectParam | Creates a modeless dialog box from a dialog box template in memory. |
CreateDialogParam | Creates a modeless dialog box from a dialog box template resource. |
DefDlgProc | Calls 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. |
DialogBox | Creates a modal dialog box from a dialog box template resource. |
DialogBoxIndirect | Creates a modal dialog box from a dialog box template in memory. |
DialogBoxIndirectParam | Creates a modal dialog box from a dialog box template in memory. |
DialogBoxParam | Creates a modal dialog box from a dialog box template resource. |
DialogProc | An application-defined callback function used with the CreateDialog and DialogBox families of functions. |
EndDialog | Destroys a modal dialog box. |
GetDialogBaseUnits | Retrieves the system's dialog base units. |
GetDlgCtrlID | Retrieves the identifier of the specified control. |
GetDlgItem | Retrieves a handle to a control in the specified dialog box. |
GetDlgItemInt | Translates the text of a specified control in a dialog box into an integer value. |
GetDlgItemText | Retrieves the title or text associated with a control in a dialog box. |
GetNextDlgGroupItem | Retrieves a handle to the first control in a group of controls that precedes (or follows) the specified control. |
GetNextDlgTabItem | Retrieves a handle to the first control that has the WS_TABSTOP style that precedes (or follows) the specified control. |
IsDialogMessage | Determines whether a message is intended for the specified dialog box. |
MapDialogRect | Converts the specified dialog box units to screen units (pixels). |
MessageBox | Creates, displays, and operates a message box. |
MessageBoxEx | Creates, displays, and operates a message box. |
MessageBoxIndirect | Creates, displays, and operates a message box. |
SendDlgItemMessage | Sends a message to the specified control in a dialog box. |
SetDlgItemInt | Sets the text of a control in a dialog box to the string representation of a specified integer value. |
SetDlgItemText | Sets the title or text of a control in a dialog box. |
相关文章推荐
- Android开发环境——SDK相关内容汇总
- Android开发环境——SDK相关内容汇总
- Android开发环境——SDK相关内容汇总
- CMS内容管理系统开发-JavaScript相关知识及小游戏开发实例
- 使用VMware VSphere WebService SDK进行开发 (四)——获取集群(Cluster, ComputeResource)的相关信息
- 摘录InfoQ上敏捷开发中用户故事相关的内容
- Android开发环境——连接驱动ADB相关内容汇总
- 移动端 h5开发相关内容总结——CSS篇
- 使用VMware VSphere WebService SDK进行开发 (四)——获取集群(Cluster, ComputeResource)的相关信息
- WindowsPhone开发 +使用Live SDK相关API操作SkyDrive + IsolatedStorageSettings的Bug。
- 敏捷开发相关内容总结
- Android开发环境——连接驱动ADB相关内容汇总
- Android开发环境——Eclipse ADT相关内容汇总
- Kinect for Windows SDK开发学习相关资源
- Linux应用开发中时间相关内容
- Android开发sdk的相关问题
- 移动端 h5开发相关内容总结——CSS篇
- Win32 SDK开发中对话框控件消息处理
- 移动端 h5开发相关内容总结——CSS篇