目录
接上:VC++在窗口中显示按钮 CButton::Create Button Styles Window Styles
接下:VC++简单绘图 MFC消息映射机制 MessageBox函数
You construct a CButton object in two steps. First, call the constructor and then call Create, which creates the Windows button control and attaches it to the CButton object.
If the WS_VISIBLE style is given, Windows sends the button control all the messages required to activate and show the button.
Apply the following window styles to a button control:
用两个步骤构造一个CButton对象。首先,调用构造函数,然后调用Create(创建Windows按钮控件并将其附加到CButton对象)。
如果给出了WS_VISIBLE样式,Windows将向按钮控件发送激活和显示按钮所需的所有消息。
在按钮控件上应用以下窗口样式:
WS_CHILD Always
WS_VISIBLE Usually
WS_DISABLED Rarely
WS_GROUP To group controls
WS_TABSTOP To include the button in the tabbing order
Type | Description |
---|---|
BS_3STATE | Creates a check box button with three states: BST_CHECKED, BST_INDETERMINATE, and BST_UNCHECKED. Clicking on the button sends a BN_CLICKED notification to the owner window but does not change the state of the button. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style. |
BS_AUTO3STATE | Creates a check box button with three states: BST_CHECKED, BST_INDETERMINATE, and BST_UNCHECKED. Clicking on the button sends a BN_CLICKED notification to the owner window and changes the state of the button. The button states cycle in the order of BST_CHECKED, BST_INDETERMINATE, and BST_UNCHECKED. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style. |
BS_AUTOCHECKBOX | Creates a check box button with two states: BST_CHECKED and BST_UNCHECKED. Clicking on the button sends a BN_CLICKED notification to the owner window and changes the state of the button. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style. |
BS_AUTORADIOBUTTON | Creates a radio button with two states: BST_CHECKED and BST_UNCHECKED. Radio buttons are usually used in groups, with each group having a maximum of one checked option at a time. Clicking on the button sends a BN_CLICKED notification to the owner window, sets the state of the clicked radio button to BST_CHECKED, and sets the states of all other radio buttons in the button group to BST_UNCHECKED. By default, associated text is displayed to the right of the radio button. To display text to the left of the radio button, use the BS_LEFTTEXT or BS_RIGHTBUTTON style. |
BS_CHECKBOX | Creates a check box button with two states: BST_CHECKED and BST_UNCHECKED. Clicking on the button sends a BN_CLICKED notification to the owner window but does not change the state of the button. By default, associated text is displayed to the right of the check box. To display text to the left of the check box, use the BS_LEFTTEXT or BS_RIGHTBUTTON style. |
BS_COMMANDLINK | Creates a command link button. A command link button is a command button specific to Windows Vista that displays a green arrow to the left of the main text and a note below the main text. You can set the note text using CButton::SetNote. |
BS_DEFCOMMANDLINK | Creates a command link button. A command link button is a command button specific to Windows Vista that displays a green arrow to the left of the main text and a note below the main text. You can set the note text using CButton::SetNote. If the button is in a dialog box, pressing the ENTER key sends a BN_CLICKED notification to the dialog box even when the button does not have the input focus. |
BS_DEFPUSHBUTTON | Creates a command button that has a heavy black border. If the button is in a dialog box, pressing the ENTER key sends a BN_CLICKED notification to the dialog box even when the button does not have the input focus. |
BS_DEFSPLITBUTTON | Creates a split button. A split button is a command button specific to Windows Vista that contains a button adjacent to a drop-down arrow. When you click the button, the default command is executed. When you click the drop-down arrow, a menu of additional commands appears. If the split button is in a dialog box, pressing the ENTER key sends a BN_CLICKED notification to the dialog box even when the button does not have the input focus |
BS_GROUPBOX | Creates a rectangle in which other buttons can be grouped. Text associated with this style is displayed in the rectangle's upper-left corner. |
BS_OWNERDRAW | Creates an owner-drawn button. The framework calls the DrawItem method when a visual aspect of the button has changed. This style must be set when you use the CBitmapButton class. |
BS_PUSHBUTTON | Creates a command button that sends a BN_CLICKED notification to the owner window when the user clicks the button. |
BS_RADIOBUTTON | Creates a radio button with two states: BST_CHECKED and BST_UNCHECKED. Radio buttons are usually used in groups, with each group having a maximum of one checked option at a time. Clicking on the button sends a BN_CLICKED notification to the owner window but does not automatically change the state of any button in the group. By default, associated text is displayed to the right of the radio button. To display text to the left of the radio button, use the BS_LEFTTEXT or BS_RIGHTBUTTON style. |
BS_SPLITBUTTON | Creates a split button. A split button is a command button specific to Windows Vista that contains a button adjacent to a drop-down arrow. When you click the button, the default command is executed. When you click the drop-down arrow, a menu of additional commands appears. |
BS_USERBUTTON | Obsolete, but provided for compatibility with 16-bit versions of Windows. Win32-based applications should use BS_OWNERDRAW instead. |
WS_BORDER Creates a window that has a border.
WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). Cannot be used with the WS_DLGFRAME style.
WS_CHILD Creates a child window. Cannot be used with the WS_POPUP style.
WS_CHILDWINDOW Same as the WS_CHILD style.
WS_CLIPCHILDREN Excludes the area occupied by child windows when you draw within the parent window. Used when you create the parent window.
WS_CLIPSIBLINGS Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only.
WS_DISABLED Creates a window that is initially disabled.
WS_DLGFRAME Creates a window with a double border but no title.
WS_GROUP Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style FALSE after the first control belong to the same group. The next control with the WS_GROUP style starts the next group (that is, one group ends where the next begins).
WS_HSCROLL Creates a window that has a horizontal scroll bar.
WS_ICONIC Creates a window that is initially minimized. Same as the WS_MINIMIZE style.
WS_MAXIMIZE Creates a window of maximum size.
WS_MAXIMIZEBOX Creates a window that has a Maximize button.
WS_MINIMIZE Creates a window that is initially minimized. For use with the WS_OVERLAPPED style only.
WS_MINIMIZEBOX Creates a window that has a Minimize button.
WS_OVERLAPPED Creates an overlapped window. An overlapped window usually has a caption and a border.
WS_OVERLAPPEDWINDOW Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles.
WS_POPUP Creates a pop-up window. Cannot be used with the WS_CHILD style.
WS_POPUPWINDOW Creates a pop-up window with the WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION style must be combined with the WS_POPUPWINDOW style to make the Control menu visible.
WS_SIZEBOX Creates a window that has a sizing border. Same as the WS_THICKFRAME style.
WS_SYSMENU Creates a window that has a Control-menu box in its title bar. Used only for windows with title bars.
WS_TABSTOP Specifies one of any number of controls through which the user can move by using the TAB key. The TAB key moves the user to the next control specified by the WS_TABSTOP style.
WS_THICKFRAME Creates a window with a thick frame that can be used to size the window.
WS_TILED Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPEDstyle.
WS_TILEDWINDOW Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_OVERLAPPEDWINDOW style.
WS_VISIBLE Creates a window that is initially visible.
WS_VSCROLL Creates a window that has a vertical scroll bar.