frmlogin.frm

来自「使用VB仿QQ界面开发的ICQ程序,采用C/S结架,实现简单文字聊天.」· FRM 代码 · 共 612 行 · 第 1/2 页

FRM
612
字号
            Name            =   "Times New Roman"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   1
         BCOL            =   14215660
         FCOL            =   0
         FCOLO           =   0
         EMBOSSM         =   12632256
         EMBOSSS         =   16777215
         MPTR            =   0
         MICON           =   "frmLogin.frx":7881
         ALIGN           =   0
         ICONAlign       =   0
         ORIENT          =   0
         STYLE           =   0
         IconSize        =   2
         SHOWF           =   -1  'True
         BSTYLE          =   0
         OPTVAL          =   0   'False
         OPTMOD          =   0   'False
         GStart          =   0
         GStop           =   16711680
         GStyle          =   0
      End
      Begin VB.CheckBox chkLogin 
         Caption         =   "隐身登录"
         Height          =   255
         Left            =   2520
         TabIndex        =   7
         Top             =   1320
         Width           =   1215
      End
      Begin VB.CheckBox chkPwd 
         Caption         =   "记住密码"
         Height          =   255
         Left            =   1200
         TabIndex        =   6
         Top             =   1320
         Width           =   1215
      End
      Begin VB.TextBox txtPassword 
         BackColor       =   &H00FFFFFF&
         Height          =   285
         IMEMode         =   3  'DISABLE
         Left            =   1200
         PasswordChar    =   "*"
         TabIndex        =   1
         Text            =   "admin"
         Top             =   840
         Width           =   2295
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "OK"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFFFF&
         Height          =   195
         Left            =   3840
         TabIndex        =   9
         Top             =   960
         Width           =   255
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "OK"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00404040&
         Height          =   195
         Left            =   3840
         TabIndex        =   10
         Top             =   960
         Width           =   255
      End
      Begin VB.Image Image3 
         Height          =   150
         Left            =   3600
         Top             =   960
         Width           =   150
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "IM密码:"
         Height          =   195
         Left            =   360
         TabIndex        =   5
         Top             =   930
         Width           =   750
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "IM帐号:"
         Height          =   195
         Left            =   360
         TabIndex        =   4
         Top             =   450
         Width           =   750
      End
   End
   Begin VB.Image Image1 
      Height          =   810
      Left            =   0
      Picture         =   "frmLogin.frx":789D
      Stretch         =   -1  'True
      Top             =   0
      Width           =   4815
   End
   Begin VB.Image Green 
      Height          =   150
      Left            =   1800
      Picture         =   "frmLogin.frx":9641
      Top             =   2880
      Visible         =   0   'False
      Width           =   150
   End
   Begin VB.Image Red 
      Height          =   150
      Left            =   1560
      Picture         =   "frmLogin.frx":96BA
      Top             =   2880
      Visible         =   0   'False
      Width           =   150
   End
   Begin VB.Menu mnuMyKIM 
      Caption         =   "&File"
      Visible         =   0   'False
      Begin VB.Menu mnuRegister 
         Caption         =   "&Register"
      End
      Begin VB.Menu mnuMyKIMExit 
         Caption         =   "&Exit"
      End
   End
   Begin VB.Menu mnuEdit 
      Caption         =   "&Accounts"
      Visible         =   0   'False
      Begin VB.Menu mnuAddAcount 
         Caption         =   "&Add New Account"
      End
      Begin VB.Menu mnuAccountSep1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuRemove 
         Caption         =   "Remove"
      End
      Begin VB.Menu mnuRename 
         Caption         =   "Rename"
      End
      Begin VB.Menu mnuChangeIcon 
         Caption         =   "Change Acct. Icon"
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "&Help"
      Visible         =   0   'False
      Begin VB.Menu mnuHelpAbout 
         Caption         =   "&About"
      End
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Dim YourSN As String    '用户帐号

Private Sub CmdApply_Click()
  txtIpAddress.Enabled = False
  txtPort.Enabled = False
  CmdApply.Enabled = False
  Call WritePrivateProfileString("Net Information", "LocalIP", txtIpAddress.Text, App.Path + "\Setup.ini")
  Call WritePrivateProfileString("Net Information", "LocalPort", txtPort.Text, App.Path + "\Setup.ini")
  MsgBox "OK!设置完成,请重新启动程序!", vbInformation
End Sub

Private Sub CmdEdit_Click()
  txtIpAddress.Enabled = True
  txtPort.Enabled = True
End Sub

Private Sub CmdOptions_Click()
  If Me.Height < 4000 Then
     Me.Height = 5455
     CmdOptions.Caption = "恢复"
   Else
     Me.Height = 3780
     CmdOptions.Caption = "高级设置"
  End If
End Sub

Private Sub Form_Initialize()
  InitCommonControls
End Sub

Private Sub Form_Load()

Image3.Picture = Red.Picture
Me.Height = 3780

txtPort.Text = GetKey(App.Path + "\Setup.ini", "LocalPort")
txtIpAddress.Text = GetKey(App.Path + "\Setup.ini", "LocalIP")
'If txtPort.Text = "" Or txtIpAddress.Text = "" Then MsgBox ("网络配置错误,请重新设置!"), vbInformation
gPort = Trim(txtPort.Text)
gHostIP = Trim(txtIpAddress.Text)
CmdApply.Enabled = False

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
 If Not FinalClose Then
    Me.WindowState = 1
    Cancel = 1
 End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
  End
End Sub

Private Sub CmdLogin_Click()
   If CobUser.Text = "" Then MsgBox "请输入您的系统帐号!", vbCritical: Exit Sub
   If txtPassword = "" Then MsgBox "密码不能为空,请输入您的密码!", vbCritical: Exit Sub
   YourSN = CobUser.Text

   If frmClient.Winsock1.State <> sckClosed Then frmClient.Winsock1.Close
   frmClient.Winsock1.RemotePort = gPort '1008
   'frmClient.Winsock1.RemoteHost = "216.77.225.246" 'put your IP here and comment out the one below
   frmClient.Winsock1.RemoteHost = gHostIP '"127.0.0.1"       'to allow people to connect to your IP
   frmClient.Winsock1.Connect

Do Until frmClient.Winsock1.State = sckConnected
   DoEvents: DoEvents: DoEvents: DoEvents
   If frmClient.Winsock1.State = sckError Then
      MsgBox "Could not connect to server! The server may be down or you may not be connected to the Internet. Check your connection and try again. If you still cannot connect wait until a later time when the server will be up."
      Exit Sub
   End If
Loop

   frmClient.Winsock1.SendData (".login" & " " & YourSN & " " & LCase(txtPassword.Text))
End Sub

Private Sub CobUser_KeyPress(KeyAscii As Integer)
 If KeyAscii = 13 Then
   SendKeys "{Tab}"
   KeyAscii = 0
  End If
End Sub

Private Sub txtIpAddress_Change()
  CmdApply.Enabled = True
End Sub

Private Sub txtPort_Change()
  CmdApply.Enabled = True
End Sub

Private Sub txtPassword_Change()
 If txtPassword.Text <> "" Then
    Image3.Picture = Green.Picture
  Else
    Image3.Picture = Red.Picture
 End If
End Sub

Private Sub txtPassword_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
     SendKeys "{Tab}"
     KeyAscii = 0
  End If
End Sub

Private Sub CmdRegister_Click()
  frmWizard.Show vbModal
End Sub

Private Sub CmdExit_Click()
  FinalClose = True
  Unload Me
End Sub

⌨️ 快捷键说明

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