|
-
Sep 29th, 2004, 12:26 PM
#1
Thread Starter
Hyperactive Member
Change style of command button to graphical during run time?
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...
If Not VB Then Exit
------------------------------------------------
visit me @ http://mzubair.50g.com/
-
Sep 29th, 2004, 04:43 PM
#2
-
Sep 29th, 2004, 09:12 PM
#3
Thread Starter
Hyperactive Member
I'm developing a subclassing control and it can catch the WM_DRAWITEM msg only for graphical style buttons(owner buttons). Got the picture...
If Not VB Then Exit
------------------------------------------------
visit me @ http://mzubair.50g.com/
-
Sep 29th, 2004, 10:33 PM
#4
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?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 30th, 2004, 12:19 AM
#5
Thread Starter
Hyperactive Member
yeah rob, its possible, but i just cant remember the constant to be supplied to SetLongWindow...
If Not VB Then Exit
------------------------------------------------
visit me @ http://mzubair.50g.com/
-
Sep 30th, 2004, 04:30 AM
#6
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
-
Sep 30th, 2004, 07:11 AM
#7
Thread Starter
Hyperactive Member
thanx Merrion, guess i cud use them...
If Not VB Then Exit
------------------------------------------------
visit me @ http://mzubair.50g.com/
-
Sep 30th, 2004, 01:49 PM
#8
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&
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 30th, 2004, 05:28 PM
#9
Use GetWindowLong to get the current window style.
Then AND this with WS_RIGHT
Then use Sendmessage(hwnd, WM_SETSTYLE, new style, True)
-
Sep 30th, 2004, 05:54 PM
#10
Thanks, i'll try it out.
Sorry for piggy-backing on your thread toughcoder!
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|