Showing posts with label OptionButton. Show all posts
Showing posts with label OptionButton. Show all posts

Friday, June 29, 2012

VB6 Source Code: Membuat Frame Dari OptionButton - CheckBox

Mengenai cara membuat Frame dari objek OptionButton atau ChekBox - Dikarenakan objek CheckBox, OptionButton, kemudian CommandButton
berasal dari kelas yang sama yaitu Class Button, maka ketiganya pun dapat kita rubah stylenya menjadi sebuah Frame dengan memanfaatkan konstanta BS_GROUPBOX dan BM_SETSTYLE melalui bantuan fungsi API SendMessage. Keuntungan membuat Frame dari OptionButton, CheckBox atau CommandButton adalah dapat mengikuti Style Windows.
Adapun kode untuk merubah style CheckBox atau OptionButton menjadi Frame sebagai berikut:
'Simpan pada form
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
        ByVal hWnd As Long, _
        ByVal wMsg As Long, _
        ByVal wParam As Long, _
        lParam As Any) As Long
         
Private Const BM_SETSTYLE As Long = &HF4
Private Const BS_GROUPBOX As Long = &H7&
 
'Contoh penggunaan
Private Sub Form_Load()
    SendMessage Check1.hWnd, BM_SETSTYLE, BS_GROUPBOX, 0
End Sub

Catatan: Jangan lupa untuk merubah property ClipsControl yang terdapat pada Form menjadi False.
Download: Source Code
READ MORE - VB6 Source Code: Membuat Frame Dari OptionButton - CheckBox