borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How to find windows which r minimized to the system tray (FindWindow)?)Next Topic (How to know if Windows is going to restart or shutdown?) New Topic New Poll Post Reply
AndreaVB Forum : API : How to center text in command button?
Poster Message
toughcoder
Level: Guest


icon How to center text in command button?

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
| Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
Goran
Level: Moderator

Registered: 16-05-2002
Posts: 1681
icon 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.

09-10-2004 at 06:26 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : API : How to center text in command button?
Previous Topic (How to find windows which r minimized to the system tray (FindWindow)?)Next Topic (How to know if Windows is going to restart or shutdown?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder