⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainfrm.frm

📁 电话本信息 基本上实现电话功能 自己下载侃侃吧
💻 FRM
📖 第 1 页 / 共 5 页
字号:
            Case 33 To 126:
              If (Index < 2) Or (Index > 3) Then GoTo Combo1_C_LOOP1 Else i = i + 1
            Case Else:
Combo1_C_LOOP1:
              j = i
              Do While j < UBound(Bytes)
                Bytes(j) = Bytes(j + 1)
                j = j + 1
              Loop
              If j < 1 Then
                ReDim Bytes(0)
                Exit Do
              Else
                ReDim Preserve Bytes(j - 1)
              End If
              If i > j Then Exit Do
         End Select
      Loop While i <= UBound(Bytes)
      STR1 = StrConv(Bytes, vbUnicode): j = Len(STR1)
      If j <> Len(Combo1(Index).Text) Then
        Flag = True
        Combo1(Index).ListIndex = -1
        Combo1(Index).Text = STR1
        Flag = False
        Combo1(Index).SelStart = IIf(j < S, j, S)
    End If
    i = Len(Trim(Combo1(Index).Text))
    CEdit(0).Enabled = i > 0
    CEdit(1).Enabled = i > 0 And SelCombo.ListCount > 0
    CEdit(2).Enabled = False
    If i Then
      For i = 0 To Combo1(Index).ListCount - 1
        If UCase(Trim(Combo1(Index).Text)) = UCase(Trim(Combo1(Index).List(i))) Then
          CEdit(0).Enabled = False
          CEdit(1).Enabled = False
          CEdit(2).Enabled = True
          ComboListIndex(Index) = i
          Exit For
        End If
      Next i
    End If
  End Select
End Sub

Private Sub Combo1_GotFocus(Index As Integer)
  Dim i As Long
  On Error Resume Next
  
  If Not SelCombo Is Nothing Then
    If SelCombo.Index = Index Then Exit Sub
  End If
  If Frame3.Visible Then
     SelCombo.Width = SelCombo.Width + 650
     Frame3.Visible = False
     SelCombo.SelLength = 0
     Set SelCombo = Nothing
  End If
  
  If (EditIndex <> 0) And (Index > 0) Then
    Combo1(Index).Width = Combo1(Index).Width - 650
    Frame3.Top = Combo1(Index).Top
    Frame3.Left = Combo1(Index).Left + Combo1(Index).Width + 50
    i = Len(Trim(Combo1(Index).Text))
    CEdit(0).Enabled = i > 0
    CEdit(1).Enabled = i > 0
    CEdit(2).Enabled = False
    For i = 0 To Combo1(Index).ListCount - 1
      If UCase(Trim(Combo1(Index).Text)) = UCase(Trim(Combo1(Index).List(i))) Then
         CEdit(0).Enabled = False
         CEdit(1).Enabled = False
         CEdit(2).Enabled = True
         ComboListIndex(Index) = i
        Exit For
      End If
    Next i
    Frame3.Visible = True
    Set SelCombo = Combo1(Index)
  End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
  DisposeImage
  UnLockFormSize
End Sub

Private Sub IC1_Click()
  If EditIndex Then TB1.Buttons("tSave").Enabled = True
End Sub

Private Sub M_New_Click()
  If EditIndex Then
    If MsgBox("提示:" & vbCrLf & "你已经修改了 " & TV1.Nodes("L" & EditIndex).Text & " 用户信息,是否保存当前信息?", vbQuestion Or vbYesNo, Me.Caption) = vbYes Then
      TB1_ButtonClick TB1.Buttons("tSave")
    ElseIf EditIndex < 0 Then
      TV1.Nodes.Remove "L-1"
    End If
  End If
  If TV1.SelectedItem Is Nothing Then
    TV1.Nodes.Add "R0", 4, "L-1", "NewUser", 20
  ElseIf Left(TV1.SelectedItem.Key, 1) = "L" Then
    TV1.Nodes.Add TV1.SelectedItem.Parent.Key, 4, "L-1", "NewUser", 20
  Else
    TV1.Nodes.Add TV1.SelectedItem.Key, 4, "L-1", "NewUser", 20
  End If
  ClearALL True, True
  CImage(0).Enabled = True
  T1(0).Text = "NewUser"
  TV1.Nodes("L-1").ForeColor = LColor
  TV1.Nodes("L-1").Selected = True
  IC1.ComboItems(1).Selected = True
  EditIndex = -1
  T1(0).SetFocus
  T1(0).SelStart = 0
  T1(0).SelLength = 7
  Combo1(0).ListIndex = 0
  TB1.Buttons("tSave").Enabled = True
  TB1.Buttons("tDel").Enabled = True
  TB1.Buttons("tOpen").Enabled = False
  TB1.Buttons("tClose").Enabled = False
  TB1.Buttons("tEdit").Enabled = True
  TB1.Buttons("tEditR").Enabled = False
  TB1.Buttons("tNewR").Enabled = False
  TB1.Buttons("tNew").Enabled = False
