Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

user control as a custom toolbar

$
0
0
i want to disable a button each time i press another button
this is the code for the custom control named ACPRibbon1
cant figure it out
Code:

Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Const MAX_PATH = 260

Private Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100
Private Const FORMAT_MESSAGE_ARGUMENT_ARRAY = &H2000
Private Const FORMAT_MESSAGE_FROM_HMODULE = &H800
Private Const FORMAT_MESSAGE_FROM_STRING = &H400
Private Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Private Const FORMAT_MESSAGE_IGNORE_INSERTS = &H200
Private Const FORMAT_MESSAGE_MAX_WIDTH_MASK = &HFF
Private Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long

Dim TotalButton As Integer
Dim TotalTabs As Integer
Dim TotalCats As Integer
Dim TabSelected As String
Dim TabID(30) As String
Dim TabC(30) As String
Dim CatsID(30) As String
Dim CatsC(30) As String
Dim CatsT(30) As String
Dim CatsD(30) As Boolean

Dim TopBuID(90) As String
Dim TopBuS(90) As String
Dim TopBuC(90) As String
Dim TopBuI(90) As Picture
Dim TopBuT(90) As String
Dim TopBuG(90) As Boolean

Dim MS As Boolean
Dim Mx, My As Integer
Event TabClick(ByVal ID As String, ByVal Caption As String)
Event CatClick(ByVal ID As String, ByVal Caption As String)
Event ButtonClick(ByVal ID As String, ByVal Caption As String)
Const m_def_Theme = 0
Const m_def_BC = False
Dim m_Theme As Variant
Dim m_BC As Boolean
Dim zImg As ImageList

Dim TAB_NORMAL
Dim TAB_SELECTED
Private Sub TabNone(Optional Index As Integer = -1)
    If Index <> -1 Then
        For I = 0 To Index - 1
            If Tab_center_over(I).Visible = True Then
                Tab_center_over(I).Visible = False
                Tab_left_over(I).Visible = False
                Tab_right_over(I).Visible = False
            End If
        Next
        If Tab_center(Index).Visible = False Then
            Tab_center_over(Index).Visible = True
            Tab_left_over(Index).Visible = True
            Tab_right_over(Index).Visible = True
        End If
        For I = Index + 1 To TabMouse.UBound
            If Tab_center_over(I).Visible = True Then
                Tab_center_over(I).Visible = False
                Tab_left_over(I).Visible = False
                Tab_right_over(I).Visible = False
            End If
        Next
    Else
        For I = 0 To TabMouse.UBound
            If Tab_center_over(I).Visible = True Then
                Tab_center_over(I).Visible = False
                Tab_left_over(I).Visible = False
                Tab_right_over(I).Visible = False
            End If
        Next
    End If
End Sub
Private Sub CatNone(Optional Index As Integer = -1)
    If Index <> -1 Then
        For I = 0 To Index - 1
            If Cat_Center_on(I).Visible = True Then
                Cat_Center_on(I).Visible = False
                Cat_Left_on(I).Visible = False
                Cat_Right_on(I).Visible = False
                If Cat_Dlg(I).Visible = True Then
                    Cat_Dlg_on(I).Visible = False
                    Cat_Dlg_over(I).Visible = False
                End If
            End If
        Next
        Cat_Center_on(Index).Visible = True
        Cat_Left_on(Index).Visible = True
        Cat_Right_on(Index).Visible = True
        If Cat_Dlg(Index).Visible = True Then
            Cat_Dlg_on(Index).Visible = True
            Cat_Dlg_over(Index).Visible = False
        End If
        For I = Index + 1 To CatMouse.UBound
            If Cat_Center_on(I).Visible = True Then
                Cat_Center_on(I).Visible = False
                Cat_Left_on(I).Visible = False
                Cat_Right_on(I).Visible = False
                If Cat_Dlg(I).Visible = True Then
                    Cat_Dlg_on(I).Visible = False
                    Cat_Dlg_over(I).Visible = False
                End If
            End If
        Next
    Else
        For I = 0 To CatMouse.UBound
            If Cat_Center_on(I).Visible = True Then
                Cat_Center_on(I).Visible = False
                Cat_Left_on(I).Visible = False
                Cat_Right_on(I).Visible = False
                If Cat_Dlg(I).Visible = True Then
                    Cat_Dlg_on(I).Visible = False
                    Cat_Dlg_over(I).Visible = False
                End If
            End If
        Next
    End If
