www.pudn.com > VBkongjian.rar > Button.ctl


VERSION 5.00 
Begin VB.UserControl NiceButton  
   Alignable       =   -1  'True 
   Appearance      =   0  'Flat 
   AutoRedraw      =   -1  'True 
   BackColor       =   &H00E0E0E0& 
   BackStyle       =   0  '透明 
   ClientHeight    =   2865 
   ClientLeft      =   0 
   ClientTop       =   0 
   ClientWidth     =   5040 
   ClipBehavior    =   0  '无 
   ControlContainer=   -1  'True 
   DefaultCancel   =   -1  'True 
   HitBehavior     =   2  '使用画图 
   PropertyPages   =   "Button.ctx":0000 
   ScaleHeight     =   2865 
   ScaleWidth      =   5040 
   ToolboxBitmap   =   "Button.ctx":0011 
   Begin VB.PictureBox PicTmp  
      Appearance      =   0  'Flat 
      AutoRedraw      =   -1  'True 
      BackColor       =   &H80000005& 
      BorderStyle     =   0  'None 
      ForeColor       =   &H80000008& 
      Height          =   255 
      Left            =   840 
      ScaleHeight     =   255 
      ScaleWidth      =   255 
      TabIndex        =   2 
      Top             =   2400 
      Width           =   255 
   End 
   Begin VB.Timer Timer1  
      Interval        =   3 
      Left            =   2880 
      Top             =   960 
   End 
   Begin VB.Image Ico  
      Appearance      =   0  'Flat 
      Height          =   240 
      Left            =   120 
      Stretch         =   -1  'True 
      Top             =   600 
      Width           =   240 
   End 
   Begin VB.Label L1  
      Alignment       =   2  'Center 
      BackStyle       =   0  'Transparent 
      Caption         =   "Label1" 
      Height          =   180 
      Left            =   2040 
      TabIndex        =   1 
      Top             =   1800 
      Visible         =   0   'False 
      Width           =   1380 
   End 
   Begin VB.Shape Sh  
      BorderStyle     =   3  'Dot 
      DrawMode        =   6  'Mask Pen Not 
      Height          =   495 
      Left            =   360 
      Shape           =   4  'Rounded Rectangle 
      Top             =   1080 
      Width           =   2055 
   End 
   Begin VB.Label L  
      Alignment       =   2  'Center 
      BackStyle       =   0  'Transparent 
      Caption         =   "Button1" 
      Height          =   180 
      Left            =   0 
      TabIndex        =   0 
      Top             =   120 
      Width           =   1380 
   End 
   Begin VB.Image BT  
      Height          =   420 
      Left            =   0 
      Picture         =   "Button.ctx":0323 
      Stretch         =   -1  'True 
      Top             =   0 
      Width           =   1335 
   End 
End 
Attribute VB_Name = "NiceButton" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = True 
Attribute VB_PredeclaredId = False 
Attribute VB_Exposed = True 
Attribute VB_Ext_KEY = "PropPageWizardRun" ,"Yes" 
'缺省属性值: 
Const m_def_UsePicture = 0 
Const m_def_ButtonStyle = 0 
 
'属性变量: 
Dim m_UsePicture As Boolean 
Dim m_ButtonIcon As Picture 
Dim m_NoPicture As Picture 
Dim m_OnPicture As Picture 
Dim m_DownPicture As Picture 
'Dim m_ButtonIcon As Picture 
'Dim m_PicNoFocus As Picture 
'Dim m_PicGetFocus As Picture 
Dim m_ToolTipText As String 
Dim m_ButtonStyle As Integer 
'事件声明: 
  Private Const DSS_DISABLED As Long = &H20& 
  Private Const DSS_MONO As Long = &H80& 
  Private Const DSS_NORMAL As Long = &H0& 
  Private Const DSS_UNION As Long = &H10& 
  Private Const DST_BITMAP As Long = &H4& 
  Private Const DST_COMPLEX As Long = &H0& 
  Private Const DST_ICON As Long = &H3& 
  Private Const DST_PREFIXTEXT As Long = &H2& 
  Private Const DST_TEXT As Long = &H1& 
