Windows SDK之按钮文字对齐方式

来源:互联网 发布:创新网络 编辑:程序博客网 时间:2024/05/16 17:39

    本例设置按钮文字居中对齐方式,对非自绘按钮(BS_OWNERDRAW)起作用。

    GetWindowLong取得按钮自身设定的文字对齐方式,若为左右对齐,则取消其属性。之后,因按钮默认文字对齐属性为居中,故也可不设置。

    可在处理对话框WM_INITDLG消息时运行此段代码。

 

 

 

PS:摘自MSDN的按钮Style

 

Platform SDK: Windows User Interface

Button Styles

If you create a button by specifying the BUTTON class with the CreateWindow or CreateWindowEx function, you can specify a combination of the following button styles.

StyleMeaningBS_3STATECreates a button that is the same as a check box, except that the box can be grayed as well as checked or cleared. Use the grayed state to show that the state of the check box is not determined.BS_AUTO3STATECreates a button that is the same as a three-state check box, except that the box changes its state when the user selects it. The state cycles through checked, grayed, and cleared.BS_AUTOCHECKBOXCreates a button that is the same as a check box, except that the check state automatically toggles between checked and cleared each time the user selects the check box.BS_AUTORADIOBUTTONCreates a button that is the same as a radio button, except that when the user selects it, The system automatically sets the button's check state to checked and automatically sets the check state for all other buttons in the same group to cleared.BS_CHECKBOXCreates a small, empty check box with text. By default, the text is displayed to the right of the check box. To display the text to the left of the check box, combine this flag with the BS_LEFTTEXT style (or with the equivalent BS_RIGHTBUTTON style).BS_DEFPUSHBUTTONCreates a push button that behaves like a BS_PUSHBUTTON style button, but also has a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely (default) option.BS_GROUPBOXCreates a rectangle in which other controls can be grouped. Any text associated with this style is displayed in the rectangle's upper left corner.BS_LEFTTEXTPlaces text on the left side of the radio button or check box when combined with a radio button or check box style. Same as the BS_RIGHTBUTTON style.BS_OWNERDRAWCreates an owner-drawn button. The owner window receives a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles.BS_PUSHBUTTONCreates a push button that posts a WM_COMMAND message to the owner window when the user selects the button.BS_RADIOBUTTONCreates a small circle with text. By default, the text is displayed to the right of the circle. To display the text to the left of the circle, combine this flag with the BS_LEFTTEXT style (or with the equivalent BS_RIGHTBUTTON style). Use radio buttons for groups of related, but mutually exclusive choices.BS_USERBUTTONObsolete, but provided for compatibility with 16-bit versions of Windows. Applications should use BS_OWNERDRAW instead.BS_BITMAPSpecifies that the button displays a bitmap.BS_BOTTOMPlaces text at the bottom of the button rectangle.BS_CENTERCenters text horizontally in the button rectangle.BS_ICONSpecifies that the button displays an icon.BS_FLATSpecifies that the button is two-dimensional; it does not use the default shading to create a 3-D image. BS_LEFTLeft-justifies the text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is left justified on the right side of the check box or radio button.BS_MULTILINEWraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.BS_NOTIFYEnables a button to send BN_KILLFOCUS and BN_SETFOCUS notification messages to its parent window.

Note that buttons send the BN_CLICKED notification message regardless of whether it has this style. To get BN_DBLCLK notification messages, the button must have the BS_RADIOBUTTON or BS_OWNERDRAW style.

BS_PUSHLIKEMakes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked.BS_RIGHTRight-justifies text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is right justified on the right side of the check box or radio button.BS_RIGHTBUTTONPositions a radio button's circle or a check box's square on the right side of the button rectangle. Same as the BS_LEFTTEXT style.BS_TEXTSpecifies that the button displays text.BS_TOPPlaces text at the top of the button rectangle.BS_VCENTERPlaces text in the middle (vertically) of the button rectangle.

 

 

Platform SDK Release: August 2001 What did you think of this topic?
Let us know.Order a Platform SDK CD Online
(U.S/Canada)   (International)
原创粉丝点击