End Sub

Private Sub PBox_Click()
  If Not LT1.Visible Then
    Load ImageFrm
    ImageFrm.Show 1
    TV1.SetFocus
  End If
End Sub

Private Sub T1_Change(Index As Integer)
  Dim Bytes() As Byte, i As Long, STR1 As String, j As Long, S As Long, Nums As Integer
  Static Flag As Boolean
  
  If (EditIndex = 0) Or Flag Then Exit Sub
  TB1.Buttons("tSave").Enabled = True
  If Index = 0 Then Exit Sub
  If Len(T1(Index).Text) = 0 Then Exit Sub
  S = T1(Index).SelStart
  Bytes() = StrConv(T1(Index).Text, vbFromUnicode)
  Do
    Select Case Bytes(i)
       Case &H30 To &H39:
         i = i + 1
       Case 45:
         If Index > 1 Then
           If Nums > 1 Then
             ReDim Preserve Bytes(i - 1)
           Else
             If i = 0 Then GoTo T1_C_LOOP1
             If Bytes(i - 1) = 45 Then
               GoTo T1_C_LOOP1
             Else
               i = i + 1
               Nums = Nums + 1
             End If
           End If
         Else
           i = i + 1
           Nums = Nums + 1
         End If
       Case 32 To 126:
         If Index > 1 Then GoTo T1_C_LOOP1 Else i = i + 1
       Case Else:
T1_C_LOOP1:
'        Flag = True
'        SendMessage T1(Index).hWnd, EM_UNDO, 0&, 0&
'        Flag = False
'        Exit Sub
        j = i
        Do While j < UBound(Bytes)
          Bytes(j) = Bytes(j + 1)
          j = j + 1
        Loop
        If j < 1 Then
           ReDim Bytes(0)
           Exit Do
        Else
           ReDim Preserve Bytes(j - 1)
        End If
        If i > j Then Exit Do
    End Select
  Loop While i <= UBound(Bytes)
  If UBound(Bytes) = 0 And Bytes(0) = 0 Then
    STR1 = vbNullString: j = 0
  Else
    STR1 = StrConv(Bytes, vbUnicode): j = Len(T1(Index).Text)
  End If
  Flag = True
  T1(Index).Text = STR1
  Flag = False
  If j <> Len(T1(Index).Text) Then T1(Index).SelStart = IIf(j < S, j, S)
End Sub

Private Sub Combo1_Click(Index As Integer)
  Dim i As Long
  ComboListIndex(Index) = Combo1(Index).ListIndex
  CEdit(0).Enabled = False
  CEdit(1).Enabled = False
  CEdit(2).Enabled = True
  TB1.Buttons("tSave").Enabled = Index = 0 And Combo1(0).Enabled
End Sub

Private Sub Form_Load()
  Dim i As Long
  
  On Error Resume Next
  
  Me.Caption = "通讯簿(南宫飘雪) V" & App.Major & "." & Format(App.Minor, "00") '& "." & Format(App.Revision, "00")
  GetTreeView TV1
  For i = 1 To TB1.Buttons.Count
    If Len(TB1.Buttons(i).Caption) Then TB1.Buttons(i).Description = TB1.Buttons(i).Caption
  Next
  Set IC1.ImageList = IList1
  IC1.ForeColor = &HFF0000
  For i = 20 To IList1.ListImages.Count
    IC1.ComboItems.Add , "I" & i, i - 20, i
  Next i
  Combo1(0).AddItem "女"
  Combo1(0).AddItem "男"
  For i = 0 To UBound(ComboListIndex)
    ComboListIndex(i) = -1
  Next
  PBox.BackColor = &HFFFFFF
  ClearALL
  TV1_NodeClick TV1.Nodes(1)
  StatusBar1.Panels(1).Picture = Me.Icon
  StatusBar1.Panels(1).Text = Me.Caption
  Set TB1.DisabledImageList = TIList(1)
'  LockFormSize Me.hwnd
End Sub