End Sub
Private Sub ButNone(Optional Index As Integer = -1)
    If Index <> -1 Then
        For KL = 0 To Index - 1
            If Button_center(KL).Visible = True Then
                Button_left(KL).Visible = False
                Button_right(KL).Visible = False
                Button_center(KL).Visible = False
                If Glip_off(I).Visible = True Then
                    Glip_on(I).Visible = False
                End If
            End If
        Next
        If Button_left(Index).Visible = False Then
            Button_left(Index).Visible = True
            Button_center(Index).Visible = True
            Button_right(Index).Visible = True
            If Glip_off(Index).Visible = True Then
                Glip_on(Index).Visible = True
            End If
        End If
        For KL = Index + 1 To ButMouse.UBound
            If Button_center(KL).Visible = True Then
                Button_left(KL).Visible = False
                Button_right(KL).Visible = False
                Button_center(KL).Visible = False
                If Glip_off(I).Visible = True Then
                    Glip_on(I).Visible = False
                End If
            End If
        Next
    Else
        For KL = 0 To ButMouse.UBound
            If Button_center(KL).Visible = True Then
                Button_left(KL).Visible = False
                Button_right(KL).Visible = False
                Button_center(KL).Visible = False
                If Glip_off(I).Visible = True Then
                    Glip_on(I).Visible = False
                End If
            End If
        Next
    End If
End Sub
Private Sub Barra2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone
    CatNone
    ButNone
End Sub
Private Sub BarraLeft_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone
    CatNone
    ButNone
End Sub
Private Sub BarraRight_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone
    CatNone
    ButNone
End Sub
Private Sub ButMouse_Click(Index As Integer)
    RaiseEvent ButtonClick(ButMouse(Index).Tag, Button_Caption(Index).Caption)
End Sub
Private Sub ButMouse_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    Button_left_over(Index).Visible = True
    Button_center_over(Index).Visible = True
    Button_right_over(Index).Visible = True
End Sub
Private Sub ButMouse_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone
    CatNone Button_center(Index).Tag
    ButNone Index
End Sub
Private Sub ButMouse_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    Button_left_over(Index).Visible = False
    Button_center_over(Index).Visible = False
    Button_right_over(Index).Visible = False
End Sub
Private Sub Cat_Dlg_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone
    CatNone Index
    ButNone
End Sub
Private Sub Cat_Dlg_on_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone
    CatNone Index
    ButNone
    Cat_Dlg_over(Index).Visible = True
End Sub
Private Sub Cat_Dlg_over_Click(Index As Integer)
    RaiseEvent CatClick(Cat_Caption(Index).Tag, Cat_Caption(Index).Caption)
End Sub
Private Sub CatMouse_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone
    CatNone Index
    ButNone
End Sub
Private Sub TabMouse_Click(Index As Integer)
    TabNone
    For I = 0 To Index - 1
        Tab_center(I).Visible = False
        Tab_left(I).Visible = False
        Tab_right(I).Visible = False
        Tab_caption(I).ForeColor = TAB_NORMAL
    Next
    Tab_caption(Index).ForeColor = TAB_SELECTED
    Tab_center(Index).Visible = True
    Tab_left(Index).Visible = True
    Tab_right(Index).Visible = True
    For I = Index + 1 To TabMouse.UBound
        Tab_center(I).Visible = False
        Tab_left(I).Visible = False
        Tab_right(I).Visible = False
        Tab_caption(I).ForeColor = TAB_NORMAL
    Next
    TabSelected = TabID(Index)
    CatsUpdate
    RaiseEvent TabClick(TabID(Index), TabC(Index))
