Di sini menerima pembuatan Program Aplikasi, bila anda berminat bisa kontak lewat via Email rizal.lonly@gmail.com, dan bila ada link yang rusak segera hubungi admin, Terima kasih atas kunjungannya.

Script Code : Buat Form Blocker

Posted on
  • Tuesday, December 13, 2011
  • by
  • Rizal
  • in
  • Labels:
  • Di sini saya akan berbagi dengan Script Coding Program, Program yang digunakan dalam Script ini terutama Bahasa Pemprograman VB (VisualBasic), sebenarnya hampir sama dengan Bahasa Pemprograman Java dan Visual Foxpro, hanya memgganti sedikit perintah-perintahnya saja. Script Coding yang akan saya bagikan ini, tentang pemblokiran situs-situs baik itu situs yang mengandung virus yang dapat merusak PC maupun situs yang berbau porno. Jika anda berminat ingin belajar Bahasa Pemprograman ini, anda bisa mengikuti langkah-langkah berikut. Oya, anda tinggal mengklik menu dibawah ini!
    1. Forms
        -  frm_Main(frm_Main.frm)
        -  frm_Splash(frm_Splash.frm)
    2. Modules
        -  Fungsi(Fungsi.bas)
        -  Registry(Registry.bas)
        -  tray(tray.bas)
    3. User Controls
        -  XpButton(XpButton.ctl)

    --------------------------------------------------------------------------------------------------
    1.  Forms
         -  frm_Main
            Keterangan Gambar tentang Pengaturan Pemblokiran Berdasarkan Alamat Situs.

              Keterangan Gambar tentang Pengaturan Pemblokiran Berdasarkan Caption.

        Script Code :
    Private Sub cmd_add_Click()
    Dim cari As Long
    If Text1.Text = "" Then
    MsgBox "Anda belum memasukan situs yang akan diblokir", vbInformation + vbOKOnly, "(punya-rizal.blogspot.com)The Porn Blocker"
    Exit Sub
    End If
    For cari = 0 To List1.ListCount - 1
    If Text1.Text = List1.list(cari) Then
    MsgBox "Situs yang anda masukan sudah ada dalam daftar situs yang diblokir", vbInformation + vbOKOnly, "(punya-rizal.blogspot.com)The Porn Blocker"
    Exit Sub
    End If
    Text1.SetFocus
    Next
    List1.AddItem Text1.Text
    Text1.Text = ""
    SaveFileHost List1, GetSystemPath & "\drivers\etc\Hosts"
    lbl_jml.Caption = List1.ListCount
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_addcap_Click()
    Dim cari As Long
    If txt_blokcap.Text = "" Then
    MsgBox "Anda belum memasukan caption yang akan diblokir", vbInformation + vbOKOnly, "(punya-rizal.blogspot.com)The Porn Blocker"
    Exit Sub
    End If
    For cari = 0 To lst_cap.ListCount - 1
    If txt_blokcap.Text = lst_cap.list(cari) Then
    MsgBox "Caption yang anda masukan sudah ada dalam daftar caption yang diblokir", vbInformation + vbOKOnly, "(punya-rizal.blogspot.com)The Porn Blocker"
    txt_blokcap.SetFocus
    Exit Sub
    End If
    Next
    lst_cap.AddItem txt_blokcap.Text
    txt_blokcap.Text = ""
    SaveCaption lst_cap, App.Path & "\list.txt"
    lbl_jmlcap.Caption = lst_cap.ListCount
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_atur_Click()
    Frame1.Visible = True
    Frame1.Enabled = True
    Framecap.Visible = False
    Framecap.Enabled = False
    lbl_jml.Caption = List1.ListCount
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_aturcap_Click()
    Frame1.Visible = False
    Frame1.Enabled = False
    Framecap.Visible = True
    Framecap.Enabled = True
    lbl_jmlcap.Caption = lst_cap.ListCount
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_delcap_Click()
    If lst_cap.ListIndex = -1 Then
    MsgBox "Anda belum memilih situs yang akan dihapus", vbInformation + vbOKOnly, "(punya-rizal.blogspot.com)The Porn Blocker"
    Exit Sub
    End If
    lst_cap.RemoveItem (lst_cap.ListIndex)
    HapusCaption lst_cap, App.Path & "\list.txt"
    Call cmd_refreshcap_Click
    lbl_jmlcap.Caption = lst_cap.ListCount
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_exit_Click()
    If MsgBox("Apakah anda yakin ingin keluar dari aplikasi ini?" & vbNewLine & "Keluar dari aplikasi ini berarti proses pemblokiran dihentikan", vbInformation + vbYesNo, "(punya-rizal.blogspot.com)The Porn Blocker") = vbYes Then
    TrayDelete
    backup
    Kill App.Path & "\kill.bat"
    End
    Else
    Exit Sub
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_hapus_Click()
    If List1.ListIndex = -1 Then
    MsgBox "Anda belum memilih situs yang akan dihapus", vbInformation + vbOKOnly, "(punya-rizal.blogspot.com)The Porn Blocker"
    Exit Sub
    End If
    List1.RemoveItem (List1.ListIndex)
    hapus List1, GetSystemPath & "\drivers\etc\Hosts"
    Call cmd_refresh_Click
    lbl_jml.Caption = List1.ListCount
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_hide_Click()
    App.TaskVisible = False
    ilang.Enabled = True
    frm_main.Hide
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub cmd_refresh_Click()
    List1.Clear
    LoadFileHost List1, GetSystemPath & "\drivers\etc\Hosts"
    Text1.Text = ""
    Text1.SetFocus
    lbl_jml.Caption = List1.ListCount
    End Sub
    Private Sub cmd_refreshcap_Click()
    lst_cap.Clear
    Load_Caption lst_cap, App.Path & "\list.txt"
    txt_blokcap.Text = ""
    txt_blokcap.SetFocus
    lbl_jmlcap.Caption = lst_cap.ListCount
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_DblClick()
    MsgBox "Copyright (C) YaDoY SofTwaRe DeVeLoPmEnT 2007", vbOKOnly + vbInformation, "(punya-rizal.blogspot.com)The Porn Blocker"
    End Sub
    Private Sub Form_Load()
    mulai
    TrayAdd hwnd, Picture1.Picture, "The Porn Blocker", MouseMove
    Frame1.Visible = True
    Frame1.Enabled = True
    Framecap.Visible = False
    Framecap.Enabled = False
    LoadFileHost List1, GetSystemPath & "\drivers\etc\Hosts"
    lbl_jml.Caption = List1.ListCount
    lst_cap.Clear
    Load_Caption lst_cap, App.Path & "\list.txt"
    lbl_jmlcap.Caption = lst_cap.ListCount
    CreateStringValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", REG_SZ, "Porn Blocker", "C:\Program Files\Porn_Blocker\Porn Blocker.exe"
    buat_kill
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_Unload(Cancel As Integer)
    TrayDelete
    backup
    Kill App.Path & "\kill.bat"
    End
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Frame1_Click()
    Text1.SetFocus
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Dim cEvent As Single
    cEvent = x / Screen.TwipsPerPixelX
    Select Case cEvent
    Case MouseMove
    Debug.Print "MouseMove"
    Case LeftUp
    Debug.Print "Left Up"
    Case LeftDown
    Debug.Print "LeftDown"
    Case LeftDbClick
    Debug.Print "LeftDbClick"
    Case MiddleUp
    Debug.Print "MiddleUp"
    Case MiddleDown
    Debug.Print "MiddleDown"
    Case MiddleDbClick
    Debug.Print "MiddleDbClick"
    Case RightUp
    Debug.Print "RightUp": PopupMenu mnu
    Case RightDown
    Debug.Print "RightDown"
    Case RightDbClick
    Debug.Print "RightDbClick"
    End Select
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub ilang_Timer()
    On Error Resume Next
    Dim bunuh As Long
    frm_main.show
    App.TaskVisible = False
    For bunuh = 0 To lst_cap.ListCount - 1
    kill_IE (lst_cap.list(bunuh))
    Tonjok (lst_cap.list(bunuh))
    Next
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub kill_task_Timer()
    Hajar "TASK MANAGER"
    Hajar "CMD"
    Hajar "Command Prompt"
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub show_Click()
    frm_main.show
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub buat_kill()
    Open App.Path & "\kill.bat" For Output As #1
    Print #1, "taskkill /f /im iexplore.exe"
    Close #1
    End Sub
         -  frm_Splash
        Script Code :
    Private Sub Form_Load()
    ProgressBar1.Value = ProgressBar1.Min
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub Timer1_Timer()
    ProgressBar1.Value = ProgressBar1.Value + 5
    If ProgressBar1.Value = 10 Then
    Label3.Caption = "Application Initialazing"
    End If
    If ProgressBar1.Value = 40 Then
    Label3.Caption = "Loading Database"
    End If
    If ProgressBar1.Value = 80 Then
    Label3.Caption = "Loading Complete"
    End If
    If ProgressBar1.Value >= ProgressBar1.Max Then
    Unload Me
    frm_main.show
    End If
    End Sub
    2.  Modules
         -  Fungsi

        Script Code :
    Public Declare Function GetSystemDirectory Lib "kernel32.dll" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    Public Declare Function GetForegroundWindow Lib "user32" () As Long
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Public Const WM_CLOSE = &H10
    Public IP As String, Situs As String
    Public x As String, Judul As String
    -----------------------------------------------------------------------------------------
    Public Sub LoadFileHost(list As ListBox, Namafile As String)
    Dim linestr As String, tmp() As String
    On Error Resume Next
    Open Namafile For Input As #1
    While Not EOF(1)
    Line Input #1, linestr
    tmp = Split(linestr, " ")
    IP = tmp(0)
    Situs = tmp(1)
    DoEvents
    list.AddItem Situs
    Wend
    Close #1
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub Load_Caption(list As ListBox, Namafile As String)
    Dim linestr As String, tmp() As String
    On Error Resume Next
    Open Namafile For Input As #1
    While Not EOF(1)
    Line Input #1, linestr
    Judul = linestr
    DoEvents
    list.AddItem Judul
    Wend
    Close #1
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub SaveFileHost(list As ListBox, place As String)
    On Error Resume Next
    Dim simpan As Long
    Open place For Output As #1
    For simpan = 0 To list.ListCount - 1
    Print #1, "127.0.0.1 " & list.list(simpan)
    Next
    Close #1
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub SaveCaption(list As ListBox, place As String)
    On Error Resume Next
    Dim simpan As Long
    Open place For Output As #1
    For simpan = 0 To list.ListCount - 1
    Print #1, list.list(simpan)
    Next
    Close #1
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub hapus(list As ListBox, place As String)
    On Error Resume Next
    Dim hapus As Long
    Open place For Output As #1
    For hapus = 0 To list.ListCount - 1
    Print #1, "127.0.0.1 " & list.list(hapus)
    Next
    Close #1
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub HapusCaption(list As ListBox, place As String)
    On Error Resume Next
    Dim hapus As Long
    Open place For Output As #1
    For hapus = 0 To list.ListCount - 1
    Print #1, list.list(hapus)
    Next
    Close #1
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub backup()
    FileCopy GetSystemPath & "\Drivers\etc\Hosts", App.Path & "\back.txt"
    Open GetSystemPath & "\Drivers\etc\Hosts" For Output As #1
    Print #1, "127.0.0.1 localhost"
    Close #1
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub mulai()
    On Error Resume Next
    FileCopy App.Path & "\back.txt", GetSystemPath & "\Drivers\etc\Hosts"
    FileCopy App.Path & "back.txt", GetSystemPath & "\Drivers\etc\Hosts"
    End Sub
    -----------------------------------------------------------------------------------------
    Public Function GetSystemPath() As String
    On Error Resume Next
    Dim Buffer As String * 255
    Dim x As Long
    x = GetSystemDirectory(Buffer, 255)
    GetSystemPath = Left(Buffer, x) & "\"
    End Function
    -----------------------------------------------------------------------------------------
    Public Function Hajar(target As String)
    Dim h As Long
    Dim t As String * 255
    h = GetForegroundWindow
    GetWindowText h, t, 255
    If InStr(UCase(t), UCase(target)) > 0 Then
    SendMessage h, WM_CLOSE, 0, 0
    MsgBox "Maaf perintah yang coba anda jalankan telah dinonaktifkan oleh administrator komputer ini. Silahkan menghubungi administrator untuk mengaktifkannya kembali", vbInformation + vbOKOnly, "Pembatasan"
    End If
    End Function
    -----------------------------------------------------------------------------------------
    Public Sub Tonjok(target As String)
    Dim h As Long
    Dim t As String * 255
    h = GetForegroundWindow
    GetWindowText h, t, 255
    If InStr(UCase(t), UCase(target)) > 0 Then
    SendMessage h, WM_CLOSE, 0, 0
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub kill_IE(target As String)
    Dim h As Long
    Dim t As String * 255
    h = GetForegroundWindow
    GetWindowText h, t, 255
    If InStr(UCase(t), UCase(target)) > 0 Then
    Shell App.Path & "\kill.bat", vbHide
    End If
    End Sub
        Registry

        Script Code :
    Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
    Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
    Public Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
    Public Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
    Public Const REG_DWORD = 4
    Enum REG
    HKEY_CURRENT_USER = &H80000001
    HKEY_CLASSES_ROOT = &H80000000
    HKEY_CURRENT_CONFIG = &H80000005
    HKEY_LOCAL_MACHINE = &H80000002
    HKEY_USERS = &H80000003
    End Enum
    Enum TypeStringValue
    REG_SZ = 1
    REG_EXPAND_SZ = 2
    REG_MULTI_SZ = 7
    End Enum
    -----------------------------------------------------------------------------------------
    Public Function DeleteValue(hKey As REG, Subkey As String, lpValName As String) As Long
    Dim Ret As Long
    On Error Resume Next
    RegOpenKey hKey, Subkey, Ret
    DeleteValue = RegDeleteValue(Ret, lpValName)
    RegCloseKey Ret
    End Function
    -----------------------------------------------------------------------------------------
    Public Function CreateStringValue(hKey As REG, Subkey As String, RTypeStringValue As TypeStringValue, strValueName As String, strData As String) As Long
    On Error Resume Next
    Dim Ret As Long
    RegCreateKey hKey, Subkey, Ret
    CreateStringValue = RegSetValueEx(Ret, strValueName, 0, RTypeStringValue, ByVal strData, Len(strData))
    RegCloseKey Ret
    End Function
        -  tray

        Script Code :
    Option Explicit
    Const NIF_MESSAGE As Long = &H1
    Const NIF_ICON As Long = &H2
    Const NIF_TIP As Long = &H4
    Const NIM_ADD As Long = &H0
    Const NIM_MODIFY As Long = &H1
    Const NIM_DELETE As Long = &H2
    Private Type NOTIFYICONDATA
    cbSize As Long
    hwnd As Long
    uId As Long
    uFlags As Long
    uCallBackMessage As Long
    hIcon As Long
    szTip As String * 64
    End Type
    Public Enum TrayRetunEventEnum
    MouseMove = &H200
    LeftUp = &H202
    LeftDown = &H201
    LeftDbClick = &H203
    RightUp = &H205
    RightDown = &H204
    RightDbClick = &H206
    MiddleUp = &H208
    MiddleDown = &H207
    MiddleDbClick = &H209
    End Enum
    Public Enum ModifyItemEnum
    ToolTip = 1
    Icon = 2
    End Enum
    Private TrayIcon As NOTIFYICONDATA
    Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
    -----------------------------------------------------------------------------------------
    Public Sub TrayAdd(hwnd As Long, Icon As Picture, _
    ToolTip As String, ReturnCallEvent As TrayRetunEventEnum)

    With TrayIcon
    .cbSize = Len(TrayIcon)
    .hwnd = hwnd
    .uId = vbNull
    .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    .uCallBackMessage = ReturnCallEvent
    .hIcon = Icon
    .szTip = ToolTip & vbNullChar
    End With
    Shell_NotifyIcon NIM_ADD, TrayIco
    n End Sub
    -----------------------------------------------------------------------------------------
    Public Sub TrayDelete()
    Shell_NotifyIcon NIM_DELETE, TrayIcon
    End Sub
    -----------------------------------------------------------------------------------------
    Public Sub TrayModify(Item As ModifyItemEnum, vNewValue As Variant)
    Select Case Item
    Case ToolTip
    TrayIcon.szTip = vNewValue & vbNullChar
    Case Icon
    TrayIcon.hIcon = vNewValue
    End Select
    Shell_NotifyIcon NIM_MODIFY, TrayIcon
    End Sub
    3.  User Controls
         -  XpButton
        Script Code :
    Option Explicit
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
    Private Declare Function FrameRect Lib "user32" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As Long
    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
    Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal Y As Long, ByVal crColor As Long) As Long
    Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long
    Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal Y As Long) As Long
    Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
    Private Const PS_SOLID = 0
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
    Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
    Private Const RGN_DIFF = 4
    Private Declare Function GetTextColor Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As Long) As Long
    Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    Private Const DT_CALCRECT = &H400
    Private Const DT_WORDBREAK = &H10
    Private Const DT_CENTER = &H1
    Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type
    Private Type POINTAPI
    x As Long
    Y As Long
    End Type
    Public Event Click()
    Public Event MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Public Event MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Public Event MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
    Public Event KeyPress(KeyAscii As Integer)
    Public Event KeyDown(KeyCode As Integer, Shift As Integer)
    Public Event KeyUp(KeyCode As Integer, Shift As Integer)
    Public Event MouseOver()
    Public Event MouseOut()
    Private rc As RECT
    Private W As Long, h As Long
    Private rgMain As Long, rgn1 As Long
    Private isOver As Boolean
    Private flgHover As Integer
    Private flgFocus As Boolean
    Private LastButton As Integer
    Private LastKey As Integer
    Private r As Long, l As Long, t As Long, b As Long
    Private mEnabled As Boolean
    Private mCaption As String
    Private mForeHover As OLE_COLOR
    -----------------------------------------------------------------------------------------
    Private Sub DrawButton()
    Dim pt As POINTAPI, pen As Long, hpen As Long
    With UserControl
    hpen = CreatePen(PS_SOLID, 1, RGB(122, 149, 168))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, t + 1, pt
    LineTo .hdc, l + 2, t
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(37, 87, 131))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 2, t, pt
    LineTo .hdc, l, t + 2
    SelectObject .hdc, pen
    DeleteObject hpen
    SetPixel .hdc, l, t + 2, RGB(37, 87, 131)
    SetPixel .hdc, l + 1, t + 2, RGB(191, 206, 220)
    SetPixel .hdc, l + 2, t + 1, RGB(192, 207, 221)
    hpen = CreatePen(PS_SOLID, 1, RGB(0, 60, 116))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 3, t, pt
    LineTo .hdc, r - 2, t
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(37, 87, 131))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, r - 2, t, pt
    LineTo .hdc, r + 1, t + 3
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(122, 149, 168))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, r - 1, t, pt
    LineTo .hdc, r, t + 2
    SetPixel .hdc, r, t + 1, RGB(122, 149, 168)
    SetPixel .hdc, r - 2, t + 1, RGB(213, 223, 232)
    SetPixel .hdc, r - 1, t + 2, RGB(191, 206, 219)
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(0, 60, 116))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, r, t + 3, pt
    LineTo .hdc, r, b - 3
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(37, 87, 131))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, r, b - 3, pt
    LineTo .hdc, r - 3, b
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(122, 149, 168))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, r, b - 2, pt
    LineTo .hdc, r - 2, b
    SetPixel .hdc, r - 2, b - 2, RGB(177, 183, 182)
    SetPixel .hdc, r - 1, b - 3, RGB(182, 189, 189)
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(0, 60, 116))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 3, b - 1, pt
    LineTo .hdc, r - 2, b - 1
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(37, 87, 131))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, b - 3, pt
    LineTo .hdc, l + 3, b
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(122, 149, 168))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, b - 2, pt
    LineTo .hdc, l + 2, b
    SetPixel .hdc, l + 1, b - 3, RGB(191, 199, 202)
    SetPixel .hdc, l + 2, b - 2, RGB(163, 174, 180)
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(0, 60, 116))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, t + 3, pt
    LineTo .hdc, l, b - 3
    SelectObject .hdc, pen
    DeleteObject hpen
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub DrawFocus()
    Dim pt As POINTAPI, pen As Long, hpen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    With UserControl
    hpen = CreatePen(PS_SOLID, 1, RGB(206, 231, 251))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 2, t + 1, pt
    LineTo .hdc, r - 1, t + 1
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(188, 212, 246))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 1, t + 2, pt
    LineTo .hdc, r, t + 2
    SelectObject .hdc, pen
    DeleteObject hpen
    ColorR = 186
    ColorG = 211
    ColorB = 246
    For i = t + 3 To b - 4 Step 1
    hpen = CreatePen(PS_SOLID, 2, RGB(ColorR, ColorG, ColorB))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 2, i, pt
    LineTo .hdc, l + 2, i + 1
    MoveToEx .hdc, r - 1, i, pt
    LineTo .hdc, r - 1, i + 1
    SelectObject .hdc, pen
    DeleteObject hpen
    If ColorB >= 228 Then
    ColorR = ColorR - 4
    ColorG = ColorG - 3
    ColorB = ColorB - 1
    End If
    Next i
    hpen = CreatePen(PS_SOLID, 1, RGB(ColorR, ColorG, ColorB))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 1, b - 3, pt
    LineTo .hdc, r - 1, b - 3
    SelectObject .hdc, pen
    DeleteObject hpen
    SetPixel .hdc, l + 2, b - 2, RGB(77, 125, 193)
    hpen = CreatePen(PS_SOLID, 1, RGB(97, 125, 229))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 3, b - 2, pt
    LineTo .hdc, r - 2, b - 2
    SetPixel .hdc, r - 2, b - 2, RGB(77, 125, 193)
    SelectObject .hdc, pen
    DeleteObject hpen
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub DrawHighlight()
    Dim pt As POINTAPI, pen As Long, hpen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    With UserControl
    hpen = CreatePen(PS_SOLID, 1, RGB(255, 240, 207))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 2, t + 1, pt
    LineTo .hdc, r - 1, t + 1
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(253, 216, 137))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 1, t + 2, pt
    LineTo .hdc, r, t + 2
    SelectObject .hdc, pen
    DeleteObject hpen
    ColorR = 254
    ColorG = 223
    ColorB = 154
    For i = t + 2 To b - 3 Step 1
    hpen = CreatePen(PS_SOLID, 1, RGB(ColorR, ColorG, ColorB))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 1, i, pt
    LineTo .hdc, l + 1, i + 1
    MoveToEx .hdc, r - 1, i, pt
    LineTo .hdc, r - 1, i + 1
    SelectObject .hdc, pen
    DeleteObject hpen
    If ColorB >= 49 Then
    ColorR = ColorR - 1
    ColorG = ColorG - 3
    ColorB = ColorB - 7
    End If
    Next i
    ColorR = 252
    ColorG = 210
    ColorB = 121
    For i = t + 3 To b - 3 Step 1
    hpen = CreatePen(PS_SOLID, 1, RGB(ColorR, ColorG, ColorB))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 2, i, pt
    LineTo .hdc, l + 2, i + 1
    MoveToEx .hdc, r - 2, i, pt
    LineTo .hdc, r - 2, i + 1
    SelectObject .hdc, pen
    DeleteObject hpen
    If ColorB >= 57 Then
    ColorR = ColorR - 1
    ColorG = ColorG - 4
    ColorB = ColorB - 8
    End If
    Next i
    hpen = CreatePen(PS_SOLID, 1, RGB(ColorR, ColorG, ColorB))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 3, b - 3, pt
    LineTo .hdc, r, b - 3
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(229, 151, 0))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l + 2, b - 2, pt
    LineTo .hdc, r - 1, b - 2
    SelectObject .hdc, pen
    DeleteObject hpen
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub DrawButtonFace()
    Dim pt As POINTAPI, pen As Long, hpen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    With UserControl
    .AutoRedraw = True
    .Cls
    .ScaleMode = 3
    ColorR = 255
    ColorG = 255
    ColorB = 253
    For i = t + 3 To b - 3 Step 1
    hpen = CreatePen(PS_SOLID, 1, RGB(ColorR, ColorG, ColorB))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, i, pt
    LineTo .hdc, r, i
    SelectObject .hdc, pen
    DeleteObject hpen
    If ColorB >= 230 Then
    ColorR = ColorR - 1
    ColorG = ColorG - 1
    ColorB = ColorB - 1
    End If
    Next i
    hpen = CreatePen(PS_SOLID, 1, RGB(214, 208, 197))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, b - 2, pt
    LineTo .hdc, r, b - 2
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(226, 223, 214))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, b - 3, pt
    LineTo .hdc, r, b - 3
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(236, 235, 230))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, b - 4, pt
    LineTo .hdc, r, b - 4
    SelectObject .hdc, pen
    DeleteObject hpen
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub DrawButtonDown()
    Dim pt As POINTAPI, pen As Long, hpen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    With UserControl
    .AutoRedraw = True
    .Cls
    .ScaleMode = 3
    ColorR = 239
    ColorG = 238
    ColorB = 231
    For i = t + 3 To b - 2 Step 4
    hpen = CreatePen(PS_SOLID, 4, RGB(ColorR, ColorG, ColorB))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, i, pt
    LineTo .hdc, r, i
    SelectObject .hdc, pen
    DeleteObject hpen
    If ColorB >= 218 Then
    ColorR = ColorR - 1
    ColorG = ColorG - 1
    ColorB = ColorB - 1
    End If
    Next i
    hpen = CreatePen(PS_SOLID, 1, RGB(209, 204, 192))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, t + 1, pt
    LineTo .hdc, r, t + 1
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(220, 216, 207))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, t + 2, pt
    LineTo .hdc, r, t + 2
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(234, 233, 227))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, b - 3, pt
    LineTo .hdc, r, b - 3
    SelectObject .hdc, pen
    DeleteObject hpen
    hpen = CreatePen(PS_SOLID, 1, RGB(242, 241, 238))
    pen = SelectObject(.hdc, hpen)
    MoveToEx .hdc, l, b - 2, pt
    LineTo .hdc, r, b - 2
    SelectObject .hdc, pen
    DeleteObject hpen
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub DrawButtonDisabled()
    Dim pt As POINTAPI, pen As Long, hpen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    Dim hBrush As Long
    With UserControl
    .AutoRedraw = True
    .Cls
    .ScaleMode = 3
    hBrush = CreateSolidBrush(RGB(245, 244, 234))
    FillRect UserControl.hdc, rc, hBrush
    DeleteObject hBrush
    hBrush = CreateSolidBrush(RGB(201, 199, 186))
    FrameRect UserControl.hdc, rc, hBrush
    DeleteObject hBrush
    SetPixel .hdc, l, t + 1, RGB(216, 213, 199)
    SetPixel .hdc, l + 1, t + 1, RGB(216, 213, 199)
    SetPixel .hdc, l + 1, t, RGB(216, 213, 199)
    SetPixel .hdc, l + 1, t + 2, RGB(234, 233, 222)
    SetPixel .hdc, l + 2, t + 1, RGB(234, 233, 222)
    SetPixel .hdc, r - 1, t, RGB(216, 213, 199)
    SetPixel .hdc, r - 1, t + 1, RGB(216, 213, 199)
    SetPixel .hdc, r, t + 1, RGB(216, 213, 199)
    SetPixel .hdc, r - 2, t + 1, RGB(234, 233, 222)
    SetPixel .hdc, r - 1, t + 2, RGB(234, 233, 222)
    SetPixel .hdc, l, b - 2, RGB(216, 213, 199)
    SetPixel .hdc, l + 1, b - 2, RGB(216, 213, 199)
    SetPixel .hdc, l + 1, b - 1, RGB(216, 213, 199)
    SetPixel .hdc, l + 1, b - 3, RGB(234, 233, 222)
    SetPixel .hdc, l + 2, b - 2, RGB(234, 233, 222)
    SetPixel .hdc, r, b - 2, RGB(216, 213, 199)
    SetPixel .hdc, r - 1, b - 2, RGB(216, 213, 199)
    SetPixel .hdc, r - 1, b - 1, RGB(216, 213, 199)
    SetPixel .hdc, r - 1, b - 3, RGB(234, 233, 222)
    SetPixel .hdc, r - 2, b - 2, RGB(234, 233, 222)
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub DrawButton2()
    Dim pt As POINTAPI, pen As Long, hpen As Long
    Dim i As Long, ColorR As Long, ColorG As Long, ColorB As Long
    Dim hBrush As Long
    With UserControl
    hBrush = CreateSolidBrush(RGB(0, 60, 116))
    FrameRect UserControl.hdc, rc, hBrush
    DeleteObject hBrush
    SetPixel .hdc, l, t + 1, RGB(122, 149, 168)
    SetPixel .hdc, l + 1, t + 1, RGB(37, 87, 131)
    SetPixel .hdc, l + 1, t, RGB(122, 149, 168)
    SetPixel .hdc, r - 1, t, RGB(122, 149, 168)
    SetPixel .hdc, r - 1, t + 1, RGB(37, 87, 131)
    SetPixel .hdc, r, t + 1, RGB(122, 149, 168)
    SetPixel .hdc, l, b - 2, RGB(122, 149, 168)
    SetPixel .hdc, l + 1, b - 2, RGB(37, 87, 131)
    SetPixel .hdc, l + 1, b - 1, RGB(122, 149, 168)
    SetPixel .hdc, r, b - 2, RGB(122, 149, 168)
    SetPixel .hdc, r - 1, b - 2, RGB(37, 87, 131)
    SetPixel .hdc, r - 1, b - 1, RGB(122, 149, 168)
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub RedrawButton(Optional ByVal Stat As Integer = -1)
    If mEnabled Then
    If Stat = 1 And LastButton = 1 Then
    DrawButtonDown
    Else
    DrawButtonFace
    If isOver = True Then
    DrawHighlight
    Else
    If flgFocus = True Then
    DrawFocus
    End If
    End If
    End If
    DrawButton2
    Else
    DrawButtonDisabled
    End If
    DrawCaption
    MakeRegion
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub DrawCaption()
    Dim vh As Long, rcTxt As RECT
    With UserControl
    GetClientRect .hwnd, rcTxt
    If mEnabled Then
    If isOver Then
    SetTextColor .hdc, mForeHover
    Else
    SetTextColor .hdc, .ForeColor
    End If
    Else
    SetTextColor .hdc, RGB(161, 161, 146)
    End If
    vh = DrawText(.hdc, mCaption, Len(mCaption), rcTxt, DT_CALCRECT Or DT_CENTER Or DT_WORDBREAK)
    SetRect rcTxt, 0, (.ScaleHeight * 0.5) - (vh * 0.5), .ScaleWidth, (.ScaleHeight * 0.5) + (vh * 0.5)
    DrawText .hdc, mCaption, Len(mCaption), rcTxt, DT_CENTER Or DT_WORDBREAK
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub HoverTimer_Timer()
    If Not isMouseOver Then
    HoverTimer.Enabled = False
    isOver = False
    flgHover = 0
    RedrawButton 0
    RaiseEvent MouseOut
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_AccessKeyPress(KeyAscii As Integer)
    LastButton = 1
    Call UserControl_Click
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_Click()
    If LastButton = 1 Then
    RedrawButton 0
    UserControl.Refresh
    RaiseEvent Click
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_DblClick()
    If LastButton = 1 Then
    Call UserControl_MouseDown(1, 0, 0, 0)
    SetCapture hwnd
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_GotFocus()
    flgFocus = True
    RedrawButton 1
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_InitProperties()
    Set UserControl.Font = Ambient.Font
    mCaption = Ambient.DisplayName
    mEnabled = True
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
    LastKey = KeyCode
    Select Case KeyCode
    Case vbKeySpace, vbKeyReturn
    RedrawButton 1
    Case vbKeyLeft, vbKeyRight
    SendKeys "{Tab}"
    Case vbKeyDown, vbKeyUp
    SendKeys "+{Tab}"
    End Select
    RaiseEvent KeyDown(KeyCode, Shift)
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_KeyPress(KeyAscii As Integer)
    RaiseEvent KeyPress(KeyAscii)
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer)
    If ((KeyCode = vbKeySpace) And (LastKey = vbKeySpace)) Or ((KeyCode = vbKeyReturn) And (LastKey = vbKeyReturn)) Then
    RedrawButton 0
    LastButton = 1
    UserControl.Refresh
    RaiseEvent Click
    End If
    RaiseEvent KeyUp(KeyCode, Shift)
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_LostFocus()
    flgFocus = False
    RedrawButton 0
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
    If mEnabled = True Then
    LastButton = Button
    UserControl.Refresh
    If Button <> 2 Then RedrawButton 1
    RaiseEvent MouseDown(Button, Shift, x, Y)
    End If
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    If Button < 2 Then
    If Not isMouseOver Then
    If flgHover = 0 Then Exit Sub
    RedrawButton 0
    Else
    If flgHover = 1 Then Exit Sub
    flgHover = 1
    If Button = 0 And Not isOver Then
    HoverTimer.Enabled = True
    isOver = True
    flgHover = 0
    RedrawButton 0
    RaiseEvent MouseOver
    ElseIf Button = 1 Then
    isOver = True
    RedrawButton 1
    isOver = False
    End If
    End If
    End If
    RaiseEvent MouseMove(Button, Shift, x, Y)
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
    RedrawButton 0
    UserControl.Refresh
    RaiseEvent MouseUp(Button, Shift, x, Y)
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_Resize()
    GetClientRect UserControl.hwnd, rc
    With rc
    r = .Right - 1: l = .Left: t = .Top: b = .Bottom
    W = .Right: h = .Bottom
    End With
    RedrawButton 0
    End Sub
    -----------------------------------------------------------------------------------------
    Private Function isMouseOver() As Boolean
    Dim pt As POINTAPI
    GetCursorPos pt
    isMouseOver = (WindowFromPoint(pt.x, pt.Y) = hwnd)
    End Function
    -----------------------------------------------------------------------------------------
    Private Sub MakeRegion()
    DeleteObject rgMain
    rgMain = CreateRectRgn(0, 0, W, h)
    rgn1 = CreateRectRgn(0, 0, 1, 1)
    CombineRgn rgMain, rgMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(0, h - 1, 1, h)
    CombineRgn rgMain, rgMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(W - 1, 0, W, 1)
    CombineRgn rgMain, rgMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    rgn1 = CreateRectRgn(W - 1, h - 1, W, h)
    CombineRgn rgMain, rgMain, rgn1, RGN_DIFF
    DeleteObject rgn1
    SetWindowRgn UserControl.hwnd, rgMain, True
    End Sub
    -----------------------------------------------------------------------------------------
    Public Property Get Enabled() As Boolean
    Enabled = mEnabled
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Let Enabled(ByVal NewValue As Boolean)
    mEnabled = NewValue
    PropertyChanged "Enabled"
    UserControl.Enabled = NewValue
    RedrawButton 0
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Get Font() As Font
    Set Font = UserControl.Font
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Set Font(ByVal NewValue As Font)
    Set UserControl.Font = NewValue
    RedrawButton 0
    PropertyChanged "Font"
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Get Caption() As String
    Caption = mCaption
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Let Caption(ByVal NewValue As String)
    mCaption = NewValue
    RedrawButton 0
    SetAccessKeys
    PropertyChanged "Caption"
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Get ForeColor() As OLE_COLOR
    ForeColor = UserControl.ForeColor
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Let ForeColor(ByVal NewValue As OLE_COLOR)
    UserControl.ForeColor = NewValue
    RedrawButton 0
    PropertyChanged "ForeColor"
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Get ForeHover() As OLE_COLOR
    ForeHover = mForeHover
    End Property
    -----------------------------------------------------------------------------------------
    Public Property Let ForeHover(ByVal NewValue As OLE_COLOR)
    mForeHover = NewValue
    PropertyChanged "ForeHover"
    End Property
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_Show()
    RedrawButton 0
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    With PropBag
    mEnabled = .ReadProperty("Enabled", True)
    Set UserControl.Font = .ReadProperty("Font", Ambient.Font)
    mCaption = .ReadProperty("Caption", Ambient.DisplayName)
    UserControl.ForeColor = .ReadProperty("ForeColor", Ambient.ForeColor)
    mForeHover = .ReadProperty("ForeHover", UserControl.ForeColor)
    End With
    UserControl.Enabled = mEnabled
    SetAccessKeys
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    With PropBag
    .WriteProperty "Enabled", mEnabled, True
    .WriteProperty "Font", UserControl.Font, Ambient.Font
    .WriteProperty "Caption", mCaption, Ambient.DisplayName
    .WriteProperty "ForeColor", UserControl.ForeColor
    .WriteProperty "ForeHover", mForeHover, Ambient.ForeColor
    End With
    End Sub
    -----------------------------------------------------------------------------------------
    Private Sub SetAccessKeys()
    Dim i As Long
    UserControl.AccessKeys = ""
    If Len(mCaption) > 1 Then
    i = InStr(1, mCaption, "&", vbTextCompare)
    If (i < Len(mCaption)) And (i > 0) Then
    If Mid$(mCaption, i + 1, 1) <> "&" Then
    UserControl.AccessKeys = LCase$(Mid$(mCaption, i + 1, 1))
    Else
    i = InStr(i + 2, mCaption, "&", vbTextCompare)
    If Mid$(mCaption, i + 1, 1) <> "&" Then
    UserControl.AccessKeys = LCase$(Mid$(mCaption, i + 1, 1))
    End If
    End If
    End If
    End If
    End Sub

    Baca Juga Artikel Terkait :

     
    Copyright © 2011 - 2012 Blogger templates by Rizal