Greetings every1,
This thing has been done many a times, but I cant get it now. Just how can i center text in a command button. I used the following code
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = (-16)
Const BS_RIGHT As Long = &H200&
Private Sub Command2_Click()
Dim newStyle As Long
newStyle = GetWindowLong(Command1.hwnd, GWL_STYLE)
newStyle = newStyle And BS_RIGHT
SetWindowLong Command1.hwnd, GWL_STYLE, newStyle
End Sub
But its not working. Can any guyz provide a working solution...
09-10-2004 at 03:02 PM
|
Goran Level: Moderator Registered: 16-05-2002 Posts: 1681
Re: How to center text in command button?
Well, you say you want to center text on a button, and you are using BS_RIGHT. That is quite contrdictory, no?
Const BS_CENTER = &H300& ' horisontally
Const BS_VCENTER As Long = &HC00 ' vertically
____________________________
If you find the answer helpful, please mark this topic as solved.
09-10-2004 at 06:18 PM
|
Goran Level: Moderator Registered: 16-05-2002 Posts: 1681
Re: How to center text in command button?
And another thing, if you want to add some style tu button you use OR operator, not AND. AND operator is used to remove it.
____________________________
If you find the answer helpful, please mark this topic as solved.