End Sub
Private Sub TabMouse_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    TabNone Index
    CatNone
    ButNone
End Sub
Private Sub UserControl_Initialize()
    Barra2.Top = -(26 * 15)
    BarraLeft.Top = Barra2.Top
    BarraRight.Top = Barra2.Top

    UserControl.Height = Barra2.Height
    Barra2.Width = 2048 * 15
    TotalTopButton = 0
    TotalButton = 0
    TotalTabs = 0
    TotalCats = 0
    TabSelected = ""
    TabMouse(0).BackStyle = 0
    CatMouse(0).BackStyle = 0
    ButMouse(0).BackStyle = 0
End Sub
Private Sub TabsUpdate()
    On Error Resume Next
    For I = 1 To (TotalTabs - 1)
        Unload Tab_caption(I)
        Unload Tab_left(I)
        Unload Tab_center(I)
        Unload Tab_right(I)
        Unload Tab_left_over(I)
        Unload Tab_center_over(I)
        Unload Tab_right_over(I)
        Unload TabMouse(I)
    Next
    For I = 0 To (TotalTabs - 1)
        If I <> 0 Then
            Load Tab_caption(I)
            Load Tab_left(I)
            Load Tab_center(I)
            Load Tab_right(I)
            Load Tab_left_over(I)
            Load Tab_center_over(I)
            Load Tab_right_over(I)
            Load TabMouse(I)
            Tab_left(I).Left = Tab_right(I - 1).Left + Tab_right(I).Width
        Else
            Tab_left(0).Left = 90
        End If
        TabMouse(I).Left = Tab_left(I).Left
       
        Tab_caption(I).Top = 0 + 60
        Tab_center(I).Top = 0
        Tab_left(I).Top = 0
        Tab_right(I).Top = 0
        Tab_center_over(I).Top = 0
        Tab_left_over(I).Top = 0
        Tab_right_over(I).Top = 0
        TabMouse(I).Top = 0
       
        Tab_caption(I) = TabC(I)
        Tab_center(I).Width = Tab_caption(I).Width
        Tab_center(I).Left = Tab_left(I).Left + Tab_left(I).Width
        Tab_caption(I).Left = Tab_center(I).Left
        Tab_right(I).Left = Tab_center(I).Left + Tab_center(I).Width
       
        Tab_center_over(I).Width = Tab_center(I).Width
        Tab_center_over(I).Left = Tab_center(I).Left
        Tab_left_over(I).Left = Tab_left(I).Left
        Tab_right_over(I).Left = Tab_right(I).Left
       
        TabMouse(I).Width = Tab_left(I).Width + Tab_right(I).Width + Tab_center(I).Width
       
        Tab_caption(I).ForeColor = TAB_NORMAL
       
        Tab_caption(I).Visible = True
        If I = 0 Then
            Tab_center(I).Visible = True
            Tab_left(I).Visible = True
            Tab_right(I).Visible = True
            Tab_caption(I).ForeColor = TAB_SELECTED
        End If
        TabMouse(I).Visible = True
   
        Tab_center(I).ZOrder 0
        Tab_left(I).ZOrder 0
        Tab_right(I).ZOrder 0
       
        Tab_center_over(I).ZOrder 0
        Tab_left_over(I).ZOrder 0
        Tab_right_over(I).ZOrder 0
       
        Tab_caption(I).ZOrder 0
        TabMouse(I).ZOrder 0
    Next
End Sub

this is continued from other post
http://www.vbforums.com/showthread.p...ar#post4423421

Viewing all articles
Browse latest Browse all 21243

Trending Articles