Private Sub Form_Resize()
  Dim i As Long
  
  On Error Resume Next
  
  If Me.WindowState <> vbMinimized Then
    Frame1.Width = Me.Width / 2.9520295202952
    Frame1.Height = Me.ScaleHeight - 1035
    Frame2.Height = Frame1.Height
    TV1.Height = Frame1.Height - 585
    TV1.Width = Frame1.Width - 270
    
    Frame2.Left = Frame1.Left + Frame1.Width - 50
    Frame2.Width = Me.Width - Frame2.Left - 150
    PBox.Left = Frame2.Width - 2535
    Frame4.Left = PBox.Left
    For i = 0 To 2
      TA(i).Width = Frame2.Width - 675
    Next
    TA(2).Height = Frame2.Height - 5130
    L1(14).Left = Frame2.Width * 0.357692307692308
    IC1.Left = L1(14).Left + 675
    L1(5).Left = L1(14).Left
    L1(9).Left = L1(5).Left
    L1(8).Left = L1(5).Left
    Combo1(1).Left = IC1.Left
    Combo1(1).Width = PBox.Left - Combo1(1).Left - 100
    T1(3).Width = Combo1(1).Width
    T1(3).Left = IC1.Left
    Combo1(5).Left = Combo1(1).Left
    Combo1(5).Width = Combo1(1).Width
    T1(0).Width = L1(14).Left - T1(0).Left - 145
    T1(1).Width = T1(0).Width
    T1(2).Width = T1(0).Width
    Combo1(0).Width = T1(0).Width
    Combo1(4).Width = T1(0).Width
    Combo1(2).Width = PBox.Left - Combo1(2).Left - 100
    Combo1(3).Width = Combo1(2).Width
    If Frame3.Visible Then
      SelCombo.Width = SelCombo.Width - 650
      Frame3.Left = SelCombo.Left + SelCombo.Width + 50
    End If
    For i = 0 To 5
      Combo1(i).SelLength = 0
    Next
  End If
End Sub

Private Sub m_Clear_Click()
  DelNode TV1.Nodes("R-1")
  TV1_NodeClick TV1.SelectedItem
End Sub

Private Sub m_Del_Click()
  If TV1.SelectedItem Is Nothing Then Exit Sub
  DelNode TV1.SelectedItem
  TV1_NodeClick TV1.SelectedItem
End Sub

Private Sub m_DelR_Click()
  DelNode TV1.SelectedItem
  TV1_NodeClick TV1.SelectedItem
End Sub

Private Sub M_Edit_Click()
  If (TV1.SelectedItem Is Nothing) Or (EditIndex > 0) Then
    TB1.Buttons("tEdit").Value = tbrUnpressed
    StatusBar1.Panels(4).Text = sBar(0)
    Exit Sub
  End If
  EditIndex = Val(Mid(TV1.SelectedItem.Key, 2, Len(TV1.SelectedItem.Key)))
  If EditIndex Then
    ClearALL True, False
    T1(0).SetFocus
    T1(0).SelStart = Len(T1(0).Text)
    TB1.Buttons("tEdit").Value = tbrPressed
    StatusBar1.Panels(4).Text = sBar(1)
  End If
End Sub

Private Sub m_Find_Click()
  Load FindFrm
  FindFrm.Show 1
End Sub

Private Sub m_Open_Click()
  If MoveNode Is Nothing Then
    Set MoveNode = TV1.SelectedItem
  ElseIf MoveNode.Key <> TV1.SelectedItem.Key Then
    Set MoveNode = TV1.SelectedItem
  End If
  If Left(MoveNode.Key, 1) = "L" Then Exit Sub
  UnExpanded MoveNode, True
  Set TV1.SelectedItem = MoveNode
End Sub

Private Sub m_Close_Click()
  If MoveNode Is Nothing Then
    Set MoveNode = TV1.SelectedItem
  ElseIf MoveNode.Key <> TV1.SelectedItem.Key Then
    Set MoveNode = TV1.SelectedItem
  End If
  If Left(MoveNode.Key, 1) = "L" Then Set MoveNode = MoveNode.Parent
  UnExpanded MoveNode
  Set TV1.SelectedItem = MoveNode
End Sub

Private Sub m_NameR_Click()
  On Error Resume Next
  If Left(TV1.SelectedItem, 1) = "L" Then Exit Sub
  TV1.StartLabelEdit
End Sub

Private Sub M_NewR_Click()
  Dim Node1 As Node, i As Long, j As Long
  
  On Error Resume Next
  
  If Left(TV1.SelectedItem.Key, 1) = "L" Then Exit Sub
  Load Form1
  Form1.Caption = M_NewR.Caption
  Form1.Show 1
  Set Form1 = Nothing
  If HasChange <> -100 Then
    GetTreeView TV1
    Set Node1 = TV1.Nodes("R" & HasChange)
    Node1.Selected = True
  End If
  
End Sub

Private Sub m_Remove_Click()
  Dim Node1 As Node, i As Long, j As Long
  On Error Resume Next
  Load Form1
  Set Node1 = TV1.SelectedItem
  Set Form1.MoveNode = Node1
  Form1.Label1(1).Caption = "已选择的目标组名:"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -