VB6.0 :: cara merubah skin tampilan vb menjadi seperti Tampilan Office 2007

Pertama, tambahkan terlebih dahulu MDIForm kedalam projek kita.


Kedua, tambahkan module baru kedalam projek kita lalu isi dengan bentuk ID Constanta terhadap tiap objek yang nantinya akan ditampilkan pada mainmenu form kita, anda bisa lihat contoh dibawah ini.

Public Const ID_TAB_FILE = 101
Public Const ID_TAB_DATA = 102
Public Const ID_TAB_TRANSAKSI = 103
Public Const ID_TAB_LAPORAN = 104
Public Const ID_TAB_BANTUAN = 105
Public Const ID_TAB_TOOLS = 106

Public Const ID_GROUP_KON = 10111
Public Const ID_GROUP_USER = 10112
Public Const ID_GROUP_LOG = 10113
Public Const ID_GROUP_DATABASE = 10114
Public Const ID_GROUP_KELUAR = 10115
Public Const ID_KONBIODATA = 1011
Public Const ID_KONBG = 1012
Public Const ID_KONTRANS = 1013
Public Const ID_IMPORT = 1014
Public Const ID_EKSPORT = 1015
Public Const ID_USER = 1016
Public Const ID_GANTI = 1017
Public Const ID_KUNCI = 1018
Public Const ID_LOGOUT = 1019
Public Const ID_KELUAR = 10110

Public Const FSHIFT = 4
Public Const FCONTROL = 8
Public Const FALT = 16

Public Const VK_BACK = &H8
Public Const VK_TAB = &H9
Public Const VK_ESCAPE = &H1B
Public Const VK_SPACE = &H20
Public Const VK_PRIOR = &H21
Public Const VK_NEXT = &H22
Public Const VK_END = &H23
Public Const VK_HOME = &H24
Public Const VK_LEFT = &H25
Public Const VK_UP = &H26
Public Const VK_RIGHT = &H27
Public Const VK_DOWN = &H28
Public Const VK_INSERT = &H2D
Public Const VK_DELETE = &H2E
Public Const VK_MULTIPLY = &H6A
Public Const VK_ADD = &H6B
Public Const VK_SEPARATOR = &H6C
Public Const VK_SUBTRACT = &H6D
Public Const VK_DECIMAL = &H6E
Public Const VK_DIVIDE = &H6F
Public Const VK_F1 = &H70
Public Const VK_F2 = &H71
Public Const VK_F3 = &H72
Public Const VK_F4 = &H73
Public Const VK_F5 = &H74
Public Const VK_F6 = &H75
Public Const VK_F7 = &H76
Public Const VK_F8 = &H77
Public Const VK_F9 = &H78
Public Const VK_F10 = &H79
Public Const VK_F11 = &H7A
Public Const VK_F12 = &H7B

Public Const ID_INDICATOR_CAPS = 59137
Public Const ID_INDICATOR_NUM = 59138
Public Const ID_INDICATOR_SCRL = 59139

Public Const ID_USERNAME = 220
Public Const ID_AKSES = 221
Public Const ID_TANGGAL = 222
Public Const ID_JAM = 223
Public Const ID_INFO = 224

Public Const ID_INDICATOR_ZOOM = 228
Public Const ID_INDICATOR_ZOOMSLIDER = 229

Public Const ID_VIEW_STATUS_BAR = 2808
Public Const ID_GROUP_PAGESETUP = 5022
Public Const ID_SYSTEM_ICON = 1200
Public Const ID_GROUP_POPUPICON = 2004

Public Const ID_OPTIONS_STYLEBLUE = 3000
Public Const ID_OPTIONS_STYLEBLACK = 3001
Public Const ID_OPTIONS_STYLEAQUA = 3002
Public Const ID_OPTIONS_STYLESILVER = 3003
Public Const ID_OPTIONS_WORKSPACE = 3004

Ketiga, buat deklarasi awal terhadap objek yang nanti akan ditampilkan.

Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Const EM_UNDO = &HC7
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
Private Declare Function SetWindowText Lib "user32.dll" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Dim WithEvents Workspace As TabWorkspace
Dim WorkspaceVisible As Boolean
Const IMAGEBASE = 10000
Dim WithEvents StatusBar As StatusBar
Dim ViewZoom  As Long

Public Function RibbonBar() As RibbonBar
    Set RibbonBar = CommandBars.ActiveMenuBar
End Function

Public Sub SetCaption(Caption As String)
    SetWindowText Me.hwnd, Caption
End Sub

Keempat, Membuat Ribbon, sebelumnya deklarasikan ribbonnya.

Dim TabFile As RibbonTab
Dim TabData As RibbonTab
Dim TabTransaksi As RibbonTab
Dim TabLaporan As RibbonTab
Dim TabTools As RibbonTab
Dim TabBantuan As RibbonTab

Dim GroupKon, GroupUser, GroupLog, GroupKeluar, GroupBuku, GroupMember, GroupInvent As RibbonGroup
Dim GroupPinjam, GroupKembali, GroupFavorit, GroupKatalog, GroupPresensi As RibbonGroup

