Not a Member Yet,
Click here to Register

ID: 162
Viewed: 2864
Added: Apr 29, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

none

Highlight all by clicking in box
<!---Declaration--->
Option Explicit
'
'Contributed by Sam Huggil of
'
'http://www.vbsquare.com
'
' This code sample requires a button (command1) and a
' checkbox (check1) on a form (form1).
'
' Selecting the CheckBox will toggle the alignment of the
' text in the button
'
'


'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)

Highlight All
<!---Code--->
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;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!