Event KeyDown(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyDown 
Attribute KeyDown.VB_Description = "当用户在拥有焦点的对象上按下任意键时发生。" 
Event KeyPress(KeyAscii As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyPress 
Attribute KeyPress.VB_Description = "当用户按下和释放 ANSI 键时发生。" 
Event KeyUp(KeyCode As Integer, Shift As Integer) 'MappingInfo=UserControl,UserControl,-1,KeyUp 
Attribute KeyUp.VB_Description = "当用户在拥有焦点的对象上释放键时发生。" 
Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDown 
Attribute MouseDown.VB_Description = "当用户在拥有焦点的对象上按下鼠标按钮时发生。" 
Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseMove 
Attribute MouseMove.VB_Description = "当用户移动鼠标时发生。" 
Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUp 
Attribute MouseUp.VB_Description = "当用户在拥有焦点的对象上释放鼠标发生。" 
Event Click() 'MappingInfo=UserControl,UserControl,-1,Click 
Event DblClick() 'MappingInfo=UserControl,UserControl,-1,DblClick 
Private OnFocus As Boolean 
Private Md As Boolean 
Private isover As Boolean 
Private LastButton As Integer 
Private LastKeyDown As Integer 
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long 
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long 
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long 
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long 
Private Declare Function DrawState Lib "user32" Alias "DrawStateA" (ByVal hdc As Long, ByVal hBrush As Long, ByVal lpDrawStateProc As Long, ByVal lParam As Long, ByVal wParam As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal n3 As Long, ByVal n4 As Long, ByVal un As Long) As Long 
Private Declare Function DrawStateText Lib "user32" Alias "DrawStateA" (ByVal hdc&, ByVal hBrush&, ByVal lpDrawStateProc&, ByVal lData$, ByVal wData&, ByVal X&, ByVal Y&, ByVal cx&, ByVal cy&, ByVal fFlags&) 
 
Private Sub UserControl_Resize() 
If Ico.Picture <> 0 Then 
Ico.Width = 240: Ico.Height = 240 
Ico.Left = 100 
Ico.Top = UserControl.Height / 2 - Ico.Height / 2 
Else 
Ico.Width = 0: Ico.Height = 0 
Ico.Left = 0 
Ico.Top = 0 
End If 
BT.Width = UserControl.Width 
BT.Height = UserControl.Height 
L.Width = UserControl.Width - (Ico.Left + Ico.Width) 
L.Top = UserControl.Height / 2 - L.Height / 2 
L.Left = Ico.Left + Ico.Width 
End Sub 
 
Private Sub BT_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseMove Button, Shift, X, Y 
End Sub 
 
Private Sub Image1_Click() 
 
End Sub 
 
Private Sub Ico_Click() 
UserControl_Click 
End Sub 
 
Private Sub Ico_DblClick() 
UserControl_DblClick 
 
End Sub 
 
Private Sub Ico_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseDown Button, Shift, X, Y 
 
End Sub 
 
Private Sub Ico_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseMove Button, Shift, X, Y 
 
End Sub 
 
Private Sub Ico_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseUp Button, Shift, X, Y 
 
End Sub 
 
Private Sub L_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseDown Button, Shift, X, Y 
End Sub 
 
Private Sub L_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseMove Button, Shift, X, Y 
End Sub 
 
Private Sub L_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseUp Button, Shift, X, Y 
End Sub 
 
Private Sub Timer1_Timer() 
If Not isMouseOver Then 
    Timer1.Enabled = False 
    isover = False 
    If Not OnFocus Then 
        If Not m_UsePicture Then 
            BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
        Else 
            BT.Picture = m_NoPicture 
        End If 
    Else 
        If Not m_UsePicture Then 
            BT.Picture = LoadResPicture(2100 + m_ButtonStyle, 0) 
        Else 
            BT.Picture = m_OnPicture 
        End If 
    End If 
End If 
End Sub 
 
Private Sub UserControl_AccessKeyPress(KeyAscii As Integer) 
    LastButton = 1 
    UserControl_Click 
End Sub 
 
Private Sub UserControl_EnterFocus() 
OnFocus = True 
If Md = False Then 
If Not m_UsePicture Then 
    BT.Picture = LoadResPicture(2100 + m_ButtonStyle, 0) 
Else 
    BT.Picture = m_OnPicture 
End If 
End If 
End Sub 
 
Private Sub UserControl_ExitFocus() 
If Not m_UsePicture Then 
    BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
Else 
    BT.Picture = m_NoPicture 
End If 
OnFocus = False 
End Sub 
 
Private Sub UserControl_Initialize() 
If Not m_UsePicture Then 
    BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
Else 
    BT.Picture = m_NoPicture 
End If 
End Sub 
' 
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 
    RaiseEvent MouseDown(Button, Shift, X, Y) 
If Not m_UsePicture Then 
    BT.Picture = LoadResPicture(2200 + m_ButtonStyle, 0) 
Else 
    BT.Picture = m_DownPicture 
End If 
L.Top = (UserControl.Height / 2 - L.Height / 2) + 20 
Ico.Top = (UserControl.Height / 2 - Ico.Height / 2) + 20 
Md = True 
End Sub 
 
Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) 
    RaiseEvent MouseMove(Button, Shift, X, Y) 
If Not isMouseOver Then 
If Not m_UsePicture Then 
    BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
Else 
    BT.Picture = m_NoPicture 
End If 
Else 
   If Button = 0 And Not isover Then 
            Timer1.Enabled = True 
            isover = True 
            If Not m_UsePicture Then 
                BT.Picture = LoadResPicture(2100 + m_ButtonStyle, 0) 
            Else 
                BT.Picture = m_OnPicture 
            End If 
   ElseIf Button = 1 Then 
            isover = True 
            If Not m_UsePicture Then 
                BT.Picture = LoadResPicture(2200 + m_ButtonStyle, 0) 
            Else 
                BT.Picture = m_DownPicture 
            End If 
            isover = False 
   End If 
End If 
End Sub 
Private Sub SetAccessKeys() 
Dim ampersandPos As Long, elTex As String 
 
'we first clear the AccessKeys property, and will be filled if one is found 
UserControl.AccessKeys = "" 
elTex = L.Caption 
If LenBB(elTex) > 1 Then 
    ampersandPos = InStr(1, elTex, "&", vbTextCompare) 
    If (ampersandPos < LenBB(elTex)) And (ampersandPos > 0) Then 
        If Mid$(elTex, ampersandPos + 1, 1) <> "&" Then 'if text is sonething like && then no access key should be assigned, so continue searching 
            UserControl.AccessKeys = LCase$(Mid$(elTex, ampersandPos + 1, 1)) 
        Else 'do only a second pass to find another ampersand character 
            ampersandPos = InStr(ampersandPos + 2, elTex, "&", vbTextCompare) 
            If Mid$(elTex, ampersandPos + 1, 1) <> "&" Then 
                UserControl.AccessKeys = LCase$(Mid$(elTex, ampersandPos + 1, 1)) 
            End If 
        End If 
    End If 
End If 
End Sub 
Private Function LenBB(ss As String) As Long 
LenBB = LenB(StrConv(ss, vbFromUnicode)) 
End Function 
 
' 
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 
RaiseEvent MouseUp(Button, Shift, X, Y) 
If Not OnFocus Then 
    If Not m_UsePicture Then 
        BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
    Else 
        BT.Picture = m_NoPicture 
    End If 
Else 
    If Not m_UsePicture Then 
        BT.Picture = LoadResPicture(2100 + m_ButtonStyle, 0) 
    Else 
        BT.Picture = m_OnPicture 
    End If 
End If 
Md = False 
L.Top = (UserControl.Height / 2 - L.Height / 2) 
Ico.Top = (UserControl.Height / 2 - Ico.Height / 2) 
End Sub 
Private Sub BT_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseDown Button, Shift, X, Y 
End Sub 
 
Private Sub BT_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) 
UserControl_MouseUp Button, Shift, X, Y 
End Sub 
Private Function isMouseOver() As Boolean 
Dim pt As POINTAPI 
 