Dim ControlFile As CommandBarPopup
Dim ControlOptions As CommandBarPopup
Dim Control As CommandBarControl
Dim RibbonBar As RibbonBar
Dim Atur As CommandBarControl

Menampilkan Ribbon Bar.

Set RibbonBar = CommandBars.AddRibbonBar("The Ribbon")
RibbonBar.EnableDocking xtpFlagStretched
Set ControlFile = RibbonBar.AddSystemButton()
ControlFile.IconId = ID_SYSTEM_ICON

Isi dari tombol menu bericom

ControlFile.CommandBar.Controls.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_LOGOUT, "Lo&gout", False, False
Set Atur = ControlFile.CommandBar.Controls.Add(XtremeCommandBars.XTPControlType.xtpControlButton, ID_LOGOUT, "Lo&gout", False, False)
Atur.Enabled = False

Kelima, membuat Option Menu

ControlFile.CommandBar.SetIconSize 32, 32
Set ControlOptions = RibbonBar.Controls.Add(xtpControlPopup, 0, "&Options")
    ControlOptions.Flags = xtpFlagRightAlign
    Set Control = ControlOptions.CommandBar.Controls.Add(xtpControlPopup, 0, "&Change Skin")
        Control.CommandBar.Controls.Add xtpControlButton, ID_OPTIONS_STYLEBLUE, "&Blue"
        Control.CommandBar.Controls.Add xtpControlButton, ID_OPTIONS_STYLEBLACK, "B&lack"
        Control.CommandBar.Controls.Add xtpControlButton, ID_OPTIONS_STYLESILVER, "&Silver"
        Control.CommandBar.Controls.Add xtpControlButton, ID_OPTIONS_STYLEAQUA, "&Aqua"

Keenam, membuat Tabs, Group Toolbar, Toolbar

Set TabFile = RibbonBar.InsertTab(0, "&Pengaturan")
    TabFile.Id = ID_TAB_FILE
        Set GroupKon = TabFile.Groups.AddGroup("Konfigurasi", ID_GROUP_KON)
            GroupKon.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_KONBIODATA, "&Identitas Sekolah", False, False
            GroupKon.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_KONBG, "&Background", False, False
            GroupKon.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_KONTRANS, "&Transaksi", False, False
        Set GroupLog = TabFile.Groups.AddGroup("Sistem", ID_GROUP_LOG)
            GroupLog.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_GANTI, "&Ganti Password", False, False
            GroupLog.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_KUNCI, "Kunci &Sistem", False, False
            GroupLog.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_LOGOUT, "&Logout", False, False
        Set GroupKeluar = TabFile.Groups.AddGroup("Keluar", ID_GROUP_KELUAR)
            GroupKeluar.Add XtremeCommandBars.XTPControlType.xtpControlButton, ID_KELUAR, "&Keluar", False, False

Ketujuh, Load Icon

With CommandBars
    .Options.Animation = xtpAnimateRandom
    .Options.UseSharedImageList = False
    .AddImageList ImageList
    .Icons.MaskColor = vbWhite
    .Icons.AddIcon ImageList.ListImages(1).Picture, ID_GANTI, XtremeCommandBars.XTPImageState.xtpImageNormal
    .Icons.AddIcon ImageList.ListImages(9).Picture, ID_LOGOUT, XtremeCommandBars.XTPImageState.xtpImageNormal
    .Icons.AddIcon ImageList.ListImages(4).Picture, ID_KELUAR, XtremeCommandBars.XTPImageState.xtpImageNormal
    .Icons.AddIcon ImageList.ListImages(2).Picture, ID_KUNCI, XtremeCommandBars.XTPImageState.xtpImageNormal
    .Icons.AddIcon ImageList.ListImages(6).Picture, ID_KONBIODATA, XtremeCommandBars.XTPImageState.xtpImageNormal
    .Icons.AddIcon ImageList.ListImages(7).Picture, ID_KONBG, XtremeCommandBars.XTPImageState.xtpImageNormal
    .Icons.AddIcon ImageList.ListImages(8).Picture, ID_KONTRANS, XtremeCommandBars.XTPImageState.xtpImageNormal
    .Icons.AddIcon ImageList.ListImages(11).Picture, ID_KELOMPOK, XtremeCommandBars.XTPImageState.xtpImageNormal
End With

Kedelapan, Tooltiptext

Dim ToolTipContext As ToolTipContext
    Set ToolTipContext = CommandBars.ToolTipContext
    ToolTipContext.Style = xtpToolTipOffice2007
    ToolTipContext.ShowTitleAndDescription True, xtpToolTipIconNone
    ToolTipContext.ShowImage True, IMAGEBASE
    ToolTipContext.SetMargin 2, 2, 2, 2
    ToolTipContext.MaxTipWidth = 180
    ToolTipContext.ShowShadow = True

Terimakasih kepada fajar ijin nambah pustaka blog

#link sumber :: http://fajar-el-ridikc.blogspot.com/#ixzz3xlXrirUk

Iklan

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