none
如何实现MSN登入效果? RRS feed

  • 问题

  • 各位老师请指教....

    第一个画面

     

    第二个画面

     

    CODE:

    Imports MySql.Data.MySqlClient
    
    Public Class LoginForm
    
      Public MyValue As String '這行要放在最頂
      Dim nOldWndLeft As Integer
    
      Dim nOldWndTop As Integer
    
      Dim nClickX As Integer
    
      Dim nClickY As Integer
    
      Private Sub Panel_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel.MouseDown
    
        '紀錄滑鼠點選時的視窗位置與滑鼠點選位置 
    
        nOldWndLeft = Me.Left
    
        nOldWndTop = Me.Top
    
        nClickX = e.X
    
        nClickY = e.Y
    
      End Sub
    
      Private Sub Panel_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel.MouseMove
        If Panel.Capture = True Then   '如果滑鼠按著拖曳 
    
          '設定新的視窗位置 
    
          Me.Top = e.Y + nOldWndTop - nClickY
    
          Me.Left = e.X + nOldWndLeft - nClickX
    
          '更新紀錄的視窗位置 
    
          nOldWndLeft = Me.Left
    
          nOldWndTop = Me.Top
    
        End If
    
      End Sub
    
    
      Private Sub Updata(ByVal url As String)
        CUpdata.DownloadFileAsync(New Uri(url), "version.tmp")
      End Sub
      Private Sub Login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'MySQL
        Dim MySqlConnection As MySqlConnection
    
        MySqlConnection = New MySqlConnection()
    
        MySqlConnection.ConnectionString = "server=localhost; user id=vbuser; password=123; database=vb; CHARSET=big5;"
        Try
          MySqlConnection.Open()
          'MsgBox("成功連接到數據庫。", MsgBoxStyle.Information, "Database")
        Catch myerror As MySqlException
          MsgBox("無法連接數據庫。", MsgBoxStyle.Critical, "Database")
        End Try
        Dim myadapter As New MySqlDataAdapter
        Dim sqlquary = "SELECT * FROM user WHERE username = '" + iNetUser.Text + "' AND password = '" + iNetPwd.Text + "';"
        Dim command As New MySqlCommand
        command.Connection = MySqlConnection
        command.CommandText = sqlquary
        myadapter.SelectCommand = command
        Dim mydata As MySqlDataReader
        mydata = command.ExecuteReader()
        If mydata.HasRows = 0 Then
          MsgBox("輸入資料有誤,請再次確認。", MsgBoxStyle.Critical, "Error")
          'Start remember
          My.Settings.Rmbinfo = ""
          My.Settings.Save()
          My.Settings.Reload()
          'txtUser.Text = ""
          iNetUser.Focus()
          iNetPwd.Clear()
        Else
          'Start remember
          My.Settings.Rmbinfo = iNetUser.Text
          My.Settings.Save()
          My.Settings.Reload()
    
          'Check updata
          Dim data As String = My.Computer.FileSystem.ReadAllText("version.tmp")
          Dim Newdata As String
          Newdata = Application.ProductVersion
          If data = Newdata Then
            MainForm.Show()
            Me.Close()
          End If
          If data > Newdata Then
            DownloadNewVersion.Show()
            Me.Close()
          End If
        End If
        'Start remember
        'If CheckBox2.Checked = True Then
        'My.Settings.Password = TextBox1.Text
        'My.Settings.Save()
        'My.Settings.Reload()
        'Else
        'My.Settings.Password = ""
        'My.Settings.Save()
        'My.Settings.Reload()
        'ComboBox1.Text = ""
        'End If
      End Sub
    
      Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'My.Computer.Audio.Play(My.Resources.start, AudioPlayMode.Background)
        Me.Hide()
        Timer1.Start()
        iNetUser.Text = My.Settings.Rmbinfo
        MyValue = iNetUser.Text
      End Sub
    
      Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Shell("Explorer http://hk.yahoo.com", vbNormalFocus)
      End Sub
    
      Private Sub LinkLabel2_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel2.LinkClicked
        RegForm.Show()
      End Sub
    
      Private Sub LinkLabel3_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel3.LinkClicked
        Shell("Explorer mailto:rocky_chun@devil-angel.nets.hk", vbNormalFocus)
      End Sub
    
      Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Updata("http://localhost/version.txt")
        Timer1.Stop()
      End Sub
    
      Private Sub 開啟INetMessengeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 開啟INetMessengeToolStripMenuItem.Click
        Me.Show()
      End Sub
    
      Private Sub 退出INetToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出INetToolStripMenuItem.Click
        Application.Exit()
      End Sub
    
      Private Sub INet網站ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles INet網站ToolStripMenuItem.Click
        Shell("Explorer http://hk.yahoo.com", vbNormalFocus)
      End Sub
    
      Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
        'My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "*", Application.StartupPath & "iNet Messenger.exe")
      End Sub
    End Class
    
    2010年10月8日 5:03

答案

  • 你好

    你做到你想做的效果嗎? 如果做到的話可不可以分享一下你的SOURCE CODE?

    我也做了一個小小的SAMPLE 不知道能不能達成你想要的效果

    可以到以下URL DOWNLOAD 這個SAMPLE
    http://blog.sharechiwai.com/?attachment_id=778
    如果可以的話...請給我Feedback/Suggestion..待我知道怎樣可以改進這個SAMPEL

    大家一起交流交流


    Chi
    • 已标记为答案 Mr.Frankie 2010年10月9日 12:02
    • 取消答案标记 Mr.Frankie 2010年10月9日 12:49
    • 已标记为答案 Mr.Frankie 2010年10月12日 6:26
    2010年10月9日 9:31
    版主

全部回复