GetCursorPos pt 
isMouseOver = (WindowFromPoint(pt.X, pt.Y) = hwnd) 
End Function 
 
 
 
'为用户控件初始化属性 
Private Sub UserControl_InitProperties() 
    m_ButtonStyle = m_def_ButtonStyle 
'    Set m_ButtonIcon = LoadPicture("") 
    Set m_ButtonIcon = LoadPicture("") 
    Set m_NoPicture = LoadPicture("") 
    Set m_OnPicture = LoadPicture("") 
    Set m_DownPicture = LoadPicture("") 
    m_UsePicture = m_def_UsePicture 
End Sub 
 
'从存贮器中加载属性值 
Private Sub UserControl_ReadProperties(PropBag As PropertyBag) 
 
    UserControl.Enabled = PropBag.ReadProperty("Enabled", True) 
    L.ForeColor = PropBag.ReadProperty("ForeColor", &H80000012) 
    Set L.Font = PropBag.ReadProperty("Font", Ambient.Font) 
    L.Caption = PropBag.ReadProperty("Caption", "Label1") 
    Set Picture = PropBag.ReadProperty("PicNoFocus", LoadResPicture(2000 + m_ButtonStyle, 0)) 
    Set Picture = PropBag.ReadProperty("PicGetFocus", LoadResPicture(2100 + m_ButtonStyle, 0)) 
    Set Picture = PropBag.ReadProperty("PicMouseDown", LoadResPicture(2200 + m_ButtonStyle, 0)) 
