VERSION 5.00
Begin VB.Form frmServers 
   Caption         =   "Servers/Accounts"
   ClientHeight    =   3960
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8415
   LinkTopic       =   "Form1"
   ScaleHeight     =   3960
   ScaleWidth      =   8415
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdClose 
      Caption         =   "&Close"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   7080
      TabIndex        =   7
      Top             =   3420
      Width           =   1275
   End
   Begin VB.CommandButton cmdDefaultServer 
      Caption         =   "Set Selected Server as Default"
      Height          =   375
      Left            =   3600
      TabIndex        =   6
      Top             =   3480
      Width           =   2775
   End
   Begin VB.CommandButton cmdSetAsDefault 
      Caption         =   "Set phpGW as you default mailto application"
      Height          =   375
      Left            =   60
      TabIndex        =   5
      Top             =   3480
      Width           =   3435
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "&Edit Server"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   7080
      TabIndex        =   4
      Top             =   1680
      Width           =   1275
   End
   Begin VB.CommandButton cmdRemove 
      Caption         =   "&Remove Server"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   7080
      TabIndex        =   3
      Top             =   960
      Width           =   1275
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "&Add Server"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   7080
      TabIndex        =   2
      Top             =   240
      Width           =   1275
   End
   Begin VB.ListBox lstServers 
      Height          =   3180
      IntegralHeight  =   0   'False
      Left            =   0
      TabIndex        =   0
      Top             =   240
      Width           =   6975
   End
   Begin VB.Label Label1 
      Caption         =   "Configured Servers:"
      Height          =   195
      Left            =   60
      TabIndex        =   1
      Top             =   0
      Width           =   1575
   End
End
Attribute VB_Name = "frmServers"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmdAdd_Click()
On Error Resume Next
    Dim i As Long
    
    i = UBound(arrServers)
    Load frmOptions
    frmOptions.AddServer
    frmOptions.Show vbModal
    If i = UBound(arrServers) And i > 0 Then Exit Sub
    
    SaveServers
    Fill_List Me, lstServers, arrServers
    lstServers.ListIndex = lstServers.ListCount - 1
End Sub

Private Sub cmdClose_Click()
    frmMain.InitServers True
    Unload Me
End Sub

Private Sub cmdDefaultServer_Click()
    iDefaultServer = lstServers.ListIndex - 1
    WriteSavedSetting "Options", "DefaultServer", CStr(iDefaultServer)
    Fill_List Me, lstServers, arrServers
    lstServers.ListIndex = iDefaultServer + 1
End Sub

Private Sub cmdEdit_Click()
    Dim i As Long
    Load frmOptions
    i = lstServers.ListIndex - 1
    frmOptions.LoadServer i
    frmOptions.Show vbModal
    SaveServers
    Fill_List Me, lstServers, arrServers
    lstServers.ListIndex = i + 1
End Sub

Private Sub cmdRemove_Click()
    Dim i As Long, j As Long
    i = lstServers.ListIndex - 1
    For j = i To UBound(arrServers) - 1
        arrServers(j) = arrServers(j + 1)
    Next j
    ReDim Preserve arrServers(UBound(arrServers) - 1)
    SaveServers
    Fill_List Me, lstServers, arrServers
    If i >= lstServers.ListCount Then
        lstServers.ListIndex = lstServers.ListCount - 1
    Else
        lstServers.ListIndex = i + 1
    End If
End Sub

Private Sub cmdSetAsDefault_Click()
On Error Resume Next
    Dim sValue As String
    'mailto
    sValue = """" & App.Path & "\" & App.EXEName & ".exe"" /mailurl:%1"
    Dummy = SaveLOCALRegKey("SOFTWARE\Classes\mailto\shell\open\command", "*", sValue)
    sValue = App.Path & "\" & App.EXEName & ".exe,-1"
    Dummy = SaveLOCALRegKey("SOFTWARE\Classes\mailto\DefaultIcon", "*", sValue)
End Sub

Private Sub Form_Load()
    Me.Icon = frmAbout.Icon
    
    If Dir(App.Path & "\servers.dat") = "" Then
        cmdAdd_Click
    Else
        Fill_List Me, lstServers, arrServers
    End If
    lstServers.ListIndex = lstServers.ListCount - 1
End Sub

Private Sub lstServers_Click()
    If lstServers.ListCount > 1 Then
        If lstServers.ListIndex = 0 Then lstServers.ListIndex = 1
    End If
End Sub

Private Sub lstServers_DblClick()
    If lstServers.ListCount > 1 Then
        If lstServers.ListIndex = 0 Then lstServers.ListIndex = 1
    End If
    cmdEdit_Click
End Sub
