'Descripcion: Clase que emula una barra de botones
' horizontales.
' Permite el uso de skins para los botones.
Option Explicit
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal Bytelen As Long)
Private Declare Sub FillMemory Lib "kernel32.dll" Alias "RtlFillMemory" (ByRef Destination As Any, ByVal Length As Long, ByVal Fill As Byte)
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_TAB = &H9
Private Const VK_RETURN As Long = &HD
Private Const VK_SPACE As Long = &H20
'Funciones para averiguar si el mouse esta sobre el picturebox.
Private Declare Function GetFocusAPI Lib "user32.dll" Alias "GetFocus" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetStockObject Lib "gdi32.dll" (ByVal nIndex As Long) As Long
Private Const BLACK_BRUSH As Long = 4
Private Const DKGRAY_BRUSH As Long = 3
Private Const WHITE_BRUSH As Long = 0
Private Declare Function GetSysColor Lib "user32.dll" (ByVal nIndex As Long) As Long
Private Declare Function GetSysColorBrush Lib "user32.dll" (ByVal nIndex As Long) As Long
Private Const COLOR_BTNFACE As Long = 15
Private Const COLOR_3DFACE As Long = COLOR_BTNFACE
Private Const COLOR_BTNHIGHLIGHT As Long = 20
Private Const COLOR_3DHILIGHT As Long = COLOR_BTNHIGHLIGHT
Private Const COLOR_3DHIGHLIGHT As Long = COLOR_BTNHIGHLIGHT
Private Const COLOR_BTNSHADOW As Long = 16
Private Const COLOR_3DSHADOW As Long = COLOR_BTNSHADOW
Private Declare Function GetCurrentObject Lib "gdi32.dll" (ByVal hDC As Long, ByVal uObjectType As Long) As Long
Private Const OBJ_BITMAP As Long = 7
Private Const OBJ_BRUSH As Long = 2
Private Const OBJ_FONT As Long = 6
Private Const OBJ_PEN As Long = 1
Private Declare Function SetRect Lib "user32.dll" (ByRef lpRect As RECT, ByVal x1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function OffsetRect Lib "user32.dll" (ByRef lpRect As RECT, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function PtInRect Lib "user32.dll" (ByRef lpRect As RECT, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32.dll" (ByVal hDC As Long) As Long
Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hDC As Long) As Long
Private Declare Function BeginPath Lib "gdi32.dll" (ByVal hDC As Long) As Long
Private Declare Function EndPath Lib "gdi32.dll" (ByVal hDC As Long) As Long
Private Declare Function SelectClipPath Lib "gdi32.dll" (ByVal hDC As Long, ByVal iMode As Long) As Long
Private Declare Function SelectClipRgn Lib "gdi32.dll" (ByVal hDC As Long, ByVal hRgn As Long) As Long
Private Const RGN_AND As Long = 1
Private Const RGN_COPY As Long = 5
'FUNCIONES SOBRE EL MODO Y OBJETOS DEL DC
Private Declare Function GetBkMode Lib "gdi32.dll" (ByVal hDC As Long) As Long
Private Declare Function SetBkMode Lib "gdi32.dll" (ByVal hDC As Long, ByVal nBkMode As Long) As Long
Private Declare Function SetBkColor Lib "gdi32.dll" (ByVal hDC As Long, ByVal crColor As Long) As Long
Private Declare Function SetTextColor Lib "gdi32.dll" (ByVal hDC As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Private Declare Function CreatePen Lib "gdi32.dll" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function GetBkColor Lib "gdi32.dll" (ByVal hDC As Long) As Long
Private Declare Function GetTextColor Lib "gdi32.dll" (ByVal hDC As Long) As Long
Private Const OPAQUE As Long = 2
Private Const TRANSPARENT As Long = 1
Private Const PS_SOLID As Long = 0
Private Const PS_DASH As Long = 1
Private Const PS_DOT As Long = 2
'FUNCIONES DE TEXTO
Private Declare Function DrawText Lib "user32.dll" Alias "DrawTextA" (ByVal hDC As Long, ByVal lpStr As String, ByVal nCount As Long, ByRef lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function DrawTextEx Lib "user32.dll" Alias "DrawTextExA" (ByVal hDC As Long, ByVal lpsz As String, ByVal n As Long, ByRef lpRect As RECT, ByVal un As Long, ByRef lpDrawTextParams As Any) As Long
Private Const DT_LEFT As Long = &H0&
Private Const DT_RIGHT As Long = &H2&
Private Const DT_TOP As Long = &H0&
Private Const DT_VCENTER As Long = &H4&
Private Const DT_CENTER As Long = &H1&
Private Const DT_BOTTOM As Long = &H8&
Private Const DT_CALCRECT As Long = &H400&
Private Const DT_EXPANDTABS As Long = &H40&
Private Const DT_SINGLELINE As Long = &H20&
Private Const DT_MULTILINE As Long = (&H1&)
Private Const DT_END_ELLIPSIS As Long = &H8000&
Private Const DT_NOPREFIX As Long = &H800&
Private Const DT_WORD_ELLIPSIS As Long = &H40000
'FUNCIONES PARA DIBUJAR LOS BOTONES COMUNES
Private Declare Function DrawFocusRectAPI Lib "user32.dll" Alias "DrawFocusRect" (ByVal hDC As Long, ByRef lpRect As RECT) As Long
Private Declare Function DrawFrameControl Lib "user32.dll" (ByVal hDC As Long, ByRef lpRect As RECT, ByVal un1 As Long, ByVal un2 As Long) As Long
Private Const DFC_BUTTON As Long = 4
Private Const DFCS_BUTTONPUSH As Long = &H10
Private Const DFCS_FLAT As Long = &H4000
Private Const DFCS_HOT As Long = &H1000
Private Const DFCS_INACTIVE As Long = &H100
Private Const DFCS_PUSHED As Long = &H200
Private Const DFCS_CHECKED As Long = &H400
Private Const DFCS_ADJUSTRECT As Long = &H2000
Private Declare Function DrawEdge Lib "user32.dll" (ByVal hDC As Long, ByRef qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
Private Const BDR_INNER As Long = &HC
Private Const BDR_OUTER As Long = &H3
Private Const BDR_RAISED As Long = &H5
Private Const BDR_RAISEDINNER As Long = &H4
Private Const BDR_RAISEDOUTER As Long = &H1
Private Const BDR_SUNKEN As Long = &HA
Private Const BDR_SUNKENINNER As Long = &H8
Private Const BDR_SUNKENOUTER As Long = &H2
Private Const EDGE_BUMP As Long = (BDR_RAISEDOUTER Or BDR_SUNKENINNER)
Private Const EDGE_ETCHED As Long = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
Private Const EDGE_RAISED As Long = (BDR_RAISEDOUTER Or BDR_RAISEDINNER)
Private Const EDGE_SUNKEN As Long = (BDR_SUNKENOUTER Or BDR_SUNKENINNER)
Private Const EDGE_FLAT As Long = BDR_RAISEDINNER
Private Const EDGE_FLAT_DOWN As Long = BDR_SUNKENOUTER
Private Const BF_ADJUST As Long = &H2000
Private Const BF_BOTTOM As Long = &H8
Private Const BF_FLAT As Long = &H4000
Private Const BF_LEFT As Long = &H1
Private Const BF_RIGHT As Long = &H4
Private Const BF_TOP As Long = &H2
Private Const BF_SOFT As Long = &H1000
Private Const BF_RECT As Long = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
'FUNCIONES DEL BITMAP
Private Declare Function CreateCompatibleBitmap Lib "gdi32.dll" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function CreateBitmap Lib "gdi32.dll" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, ByRef lpBits As Any) As Long
'Nota: Cambiar el valor Byval de LpVoid as ByRef en CreateDibSection
Private Declare Function CreateDIBSection Lib "gdi32.dll" (ByVal hDC As Long, ByRef pBitmapInfo As BITMAPINFO, ByVal un As Long, ByRef lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
Private Declare Function DrawState Lib "user32.dll" 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 CreateDIBPatternBrushPt Lib "gdi32.dll" (ByRef lpPackedDIB As Any, ByVal iUsage As Long) As Long
Private Declare Function GetObjectAPI Lib "gdi32.dll" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long
Private Const DST_BITMAP As Long = &H4
Private Const DST_ICON As Long = &H3
Private Const DST_TEXT As Long = &H1
Private Const DSS_DISABLED As Long = &H20
Private Const DSS_NORMAL As Long = &H0
Private Const DSS_MONO As Long = &H80
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Const BI_RGB As Long = 0&
Private Const DIB_RGB_COLORS As Long = 0
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type RGBStruct
Red As Byte
Green As Byte
Blue As Byte
AlphaChannel As Byte
End Type
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors(4) As Long
End Type
'FUNCIONES PARA DIBUJAR SOBRE EL DC O BITMAP
Private Declare Function StretchBlt Lib "gdi32.dll" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Declare Function StretchDIBits Lib "gdi32.dll" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal wSrcWidth As Long, ByVal wSrcHeight As Long, ByRef lpBits As Any, ByRef lpBitsInfo As BITMAPINFO, ByVal wUsage As Long, ByVal dwRop As Long) As Long
Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function FrameRect Lib "user32.dll" (ByVal hDC As Long, ByRef lpRect As RECT, ByVal HBrush As Long) As Long
Private Declare Function FillRect Lib "user32.dll" (ByVal hDC As Long, ByRef lpRect As RECT, ByVal HBrush As Long) As Long
Private Declare Function Rectangle Lib "gdi32.dll" (ByVal hDC As Long, ByVal x1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function Ellipse Lib "gdi32.dll" (ByVal hDC As Long, ByVal x1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function Polygon Lib "gdi32.dll" (ByVal hDC As Long, ByVal lpPoint As Long, ByVal nCount As Long) As Long
Private Declare Function Polyline Lib "gdi32.dll" (ByVal hDC As Long, ByRef lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function APIGetPixel Lib "gdi32.dll" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetPixel Lib "gdi32.dll" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function ExtFloodFill Lib "gdi32.dll" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
Private Const FLOODFILLBORDER As Long = 0
Private Const FLOODFILLSURFACE As Long = 1
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
Private Type SafeArrayBound
cElements As Long
lLbound As Long
End Type
Private Type SAFEARRAY1D
cDims As Integer
fFeatures As Integer
cbElements As Long
cLocks As Long
pvData As Long
Bounds(0 To 0) As SafeArrayBound
End Type
Private Type SAFEARRAY2D
cDims As Integer
fFeatures As Integer
cbElements As Long
cLocks As Long
pvData As Long
Bounds(0 To 1) As SafeArrayBound
End Type
'FUNCIONES PARA TRABAJAR CON CODIGO ASSEMBLER
'Nota: Para compilar este Programa en VB6, cambiar las
'referencias Lib "msvbvm50.dll" por "msvbvm60.dll"
Private Declare Function VarPtrArray Lib "msvbvm50.dll" Alias "VarPtr" (Ptr() As Any) As Long
Private Declare Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Constantes que definen el estado de la barra.
Private Const fMASKCOLOR = 1
Private Const fAUTOSIZE = 2
Private Const fDRAWFOCUSRECT = 4
'Constantes para identificar los botones.
Private Const BUTTON_PREVIOUS = -2
Private Const BUTTON_NEXT = -1
Private Const NO_BUTTON = -3
'Constante que define el margen entre el texto o icono
'y los bordes.
Private Const MARGINSIZE = 3
'Constantes que definen estados internos de los botones.
Private Const BTN_VISIBLE = 1
Private Const BTN_SHOWABLE = 2
Private Const BTN_FULLVISIBLE = BTN_VISIBLE Or BTN_SHOWABLE
'Constante que define el color de la sombra del icono.
Private Const SHADOW_COLOR = &HC0C0C0
'Constantes de enumeracion que representan las posibles
'alineaciones de texto o imagen.
Public Enum eAlignment
eLeft = 1
eRight = 2
eHCenter = 4
eTop = 8
eBottom = 16
eVCenter = 32
End Enum
'Constantes de enumeracion que representan los tipos de
'botones de la barra.
Public Enum eButtonTypes
eSeparator = 1
eButton = 2
eCheck = 4
'eCheck = 0100 en binario
'eOption = 1100 en binario
'Implica que el tipo eOption comparte un bit con el
'tipo eCheck, pero no con eSeparator o eButton.
eOption = 12
End Enum
'Constantes de enumeracion que representan los estilos
'de un boton.
Public Enum eButtonStyles
eFlat = 1
eHot = 2
e3D = 3
eOwnerDrawn = 4
eSkinned = 5
End Enum
'Constantes de enumeracion que reprensentan los estados
'de un boton.
Public Enum eButtonStates
eNormal = 0
eFocused = 2
eOver = 1
eDown = 4
eDisabled = 8
End Enum
'Constantes para los offset de la skin de acuerdo al
'estado del boton.
Private Const BTN_SKN_NORMAL As Long = 0
Private Const BTN_SKN_FOCUSED As Long = 1
Private Const BTN_SKN_OVER As Long = 2
Private Const BTN_SKN_DOWN As Long = 3
Private Const BTN_SKN_DISABLED As Long = 4
'Constantes de enumeracion para los tipo de relleno del
'boton.
Public Enum eFillMode
eVerticalGradient
eHorizontalGradient
eTransparent
eSolid
ePatternFill
eBlit
eStretchBlit
End Enum
'Tipo de datos que almacena la informacion de cada boton.
Private Type tButton
Text As String
Icon As StdPicture
Style As eButtonStyles
State As eButtonStates
ButtonType As eButtonTypes
TextAlign As eAlignment
IconAlign As eAlignment
Tooltip As String
Left As Long
Top As Long
Width As Long
Height As Long
'Funciona como la skin gral., tiene los 5 estados en
'la imagen.
Skin As StdPicture
'Maskcolor de la skin y del Icon.
MaskColor As Long
Flags As Long
End Type
Private Type tDCData
DC As Long
OldBmp As Long
OldPen As Long
oldBrush As Long
OldFont As Long
CurBmp As Long
CurPen As Long
CurBrush As Long
CurFont As Long
HasBmp As Boolean
End Type
Private WithEvents m_Container As PictureBox
Attribute m_Container.VB_VarHelpID = -1
Private WithEvents m_Font As StdFont
Attribute m_Font.VB_VarHelpID = -1
'Indica el DC que contiene a la skin.
Private m_SkinDC As tDCData
'Contiene el DC del picturebox (solo por simplicidad)
Private m_DC As tDCData
'Contiene el DC de la mascara de la skin.
Private m_SkinMaskDC As tDCData
'Contiene el DC de BackBuffer
Private m_BackBuffer As tDCData
'Contiene un DC del tama±o del picturebox para dibujar
'las skins particulares de los botones.
Private m_ButtonSkinDC As tDCData
'Indica la imagen original del Canvas.
Private m_Skin As StdPicture
'Indica el Ancho de la Skin.
Private m_SkinWidth As Long
'Indica el Alto de la Skin.
Private m_SkinHeight As Long
'Indican el ancho y alto del borde de la skin.
Private m_SkinBorderWidth(5) As Long
Private m_SkinBorderHeight(5) As Long
'Array que contiene los datos de los botones y separadores
Private m_Buttons() As tButton
'Cant. de botones y separadores que hay en la barra
Private m_nButtons As Long
'Indica el color de fondo de la barra.
Private m_BackColor As Long
'Indica el color primario de fondo de los botones para los estados
'Normal, Focused, Disabled, Over y Down.
Private m_BackColor1(5) As Long
'Indica el color secundario de fondo de los botones para los estados
'Normal, Focused, Disabled, Over y Down.
Private m_BackColor2(5) As Long
'Indica el color primario de texto de los botones para los estados
'Normal, Disabled, Over y Down.
Private m_TextColor1(5) As Long
'Indica el color secundario de texto de los botones para los estados
'Normal, Focused, Disabled, Over y Down.
Private m_TextColor2(5) As Long
'Indica el color de borde de los botones para los estados
'Normal, Focused, Disabled, Over y Down.
Private m_BorderColor(5) As Long
'Indica el ancho del borde.
Private m_BorderWidth As Long
'Indica las banderas que estan activadas.
Private m_BarFlags As Long
'Indica el color de transparencia de la skin.
Private m_MaskColor As Long
'Indica cual es el boton que esta presionado por el mouse.
Private m_ButtonDown As Long
'Indica el boton sobre el cual se encuentra el mouse.
Private m_ButtonOver As Long
'Indica el boton sobre el cual se encuentra el foco.
Private m_ButtonFocus As Long
'Variables que contienen los botones Anterior y Siguiente
Private m_ButtonPrevious As tButton
Private m_ButtonNext As tButton
'Indica el modo en que se dibuja la skin del boton
Private m_FillMode As Long
'Indica el efecto que tendra el texto del boton
Private m_FontEffect As Long
'Indican el alto y ancho por defecto de los botones.
Private m_DefaultButtonWidth As Long
Private m_DefaultButtonHeight As Long
'Indica el espacio horizontal que hay entre cada bot≤n.
Private m_HorizontalButtonGap As Long
'Indica el espacio horizontal que hay entre el bot≤n y la barra.
Private m_VerticalButtonGap As Long
'Contiene el patron con el que pintamos el fondo de un
'boton Check que no usa Skin.
Private m_CheckPatternBrush As Long
'Indica si la llamada para dibujar los botones proviene
'del procedimiento RedrawBar (es para evitar el flickering).
Private m_RedrawAllButtons As Boolean
'Indica si realmente actualizamos la barra o no en el
'picturebox.
Private m_LockUpdate As Boolean
'Indica el primer boton visible.
Private m_FirstVisibleButton As Long
'Indica la cantidad de botones visibles.
Private m_nVisibleButtons As Long
Public Event Click(Index As Long)
Public Event MouseDown(Index As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseMove(Index As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseUp(Index As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Public Event MouseEnter(Index As Long)
Public Event MouseLeave(Index As Long)
Public Event GotFocus(Index As Long)
Public Event LostFocus(Index As Long, Desc As String)
Public Event Paint() '(Index As Long)
Public Event Resize() '(Index As Long)
Public Event KeyDown(Index As Long, KeyCode As Integer, Shift As Integer)
Public Event KeyUp(Index As Long, KeyCode As Integer, Shift As Integer)
Public Event KeyPressed(Index As Long, KeyAscii As Integer)
'=============================================
'DEFINICION DE METODOS PUBLICOS
'=============================================
'Crea un nuevo boton para la barra.
'Devuelve el indice del boton.
Public Function AddButton(BtnType As eButtonTypes, Text As String, Optional Style As eButtonStyles = eFlat, Optional Tooltip As String = "", Optional Img As StdPicture, Optional TextAlignment As eAlignment = eRight Or eVCenter, Optional ImgAlignment As eAlignment = eLeft Or eVCenter, Optional State As eButtonStates = eNormal) As Long
Dim dx As Long, dy As Long
'Si la barra no fue creada o fue destruida, no agregamos
Private Sub m_Font_FontChanged(ByVal PropertyName As String)
Set m_Container.Font = m_Font
' Debug.Print "RedrawBar de FontChanged"
RedrawBar
End Sub
'=============================================
'DEFINICION DE PROPIEDADES PUBLICAS
'=============================================
'Indica si actualizamos la barra o no.
Public Property Get LockUpdate() As Boolean
LockUpdate = m_LockUpdate
End Property
'Indica si actualizamos la barra o no.
Public Property Let LockUpdate(ByVal NuevoValor As Boolean)
m_LockUpdate = NuevoValor
If Not NuevoValor Then
' Debug.Print "RedrawBar de LockUpdate"
RedrawBar
End If
End Property
'Indica el espacio entre cada boton (en pixeles).
Public Property Get HorizontalButtonGap() As Long
HorizontalButtonGap = m_HorizontalButtonGap
End Property
'Indica el espacio entre cada boton (en pixeles).
Public Property Let HorizontalButtonGap(ByVal NuevoValor As Long)
m_HorizontalButtonGap = NuevoValor
' Debug.Print "RedrawBar de HorizontalButtonGap"
RedrawBar
End Property
'Indica el espacio entre cada boton (en pixeles).
Public Property edraxeles).
Public c End If CheckVisibleButtonstonIndex = GetButtonCapture(CLng(X)ttonGap * 2)
XstonIndex =own.
X)ttonGap * 2)
XstonIndex =own.
X)ttonGap * 2)
XstonInde(m_ButtonDButto2mcus >= 0 Thep * 2)
XstapturebrY))
If Button eDowntre cadaNdthibleButtonstonIndex = GeturebrY))
sropertA cada bot
'onGaer_Paint event"
' Debug.Print "RedrawBar de Paint"
Rtate) & "0 Thep * 2)t
'onGaer_Pain_tonNext.Left = a e o no.
Public Function SetButtonSize(ByVal Index As Long, Optional ByVal W As Long = 0, Optional ByVal H As Long = 0) As Boolean
If Index >= 0 And Index < m_nButtons Then
If W > 0 Then m_Buttons(Index).Width = W
If H > 0 Then m_Buttons(IndeHlean
If Index >= 0 And Ina_nButns ThenseEvent Moui=.Width nt"
RedrawBar
RaiseEvent Paint
End Sub
Private utto2mcus e(m_ButtonFocus) And eFocused)t FunonOver, eOTRedrawBar de Paint As IntegelUis*,Gpz eOTRedrawBar de Paint e utto2mcus e(m_ButtonFocus) And eFocusev,nNext.l Sub
'Si uttonDxltegelIndex).Tooltip
tate) nDxlteger.ScaleX(Ionsiguio el Over, se lo agregamos
If ButtonTa barra o no.
Public Propertyn - 1
m_Buttons(m_FirstVii_ButtstonIndun boton
'mt = d).Tooltip
tate) nDxlt Img.h= d) If
b.
Public Propertynf Index >= 0 And Index < m_nButtons Then
If W > 0 The).
Public Property LsizeDC
Public Propertynf Indeef FirstetButtonCapture(r de Paint"
Public Function SetButtonSize(ByVal Index As Long, Optional ByVal Color As Long, BtnStIndex < m_n) As Ls(m_ButtonD(m_ uttonDX
'L,h_ynnnnnByVmolL If .ButtonType = enByty LsizeDC
Public Propn Debug.Print True
Else
m_Buttons(Index).Left sS)nFocus uttonDX
'onGaer_Pain_tonNext.LefILefILByVal Index As Long, Optional ByVal Color nH,:mZed, False
DrawButton m_ButtonFocus
RaiseEvent KeyDown(m_ButtonFocus, KeyCodeXlse
'Si algun botonalgunonF0nalgunonF0lse
'Si algun colmZed,odeXlsea.l estado
ate = mvoValor
' Dhacia la izquie) 'Si algun que el
lgun que elionNexs(ContainerContai onNexs(Cot
RedrawBar
RaiseEvent Paint
End Sub
Priv_FirstVisi vbLeftButton Then
If TempBtn >nNexs(Cot
Rtons
'rtical(C& deButtons
E(_Buttonocus
Ra PrAs Boolean
If Index >= 0 _ButtonD(m_BHi)utton 'Si algnm_ynnnie) 'Si algunal ByVaem_nButFmropertynf Ilos n(m_ButtonD(m_ButtonD(m_ButtonD(m_ButtonD(m_ButtonD(m_ButtonD(m_ButtonD(m_ButtonD(m_ButtonkButtonDbot(m_ButtonkButtonDbot(m_ButtonkButm_ButtonD(m_ButtonD(m_Bu= m_nButFmropn(m_ButtonFocus, KeyCodewn(m_6uttoBtnStIn Es
xs(Coxs(Con wn(m_6"
RtadonIndutFmropertynf Ilos n(m_BUTTON Then
'a Fal& Indice
PREVIOUSd0nf Ilos us
Raise_NEXT Then
> Index)
End If
s(m_Bice
PREVIOUtoneButtonD(m_Button > , se lo agregamos
If ButtonTa barra o no m_BuickUpda2o agregamos
If ButtonTa barra o no m_BuickUpenButFmropn(m_BuD(m_ButtonD(m_ButtonD=== m_ynnnnnByVmos ligjnD(m_ButtonDnFocus uttonDX
'onGaer_Pain_tonNext.Left = a e o no.
Public Function SetButtonSize(ByVal Index As Long, Optional ByVal Color As Long, BtnStIndex < m_n) As Ls(m_ButtonD(m_ uttonDX
rbleButton = m_Firs > Ndateenadas de lo Debug.Print "M_FIRSTVISIB=ElseIf li > NO)
' Debuenadas de lo DebutonD(m_ebutoDebuednd Sub
'===== _RGB_ ThentonDown
End Sube(inFocus = NextAvao.
If m_BhentonDowny"r para trabaj "ButtThenon TheB(255, 255, 255)
.bmiColoa los botoAEaiseEveEnThentonDown
dMdex To m_nButtons - nnByVmos 'Evento con elm_ButIndc
e.ButDD2ngle)
nItte =uttonFocus If m_BueREnThentonDo)
Set m_CotDD2ng2Omos
IftonFocus If m_BueREnThentonDo)c'Xcoim Nm_B If
End If
End SMrdateBS er Is Notamosd eDisabl_BuEnd SubOpntCordenadas de los botones de navegacne el g, Topoltip
tBJIndc
e.ButDD2ngle)
nIndex) And eDisabl_BuEnd Sub
'===== _RGB_C_ButtonD(c
If m_ButIndc
e.ButDD2ngle)
nIndex) And eDisabl_Bu<ex) And eDisabl_Bu<ex) And eDisabl_Bu<ex) And eDisabl_Bi)uttoeDisabl_Bu<ex) And eSub
tbQedrawi)uttoeDisabl_BItAsab'tte =upSub
tbQedrawi)uen
'a Fal& Indic e.BVpertLeft, TD(m_====si vbLeftBu >e)
If ButtonTa baA/ButtonNkl_Bu<exex) AstonTa baA/ButtonLg.l Subn
ut(isabl_Busuario.
If m_ButtonOver >= 0 Then
' & Iebug.Print "MouseTo 5
If ButtonTmismseIf eighMVs&5'D(m_Bu ps dei_ButtstonIndun boton
s If m_BueREButtstoButtonLg.l SDisabl_BuEnd me Aisabl_Bu<ex) And eDsi vb & Iebug.Print "MouseTo 5
If ButtonTmismseIf eighM=in-rAnd eDiPrevious.Fir
GoT GoT GoT t
'Si no existe uoT onTa baA/
SiSD(m_Print "LaIndc
e.ButDD2ngle)
nIndex) And eDiSiS GoT
rbouttonTmisebQedrawi)uen
'a Fal& Indic NDiSiS GoT
rbouttonTmisebQWabl_Bu<exf ItonD(s un boton agreg SMrdateBS e SMrdateBS e SMrdateBS e SMrdateBS e os el foco del boton actual.
Me.SetButSButtonI00000) = &H80000000 Then
'Esyo existe uoT onTa baA/
SiSD(m_Print "LaIndc
e.ButDD2ngle)
nIndex) And eDiSiS GoT
rbouttonTmisebQedrawi)uen
'a Fal& Indic NDiSiS GoT
rbouttonTmisebQWabl_Bu<exf ItonD(s un boton agreg SMrdateBS e SMrs===
'Evento N)
m_Cn boton agreg SMrdateBS
' With m_(eEvent KeyDoboton actual.
Me.SetB(uttoocus= a. Exit For
& Inrra'tonDown
'Evento con rsm_B agxeAsadateBS e SMrs===
ni SiSD(mtonI000tan
IfqthsrButtntChaoreAblSysColor(SysColor)
EneCheck Then
Me.SetBut Me.SetB
EneC En If m_DQWabl_Bu<exf ItoetB
EneCN Ifn = m_Firsm_nt "ButtntChaoreAblS
m_t "Buurebom=======si vblYt InrraRed
Me.SetButtonState m_ButtonFocus, eF N)
m_Cn boton urState
D barrEIf m_DQWabl_BufSub m_CD(mtouttot(m_BuItoetB
ndic NDiSiS GoT
rbouttonTmiespacio(mtouttot(m_BuI If (.Statetbera todos los objetos asoci ItonD(s > NO)
' Debuenadas de lo DebutonD(m_ebutoDebuedss.Fir
mcs, eF N)
ot(m_BuI If (.Statetbera todos lops dei_ButtstonIndDebutoR===
ni SiSD(mtonI000tan
IfqthsrButtntbliRe CapturtoR===en
If W > 0 Then m_Buttonboton urptuo L m_t "Buurebom=L En If m_DQWabl_Bolor del sisoe
With XIs No6e_L.PriF Focus? = " & CBoPai? = " & CBoPai? = " & CBoPai? = " & CBoPor2(BtnState) & CBoPai?blic Function SetButtblic F m_ (.Statetbera todos los objetos asoci Ity
_eDThep * 2)tdTa ===enIf S.
ug.PrRais
Me.SetButtonion SetButtblic F m_pnction SetButtblic F m_ (.Statetbera tonD(m_ButtoeetButtblic F m_ (.Statetbera tysColCSMrdateBS uttonTmisebQedi? = onTmiseSeeBS _Firsm_B = s 'Eventouttn) And eD
'Indi_ (.Statera todos loeT
== _b tysColCSMrdateBS uLLious.State = m_ButtonPrevious.State Or State
Else* 2)<:NtonPDState
ra tony& CBoPai? = "pe
rbouttonTmisebQedrawi)utton'EventouttnonSta'Eventouttn) And eD
'Indi_ alate Or State
El,tn) An
ElseirdateAn
ElseirdateAn
ElseirdateAn
ElseirdateAn
s eD_Bi)uttoeDisablpmIera todos lops irdo
ate = AS
Then
reAttonD(mate = tera todos loeT
== _b tysColCSMrdateBS uLLious.State = m_,i=ar
Ranednd Sub
tetberayn - 1
a
Else* 2)
Else = m_,i=aoPRtn) And eD
'Indi_ alata = m_,i=ar
PubbtoAyrb
on SetButtblic F m_ (.Statetbeent KeyDown(m_ButtonFocus, KeyAnd eD.n Exit/lse
cPDStat'Indi_ alatN= tera tQlgun xit Sub
If KeyCode = vbKeyReturn Or KeyCode = vbKeySpace Then
If m_ButtonDown > NO_BUTTON Then
' Debug.Print "Key Up con ui=.Wi(Me.ButtonType(m_ButtonDown) And eChecttonState
El,tn)Re CaputtntChaoreAb De
' Debug.Prayn - 1
a
Else* 2)
ElRAyrb
iocus(leT
CaputtntC) And eChectt Then
' DeuoT onndex) And eDisab,ai De
't, m_MaskCode_FirstVis.g
't, m_MaskMaskC loeT
eirstVis.g
't,kC loeT
eirstVis.g
't,kC loeT
eirstVis.g
't,kC loeT
eirstVis.stVis.gu loeT
eirstVis.stVis.gu loeT
eirstNh)TaUTTONtOus.State = m_o, no hacemos n EndHng
en1aD.n Exixt.Left tera todos loeT
== _b tysColCSMrdateBS uLLious.Stat i = Index As Boolean
iocus(leasNr)e m_ eD Or KvoValor = m_Buttons(Inde_ eD O_,onmRedt,B=E Hex(State) & ") = &H" & Hex(m_Buttons(Index).StatevlmpntChao=======ttonDowuttonTmiN Then
'a Falil_BnD(m_But,le.sThenon Then ByVaeenon Then_ButtonbotouttntChae And eDown) Then
tonDowp GetMrdateBS uttonTmite E'Tuttadate = Nu'L,h_cemos el tiainl_Bu<exf ItonNnM
Dowp GetMrdateBS uocus eSHlate Or State
es.stVis.gu loeT
eirstVis.stVis.gu loeT
eirstNDSub
tetberayn - 1
a
Else* 2)
Elsamos
If Butie E'Tuttada el tiainlr Boton " &_Butgle, Y Ano m_BuickUpd.stVis.gu loeT
If Butto2C quSorbet,A:iS c,mb5, 2=S c anOttttoocus i >Hs± Debu2 If Buts Buts ButsP c,mb5, 2=S c anOttttoocus,toocus i >Hs± Debu2 If Buts Buts ButsP c,mb5, 2=S c anOttttoocus,toocus i >Hs± Debu2 If Buts Buts ButsP c,mb5, 2=S toocaSorbet
Pubgu ls m_BuW)e ,aphiocatonDepimonStaepaIneusl ,aphiocatig.PsEBLong,tttat owdLDett=i.Dodoug."trab3etberdi_DC)
ubliRde sigiom_ButtonFoctuThen')d SuR Me.SetB
EneC En If m_DQWabl_Bu<exf Itoe & Ina)en If m_DQWabl_Kaistutt If ig.PsEBLong,tttat owdLDett=i.Dodoug."trab3etberdi_DC.Dodoug."trab3etbeubliRde sigiom_Ba8ett=i.Dodoug."treett=s."dte Or
Aate = .PrioreAbl'on Theo(uso clB
o, " "CLoAnwsbaButtonebuC"b2exfbiyB) Apda2ormons - nnByVmos 'Evedte Or
Aate = .PrioreAbl'on Theo(uso clB
o, " "rQedraD(m_L tLttong"snnByLbaButtoDEet=i.Dodoug."t'."trab3toDEete Or
AateDodoug."t'."trab3dEte Or
Aat1
x And imonStaepaIneusl ,aphiocatig.PsEBLong,tttat owdLDett=i.Dodoug."trab3etberSe sigiom_Ba8t sD Me.SetButt Me.SetButtonStatx'T
If)uttdo, " False0_XlbaI(VISIBLf lbaI(VISIBLf lbaI(VISI x =De
iBLf lbaeEonA"traE)onDesFBYbLf Bos las coord_t) A"tas(Innt PaioTI x 1a,)m_Bu2Seainlc(= " De,(lbLf m_Br i > r
h+.l Si > r
h+.l Si > rI todoDs.gttoeodte skC loeTonD(m_ButMt,SLe'
==ttou.gtt m_t) A"tryVccu2_BnD(m_B(W5alba F),
'Iver & " in x = " &c
If)uttdo, " False0_XlbaI(VISIBLf lbaI(VISIBLf lbaI(VISI x =De
iBLf lbaeEonA"traE)onDesFBYbLf Bos las coord_t) A"tas(Innt PaioTI x 1a,)m_Bu2SIIIIIxiicap
IT 'mE_o(af m_D" in x)=
oneni_Bsu2_BnD(m_B(W5alba F),
'Iver & " inord_t) A"tas(Innt PaioTI x 1a,)m_Bu2SIIIscB
o, " " Gxet
'EY F),SechaoreAb De
iBLf lbaBsbl_t T SY I2Seainlc(= " De,(lbLf m_Br i 8d_t) A"tas(In" De,(lbt "Bu6mt f lbaBsbli _,oTdLDett=iou.gtDt,(VI tG8_5sI ta = mBS uocus eSHloDEeuodenSt " &c
BHs,(<rC) DM)chaoreAb De
iBLf M) & Ina)en If m_Dcus(ltonDoBos l rI todoDs.gtto))chaoreAb Deb Deb irrsmrsm_nc Psndv
_Bexfeo & ") = &H" &s.ghaotat owdLaotat
toN irrsmrsm_nc Psnet TTDsU1a,)m_Bu2SIIIIIxii' DttonodenSt " &c
BHs,(<rC) DM)chaoreAb De
iBLf M) & InXat
t1a,)m_os lasI t1a,)m_os ",)m_os lasI t1N2tG8ttos,n
reAaepaIneusl ,.FirogtsIf Butto2C quSoPDsU1a,)m_Bu2edtON DE PaI(VIf)uttoeilasI t1N2tG8tt(tls
tetbe 1
a
ndColor OnSVis.gqateionD==wn inNton Dras(In
tet cLoas(In
tet cLoayn i _/ono
oneni_tneTIf)W5alba F),
'IvEnd If
If (MeLoIIIIBIvEnt,(VISn
_oneo ==t W5ard_ And eDisab)
m_Cm>TmisebQPrint(Md 0 Dt,(VIn" Gxetetberax'vento T
tberax'T
tbgf (MeLo Ch+.l SDispenI00000,eoeTonD(m_ButMento T
tberax'T=== _Me.SetButtonStatx'T'itet cLoas,n Dras(InLnm'8_5sI bm_ButMento T
o Iv.mRka in=i.Dodoug."tRkae_blic P" . td ndeE'I d_BnD(m_B(W5alba F),
'Iver & " in x = "ver & " in x = "trabB
uttQa?Focusos ndv
_si' Dt<> eChonenEeuowHiIueMiret nr &ttonD)uismo que el'Iv.mRBscnzp-zp-zp-zp-zp-SdetBCh ti'v.mRka-Sdetat x =p-SdetBCh ti'v.mRka-v algiatd nY<r Ch ti'v.mRu.M,RBscnzp-zp-zp-zp-zp-niNot Nn
Ei)e m_i)e m_i)eE'Indi2tteeruuowHiIueMiret nr &tton)e m l.'Ea aoe & InptNhI
'In)blIIeNn
Ei)e m_i)e mgndv
_sCmI d_BnD(m_B( n
OiTdooSdtON Letpet nQa?L tLPuuowHiIueMiret nr &tton)e m deE'I
:ttoE_o(af m_D" dzp-zp-zp-zpexfe1d eR eR eRQa?Focu tnTmiI._TT2toTp= biyB) A"tr_o(af eR eRQa?F A"tr_o(af lbaBsccm AlbMDM,ton'Iver &ip-zp-"" . td _xiicap
o Iv.mRka in=i.Dodoug."tRkt,kCOiTdog, ie,toNdLm lI tuAcEY
s. fON Letpeno(igdtbera m l1nFdka(r
o XPos m_oDEetSaIneusl ,.FiroiIxtd nY8_5(ssed(m_Buttl.'Eaych+td nY8_5(sL=SA ==t AnRka in=i.Dodoug."tRkae_blic P" . td reB Q s.M8_tE((yAItoeO8" in xo I_Me.etSaIPos p
t "tt/onoXA2tontXA2tontuoT(on:n x)='Iver n x)='m_ButMento T
tbes x)=
om_Bura m l1nFdka(r
o 'llllg'mE_TT2dTdicSdldNtonaocu tnTmi_bli(VISIBcEY
s. t ndenS= mK)osL A(on:n '==_UponA"traE)onDesnD(m_ButtonD(m_A En If m_aIneusl ,.FiroiIxtroiTdogFce'_Debuel p
TdogFce'_Debuel petBuh>eb
(de eRts tret n_ButtonD(nDodoug2tontu>Brie,t nto.Dvent n m l1nFdkFdkFdkFdkFdkFeb
(de eRts Sdto(i_on EpAsQaebuel petBuh>eb
(de eRts r m deE'I Iv.mRka in=i.Dodougf lbaienTmiI._TTXPos m_ Iv.mRf m_D" in su2_e" & m_ButtoBuh>eb
(de e BcEY
gregAt m_D" in suAsQa_P" . td reB_e" & m_ButtoBu(n If IgB)nsccm_L t5((uev
m(r
o & in sun su2_e" & m_ButtoBuh>n ' DeBxuL(VIm_t) A"e" & m_ButtoE_o(af m(UuESr &e1d eR eRts tono(i_on EpCrd_rd_rd, Oiongmsno(i_onuuLdooSdtOde, Ships S:EY
s. fON KmCLnm'8_5R"tryV SuR
ItoetB
CBo If
If m_BusAttoco ,s =eweInteger, SateosL==wn i'er & rd_rduttoE_o(af mPlbaBsccm AUto
o Iv.mRka in=i.Dodoug.Nut) A"trabB
uttQo, "Deb(ntdlTAttoco ,s =eweInteger, SateosL==wn iton acl_Bu=wn i FereAl_
'to
o.mRka " , SateosL==wn iton acl_Bu=wn i FereAl_
'to
o.mRka " , SateosL==wn iton acl_Bu=gB) APrie,toPIEeyCodelKmCLnmonSiis.s TBot Nn
Ei)e m_i)plbaienTmiI._TTXPos m_ Iv.mRf m_D" in su2_e" & m_ButtoBuh>eb
(in x spaciowu_g,6ICodelKmCLnmonSiis.s TDQWabl_t "tt/onpEeyCodeLsER
ItoetB
CBo h>eb
(in x spaciowu_g,6ICodelKmCLASteBPrope =alel Ov x spa
Pubgu Le'
Y= " ton EKmCLnm'8_5sI tueMiroi
nu<ex n
'XpontuoTetono'LoII_"
sP
ous.TdogtsPtoe &=tt(LsyB) Aatb.
PnB) Aatb.
PnBe)tt(Ls\ xs(Camos)bl'InduttonD(m_ButtQa?Focus If m_b5, 2=S c anOttt >Hs± Debu= " &c
If)uttoco dB
EKmCo dB
EKmCo dB
EKSD(m_Print "e>Hs± DeonS Inc2yVccus(leas7Upe.et
'E,6ICodelKmCLASteBPrope =alel Ov x spa
Pubgu Le'
Y= " ton EKm SDisEKmCLnm'8_5sIargu LeOttt >Hs± Debu= " &c
If)uttoco dB
EKmCo dB
EKmCobgu " ton EKm SDisEKmCLnm'8_5sIs(leas7Lygu Le'
' Dtnt PaioTI xctnt PtosRDs'_B.moR=ttB), PIBL(VIm_*t2 rontuoT(osLnInoeto)e m_i)eEeo 1aoug.6geai p
t ")0 Q sIKmCLnmonSesLnInoeto)eoEYento cAa<eoEYen I xctnt PtosRDs'_B.moR=ttB), PIBL(VIm_*t2 rontuoT(osLnInoennt PtosrH_nmHs± Debu= " &c
r±ntChD
e e), PIBL(VIm_*t2 rontuoT(osLnInoennt PtosrH_nmHs± Debu= "iu' m ) AnP "Buttn=_UponA"traosLnInoennt PtosrH_nmHs± Debu= "iu' m ) futtQo, "Deb(ntdlTAtto PIBLA, PIBL(VImh>cDrvgrodetBuh>mOraosLnInoennt PtosrH_nmHs± Debu= "iu' m i FeredooSdtON Letpet nQa?L tLPuuowHiIueMiret nr &tton)e m deE'If lbat PtosrH_nmHs± DE PIBLA fetBuh>cspITnW
e.SetButtonSt)ka in=i.Dodoug S(mtouttoEYentoAa<eoEYen I xctnt PtoimoreAb De
iBLf lbaBsbl_t T SY I2Seainlc(= " DetoimoreAb De
iag Si spacioDebu= "iu' m ) fu inNXAA fetBuh>cspITnW
e.SetButtttttttttttttttttttttt Detoah>eb
(de eRtsrogtsIf But)mt'Rk BxBocus = ButtonIndex B Ioon aR & areB_e" & m_' m ) bl_Bu<exf Itoe & cus = Bu_BFce8_5IpsLnInoennt PtosrH_nmHs± Debu= PIButtg.ctoIIeb5a anD(xtv x ni' DtCI tueMiroi
nu<ex n
' tt=i.Dodoug."tra(xttC
se
R ButtonIndexens - ) = m eC m_ButtonFocado de la barra.