'    BT.ToolTipText = PropBag.ReadProperty("ToolTipText", "") 
    m_ButtonStyle = PropBag.ReadProperty("ButtonStyle", m_def_ButtonStyle) 
    Set Picture = PropBag.ReadProperty("ButtonIcon", Nothing) 
    If Not m_UsePicture Then 
        BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
    Else 
        BT.Picture = m_NoPicture 
    End If 
    SetAccessKeys 
'    Set m_ButtonIcon = PropBag.ReadProperty("ButtonIcon", Nothing) 
    Ico.Picture = m_ButtonIcon 
    UserControl_Resize 
    Set m_ButtonIcon = PropBag.ReadProperty("ButtonIcon", Nothing) 
    Set m_NoPicture = PropBag.ReadProperty("NoPicture", Nothing) 
    Set m_OnPicture = PropBag.ReadProperty("OnPicture", Nothing) 
    Set m_DownPicture = PropBag.ReadProperty("DownPicture", Nothing) 
    m_UsePicture = PropBag.ReadProperty("UsePicture", m_def_UsePicture) 
End Sub 
 
'将属性值写到存储器 
Private Sub UserControl_WriteProperties(PropBag As PropertyBag) 
 
    Call PropBag.WriteProperty("Enabled", UserControl.Enabled, True) 
    Call PropBag.WriteProperty("ForeColor", L.ForeColor, &H80000012) 
    Call PropBag.WriteProperty("Font", L.Font, Ambient.Font) 
    Call PropBag.WriteProperty("Caption", L.Caption, "Label1") 
    Call PropBag.WriteProperty("PicNoFocus", Picture, LoadResPicture(2000 + m_ButtonStyle, 0)) 
    Call PropBag.WriteProperty("PicGetFocus", Picture, LoadResPicture(2100 + m_ButtonStyle, 0)) 
    Call PropBag.WriteProperty("PicMouseDown", Picture, LoadResPicture(2200 + m_ButtonStyle, 0)) 
    Call PropBag.WriteProperty("ToolTipText", L.ToolTipText, "") 
    Call PropBag.WriteProperty("ButtonStyle", m_ButtonStyle, m_def_ButtonStyle) 
    If Not m_UsePicture Then 
        BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
    Else 
        BT.Picture = m_NoPicture 
    End If 
    Call PropBag.WriteProperty("ButtonIcon", Picture, Nothing) 
'    Call PropBag.WriteProperty("ButtonIcon", m_ButtonIcon, Nothing) 
    Call PropBag.WriteProperty("ButtonIcon", m_ButtonIcon, Nothing) 
    Call PropBag.WriteProperty("NoPicture", m_NoPicture, Nothing) 
    Call PropBag.WriteProperty("OnPicture", m_OnPicture, Nothing) 
    Call PropBag.WriteProperty("DownPicture", m_DownPicture, Nothing) 
    Call PropBag.WriteProperty("UsePicture", m_UsePicture, m_def_UsePicture) 
End Sub 
 
'注意!不要删除或修改下列被注释的行! 
'MappingInfo=L,L,-1,ForeColor 
Public Property Get ForeColor() As OLE_COLOR 
Attribute ForeColor.VB_Description = "返回/设置对象中文本和图形的前景色。" 
    ForeColor = L.ForeColor 
End Property 
 
Public Property Let ForeColor(ByVal New_ForeColor As OLE_COLOR) 
    L.ForeColor() = New_ForeColor 
    PropertyChanged "ForeColor" 
End Property 
 
'注意!不要删除或修改下列被注释的行! 
'MappingInfo=L,L,-1,Font 
Public Property Get Font() As Font 
Attribute Font.VB_Description = "返回一个 Font 对象。" 
Attribute Font.VB_UserMemId = -512 
    Set Font = L.Font 
End Property 
 
Public Property Set Font(ByVal New_Font As Font) 
    Set L.Font = New_Font 
    PropertyChanged "Font" 
