COMMAND BUTTON

Mengatur Property Alignment Caption Button

Mengatur alignment (perataan) tulisan (caption) di commandbutton. Anda dapat mengatur agar tulisan di tombol kelihatan rata kiri, rata kanan, rapat ke atas, atau rapat ke bawah.

langkah2:
1. Buat 1 Project baru dengan 1 Form, 1 Module, 4 Commandbutton,
2. Ketik coding berikut ke dalam editor form dan module yang bertalian.
Ketik coding berikut ini pada Module.

Code:

Public Const A_CENTER = &H300&
Public Const A_TOP = &H400&
Public Const A_TOPLEFT = &H500&
Public Const A_TOPRIGHT = &H600&
Public Const A_BOTTOM = &H800&
Public Const A_BOTTOMLEFT = &H900&
Public Const A_BOTTOMRIGHT = &HA00&
Public Const A_LEFT = &H100&
Public Const A_RIGHT = &H200&
Public Const GWL_STYLE& = (-16)
Declare Function GetWindowLong& Lib “user32” Alias _
“GetWindowLongA” (ByVal hwnd As Long, _
ByVal nIndex As Long)
Declare Function SetWindowLong& Lib “user32” Alias _
“SetWindowLongA” (ByVal hwnd As Long, ByVal nIndex As _ Long,
ByVal dwNewLong As Long)
Ketik coding berikut ini pada Form.
Private Sub Command1_Click()
Dim tmpValue&
Dim Align&
Dim ret&
‘Contoh berikut akan membuat tulisan di Command1
‘menjadi rapat ke atas ketika Anda mengklik tombol
‘tersebut.
fAlignment& = A_TOP
tmpValue& = GetWindowLong&(Command1.hwnd, _
GWL_STYLE) And Not BS_RIGHT
ret& = SetWindowLong&(Command1.hwnd, GWL_STYLE, _
tmpValue& Or fAlignment&)
Command1.Refresh
End Sub
Private Sub Command2_Click()
Dim tmpValue&
Dim Align&
Dim ret&
‘Contoh berikut akan membuat tulisan di Command2
‘menjadi rapat ke bawah ketika Anda mengklik tombol
‘tersebut.
fAlignment& = A_BOTTOM
tmpValue& = GetWindowLong&(Command2.hwnd, _
GWL_STYLE) And Not BS_RIGHT
ret& = SetWindowLong&(Command2.hwnd, GWL_STYLE, _
tmpValue& Or fAlignment&)
Command2.Refresh
End Sub
Private Sub Command3_Click()
Dim tmpValue&
Dim Align&
Dim ret&
‘Contoh berikut akan membuat tulisan di Command3
‘menjadi rapat ke kiri ketika Anda mengklik tombol
‘tersebut.
fAlignment& = A_LEFT
tmpValue& = GetWindowLong&(Command3.hwnd, _
GWL_STYLE) And Not BS_RIGHT
ret& = SetWindowLong&(Command3.hwnd, GWL_STYLE, _
tmpValue& Or fAlignment&)
Command3.Refresh
End Sub
Private Sub Command4_Click()
Dim tmpValue&
Dim Align&
Dim ret&
‘Contoh berikut membuat tulisan di Command4 menjadi
‘rapat ke kanan ketika Anda mengklik tombol tersebut.
fAlignment& = A_RIGHT
tmpValue& = GetWindowLong&(Command4.hwnd, _
GWL_STYLE) And Not BS_RIGHT
ret& = SetWindowLong&(Command4.hwnd, GWL_STYLE, _
tmpValue& Or fAlignment&)
Command4.Refresh
End Sub

1 Komentar

  1. […] chart, Source code cek status memory, Source code password generator, Source code auto starup, Command button, ComboBox, Tombol form lain, Tombol dari coding, Database1, Database2, Database3, Date and […]


Comments RSS TrackBack Identifier URI

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s