VB6 Menu Icon
berikut adalah contoh program untuk membuat menu program memiliki ikon, aku buat dengan menggunakan Visual Basic 6. berikut screen Shotnya:
Berikut windows api yang digunakan:
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
dan ini Fungsi yang aku buat untuk memudahkan mengatur ikonya:
Private Sub SetGambarMenu(MnIdx, MnSubIdx As Integer, Gambar As Picture)
Dim hMenu, hSubMenu As Long
On Error Resume Next
hMenu = GetMenu(Me.hwnd)
hSubMenu = GetSubMenu(hMenu, MnIdx)
SetMenuItemBitmaps hSubMenu, MnSubIdx, &H400&, Gambar, Gambar
End Sub
Dan ini contoh penggunaanya, yang dipanggil ketika form di load:
Private Sub Form_Load()
SetGambarMenu 0, 0, ImageList1.ListImages(2).Picture
SetGambarMenu 1, 0, ImageList1.ListImages(1).Picture
SetGambarMenu 1, 1, ImageList1.ListImages(1).Picture
SetGambarMenu 1, 2, ImageList1.ListImages(1).Picture
End Sub
Download Project & Source Code
Berikut windows api yang digunakan:
Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SetMenuItemBitmaps Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal hBitmapUnchecked As Long, ByVal hBitmapChecked As Long) As Long
dan ini Fungsi yang aku buat untuk memudahkan mengatur ikonya:
Private Sub SetGambarMenu(MnIdx, MnSubIdx As Integer, Gambar As Picture)
Dim hMenu, hSubMenu As Long
On Error Resume Next
hMenu = GetMenu(Me.hwnd)
hSubMenu = GetSubMenu(hMenu, MnIdx)
SetMenuItemBitmaps hSubMenu, MnSubIdx, &H400&, Gambar, Gambar
End Sub
Dan ini contoh penggunaanya, yang dipanggil ketika form di load:
Private Sub Form_Load()
SetGambarMenu 0, 0, ImageList1.ListImages(2).Picture
SetGambarMenu 1, 0, ImageList1.ListImages(1).Picture
SetGambarMenu 1, 1, ImageList1.ListImages(1).Picture
SetGambarMenu 1, 2, ImageList1.ListImages(1).Picture
End Sub
Download Project & Source Code
0 comments:
Posting Komentar