End Property 
 
 
'注意!不要删除或修改下列被注释的行! 
'MappingInfo=L,L,-1,Caption 
Public Property Get Caption() As String 
Attribute Caption.VB_Description = "返回/设置对象的标题栏中或图标下面的文本。" 
    Caption = L.Caption 
End Property 
 
Public Property Let Caption(ByVal New_Caption As String) 
    L.Caption() = New_Caption 
    SetAccessKeys 
    PropertyChanged "Caption" 
End Property 
 
Private Sub UserControl_Click() 
RaiseEvent Click 
End Sub 
Private Sub BT_Click() 
UserControl_Click 
End Sub 
Private Sub L_Click() 
UserControl_Click 
End Sub 
 
Private Sub UserControl_DblClick() 
    RaiseEvent DblClick 
End Sub 
Private Sub BT_DblClick() 
UserControl_DblClick 
End Sub 
Private Sub L_DblClick() 
UserControl_DblClick 
End Sub 
'' 
''注意!不要删除或修改下列被注释的行! 
''MappingInfo=BT,BT,-1,ToolTipText 
'Public Property Get ToolTipText() As String 
'    ToolTipText = L.ToolTipText 
'End Property 
' 
 
'注意!不要删除或修改下列被注释的行! 
'MemberInfo=7,0,0,0 
Public Property Get Style() As MnuStyle 
Attribute Style.VB_Description = "按钮样式" 
    ButtonStyle = m_ButtonStyle 
End Property 
 
Public Property Let Style(ByVal New_ButtonStyle As MnuStyle) 
    m_ButtonStyle = New_ButtonStyle 
    PropertyChanged "ButtonStyle" 
    BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
    m_UsePicture = False 
End Property 
 
Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer) 
    RaiseEvent KeyDown(KeyCode, Shift) 
    LastKeyDown = KeyCode 
    Select Case KeyCode 
    Case 32 'spacebar pressed 
        If Not m_UsePicture Then 
            BT.Picture = LoadResPicture(2200 + m_ButtonStyle, 0) 
        Else 
            BT.Picture = m_DownPicture 
        End If 
        L.Top = (UserControl.Height / 2 - L.Height / 2) + 20 
        Ico.Top = (UserControl.Height / 2 - Ico.Height / 2) + 20 
        Md = True 
         
    End Select 
 
End Sub 
 
Private Sub UserControl_KeyPress(KeyAscii As Integer) 
    RaiseEvent KeyPress(KeyAscii) 
End Sub 
 
Private Sub UserControl_KeyUp(KeyCode As Integer, Shift As Integer) 
RaiseEvent KeyUp(KeyCode, Shift) 
If (KeyCode = 32) And (LastKeyDown = 32) Then 'spacebar pressed, and not cancelled by the user 
    If Not m_UsePicture Then 
        BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
    Else 
        BT.Picture = m_NoPicture 
    End If 
     
    L.Top = (UserControl.Height / 2 - L.Height / 2) 
    Ico.Top = (UserControl.Height / 2 - Ico.Height / 2) 
    Md = False 
    RaiseEvent Click 
End If 
End Sub 
'' 
'''注意!不要删除或修改下列被注释的行! 
'''MappingInfo=Ico,Ico,-1,Picture 
''Public Property Get ButtonIcon() As Picture 
''    Set ButtonIcon = Ico.Picture 
''End Property 
'' 
''Public Property Set ButtonIcon(ByVal New_ButtonIcon As Picture) 
''    Set Ico.Picture = New_ButtonIcon 
''    PropertyChanged "ButtonIcon" 
''End Property 
'' 
''注意!不要删除或修改下列被注释的行! 
''MemberInfo=11,0,0,0 
'Public Property Get ButtonIcon() As Picture 
'    Set ButtonIcon = m_ButtonIcon 
'End Property 
' 
'Public Property Set ButtonIcon(ByVal New_ButtonIcon As Picture) 
'    Set m_ButtonIcon = New_ButtonIcon 
'    Ico.Picture = m_ButtonIcon 
'    UserControl_Resize 
'    PropertyChanged "ButtonIcon" 
'End Property 
Private Sub DoGrey(Icon As PictureBox) 
 
    Dim Grey& 
    Dim C1&, C2& 
    Dim B&, G&, R& 
    Dim H%, W%, pH%, pW% 
 
       pH = Icon.Height - 1 
       pW = Icon.Width - 1 
       For H = 0 To pH 
           For W = 0 To pW 
               C1 = GetPixel(Icon.hdc, W, H) 
               If C1 <> &HFFFFFF Then 
                  B = C1 \ 65536 
                  G = (C1 - B * 65536) \ 256 
                  R = C1 - B * 65536 - G * 256 
                  Grey = (222 * R + 707 * G + 71 * B) / 1000 
                  R = Grey 
                  G = Grey 
                  B = Grey 
                  SetPixelV Icon.hdc, W, H, RGB(R, G, B) 
               End If 
           Next 
       Next 
