Greetings Every1,
I want to set the Style property of Command Button to Graphical i.e., 1 during run time using the SetLongWindow API. But I dont know how? Plz help...
Printable View
Greetings Every1,
I want to set the Style property of Command Button to Graphical i.e., 1 during run time using the SetLongWindow API. But I dont know how? Plz help...
Why do you have to set it at run time?
I'm developing a subclassing control and it can catch the WM_DRAWITEM msg only for graphical style buttons(owner buttons). Got the picture...
Is it even possible? I only ask because its a read only property at
runtime. There must be some other things that will get affected
by tring to change the button stlye during run time?
yeah rob, its possible, but i just cant remember the constant to be supplied to SetLongWindow...
VB Code:
' ##ENUMERATION_DESCRIPTION ButtonControlStyles - Style bits that modify the appearance Public Enum ButtonControlStyles ' ##ENUMERATION_MEMBER_DESCRIPTION BS_PUSHBUTTON - A standard style push button BS_PUSHBUTTON = &H0 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_DEFPUSHBUTTON - A default push button BS_DEFPUSHBUTTON = &H1 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_CHECKBOX - A checkbox type button BS_CHECKBOX = &H2 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_AUTOCHECKBOX - A check box that deselects others in the same group when selected BS_AUTOCHECKBOX = &H3 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_RADIOBUTTON - A radio (option) button BS_RADIOBUTTON = &H4 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_3STATE - A checkbox that can be dimmed when disabled BS_3STATE = &H5 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_AUTO3STATE - A check box that can be dimmed and that deselects others in the same group when selected BS_AUTO3STATE = &H6 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_GROUPBOX - The button is a button group control BS_GROUPBOX = &H7 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_USERBUTTON - No longer used. BS_USERBUTTON = &H8 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_AUTORADIOBUTTON - A radio button that deselects others in the same group when selected BS_AUTORADIOBUTTON = &H9 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_OWNERDRAW - The button owner is responsible for drawing it BS_OWNERDRAW = &HB ' ##ENUMERATION_MEMBER_DESCRIPTION BS_LEFTTEXT - For check boxes this makes the check box on the left hand side of the text BS_LEFTTEXT = &H20 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_TEXT - Button has text BS_TEXT = &H0 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_ICON - Button contains an icon image BS_ICON = &H40 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_BITMAP - Button contains a bitmap (i.e is graphical) BS_BITMAP = &H80 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_LEFT - Left align the button text BS_LEFT = &H100 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_RIGHT - Right align the button text BS_RIGHT = &H200 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_CENTER - Center (horizontally) the button text BS_CENTER = &H300 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_TOP - Top align the button text BS_TOP = &H400 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_BOTTOM - Bottom align the button text BS_BOTTOM = &H800 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_VCENTER - Vertically centre the button text BS_vCENTER = &HC00 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_PUSHLIKE - Makes a checkbox style button behave as a push button BS_PUSHLIKE = &H1000 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_MULTILINE - Button text wraps if it is too long for a single line BS_MULTILINE = &H2000 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_NOTIFY - Send notification messages to the button owner BS_NOTIFY = &H4000 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_FLAT - Draws the button in the flat style BS_FLAT = &H8000 ' ##ENUMERATION_MEMBER_DESCRIPTION BS_RIGHTBUTTON - For check boxes this makes the check box on the right hand side of the text BS_RIGHTBUTTON = &H20 End Enum ' ##ENUMERATION_DESCRIPTION ButtonControlMessages - Predefined windows messages that are specifically to do with controls derived from the BUTTON class Public Enum ButtonControlMessages ' ##ENUMERATION_MEMBER_DESCRIPTION BM_GETCHECK - Sent to return the check box state (checked or unchecked) BM_GETCHECK = &HF0 ' ##ENUMERATION_MEMBER_DESCRIPTION BM_SETCHECK - Sent to set the check box state (checked or unchecked) BM_SETCHECK = &HF1 ' ##ENUMERATION_MEMBER_DESCRIPTION BM_GETSTATE - Sent to return the button control state BM_GETSTATE = &HF2 ' ##ENUMERATION_MEMBER_DESCRIPTION BM_SETSTATE - Sent to set the button control state BM_SETSTATE = &HF3 ' ##ENUMERATION_MEMBER_DESCRIPTION BM_SETSTYLE - Sent to set the new button style of this button BM_SETSTYLE = &HF4 ' ##ENUMERATION_MEMBER_DESCRIPTION BM_CLICK - Simulates the user clicking this button BM_CLICK = &HF5 ' ##ENUMERATION_MEMBER_DESCRIPTION BM_GETIMAGE - Sent to get the picture displayed by this button, if it is a graphical style button BM_GETIMAGE = &HF6 ' ##ENUMERATION_MEMBER_DESCRIPTION BM_SETIMAGE - Sent to set the picture displayed by this button, if it is a graphical style button BM_SETIMAGE = &HF7 End Enum Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As ButtonControlMessages, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function GetWindowLongApi Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
thanx Merrion, guess i cud use them...
Hey, I was looking for how to align a buttons text and there the
const. is for right align. So sendmessagelong should be able to
change the alignment of a button like this?
VB Code:
SendMessageLong btn.hwnd, BS_RIGHT, 0&, 0&
Use GetWindowLong to get the current window style.
Then AND this with WS_RIGHT
Then use Sendmessage(hwnd, WM_SETSTYLE, new style, True)
Thanks, i'll try it out.
Sorry for piggy-backing on your thread toughcoder!