|
-
Sep 30th, 2004, 11:34 PM
#1
Thread Starter
PowerPoster
Button Alignment
VB Code:
'Place a command button(Command1) And a check box(Check1) on the form
'Click checkbox to set the alignment
'Alignment constants
Private Const BS_CENTER& = &H300&
Private Const BS_LEFT& = &H100&
Private Const BS_RIGHT& = &H200&
Private Const BS_TOP& = &H400&
Private Const GWL_STYLE& = (-16)
'API Calls
Private Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long)
Private Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Private Sub Check1_Click()
'Declare Variables
Dim tmpValue&
Dim Align&
Dim ret&
Dim fAlignment As Long
'Check if the state is checked
If Check1.Value = Checked Then 'Yes
fAlignment& = BS_LEFT
tmpValue& = GetWindowLong&(Command1.hwnd, GWL_STYLE) And Not BS_RIGHT
ret& = SetWindowLong&(Command1.hwnd, GWL_STYLE, tmpValue& Or fAlignment&)
Command1.Refresh
Else 'No
fAlignment& = BS_CENTER
tmpValue& = GetWindowLong&(Command1.hwnd, GWL_STYLE) And Not BS_RIGHT Or BS_LEFT
ret& = SetWindowLong&(Command1.hwnd, GWL_STYLE, tmpValue& Or fAlignment&)
Command1.Refresh
End If
End Sub
-
Oct 1st, 2004, 02:14 PM
#2
Dont mean to give you a hard time but actually credit should go
to Merrion. I can see that you got the code from our posts in this
thread and made the code bank deposit right after we posted our
posts.
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 
-
Oct 1st, 2004, 11:02 PM
#3
Thread Starter
PowerPoster
no Rob. i don't got the code from ur posts. i have that code in my code library from a very long period.
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
|