Icon.Picture = Icon.Image 
End Sub 
 
 
'注意!不要删除或修改下列被注释的行! 
'MappingInfo=UserControl,UserControl,-1,Enabled 
Public Property Get Enabled() As Boolean 
    Enabled = UserControl.Enabled 
End Property 
 
Public Property Let Enabled(ByVal New_Enabled As Boolean) 
Dim C1 As Long 
    UserControl.Enabled() = New_Enabled 
    PropertyChanged "Enabled" 
    If New_Enabled = False Then 
        C1 = L.ForeColor 
        L.ForeColor = vb3DShadow 
        PicTmp.Picture = Ico.Picture 
        DoGrey PicTmp 
        Ico.Picture = PicTmp.Picture 
    Else 
        L.ForeColor = C1 
    End If 
End Property 
 
'注意!不要删除或修改下列被注释的行! 
'MappingInfo=L,L,-1,ToolTipText 
Public Property Get ToolTipText() As String 
Attribute ToolTipText.VB_Description = "返回/设置当鼠标在控件上暂停时显示的文本。" 
    ToolTipText = m_ToolTipText 
End Property 
Public Property Let ToolTipText(ByVal New_ToolTipText As String) 
    m_ToolTipText = New_ToolTipText 
    L.ToolTipText = m_ToolTipText 
    BT.ToolTipText = m_ToolTipText 
    PropertyChanged "ToolTipText" 
End Property 
 
'注意!不要删除或修改下列被注释的行! 
'MemberInfo=11,0,0, 
Public Property Get ButtonIcon() As Picture 
Attribute ButtonIcon.VB_Description = "返回/设置控件中显示的图形。" 
    Set ButtonIcon = m_ButtonIcon 
End Property 
 
Public Property Set ButtonIcon(ByVal New_ButtonIcon As Picture) 
    Set m_ButtonIcon = New_ButtonIcon 
    PropertyChanged "ButtonIcon" 
End Property 
 
'注意!不要删除或修改下列被注释的行! 
'MemberInfo=11,0,0,0 
Public Property Get NoPicture() As Picture 
Attribute NoPicture.VB_Description = "按钮图片" 
    Set NoPicture = m_NoPicture 
End Property 
 
Public Property Set NoPicture(ByVal New_NoPicture As Picture) 
    Set m_NoPicture = New_NoPicture 
    If m_UsePicture Then 
        BT.Picture = m_NoPicture 
    End If 
    PropertyChanged "NoPicture" 
End Property 
 
'注意!不要删除或修改下列被注释的行! 
'MemberInfo=11,0,0,0 
Public Property Get OnPicture() As Picture 
Attribute OnPicture.VB_Description = "鼠标经过按钮时的图片" 
    Set OnPicture = m_OnPicture 
End Property 
 
Public Property Set OnPicture(ByVal New_OnPicture As Picture) 
    Set m_OnPicture = New_OnPicture 
    PropertyChanged "OnPicture" 
End Property 
 
'注意!不要删除或修改下列被注释的行! 
'MemberInfo=11,0,0,0 
Public Property Get DownPicture() As Picture 
Attribute DownPicture.VB_Description = "按钮按下的图片" 
    Set DownPicture = m_DownPicture 
End Property 
 
Public Property Set DownPicture(ByVal New_DownPicture As Picture) 
    Set m_DownPicture = New_DownPicture 
    PropertyChanged "DownPicture" 
End Property 
 
'注意!不要删除或修改下列被注释的行! 
'MemberInfo=0,0,0,0 
Public Property Get UsePicture() As Boolean 
    UsePicture = m_UsePicture 
End Property 
 
Public Property Let UsePicture(ByVal New_UsePicture As Boolean) 
    m_UsePicture = New_UsePicture 
    If Not m_UsePicture Then 
        BT.Picture = LoadResPicture(2000 + m_ButtonStyle, 0) 
    Else 
        BT.Picture = m_NoPicture 
    End If 
    PropertyChanged "UsePicture" 
End Property