![]() |
Tipp 0465
|
CommandButton-Beschriftung ausrichten
|
 |
|
Autor/Einsender: Datum: |
|
Detlev Schubert 30.09.2005 |
|
Entwicklungsumgebung: |
|
VB 6 |
|
|
Leider haben die VB-Designer den CommandButton recht spartanisch ausgestattet, so dass man in die
API-Trickkiste greifen muss, um die Beschriftung anders als zentriert auszurichten. Mit den entsprechenden
Konstanten und den API-Funktionen GetWindowLong und SetWindowLong lässt sich die Beschriftung
eines CommandButtons nicht nur links oder rechts, sondern auch oben und unten ausrichten.
|
|
|
Option Explicit
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
Private Const CB_LEFT = &H100
Private Const CB_RIGTH = &H200
Private Const CB_CENTER = &H300
Private Const CB_TOP = &H400
Private Const CB_BOTTOM = &H800
Private Const CB_STYLE = (-16)
Private Sub Form_Load()
Adjust_Text Command1, CB_LEFT
Adjust_Text Command2, CB_RIGTH
Adjust_Text Command3, CB_TOP
Adjust_Text Command4, CB_BOTTOM
End Sub
Private Sub Adjust_Text(Command As Object, Style As Long)
Dim lngPOS As Long
lngPOS = GetWindowLong(Command.hwnd, CB_STYLE) Or Style
SetWindowLong Command.hwnd, CB_STYLE, lngPOS
End Sub
|
|
|
Windows-Version |
95 |
 |
|
98 |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
VB-Version |
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (2,8 kB)
|
Downloads bisher: [ 543 ]
|
|
|