ក្នុងប្រកាសនេះ អាយធីជនបទ សូមបង្ហាញពីរបៀបបង្កើតLOGIN User Interfaceដែលប្រើរូបភាពជាBackground ហើងក្នុងនេះ យើងអាចផ្លាស់ទីវាបានផងដែរ។
កំណត់Propertiesរបស់Form
- Name : frmLogin
- AcceptButton : cmdlogin
- BackColor : Black
- BackgroundImage : រូបភាពរបស់អ្នកណាមួយដែលមានកន្ទុយ(.png) ឬអាចទាញយកResourceពី< a href="">ទីនេះ
- BackgroundImagelayout: Stretch
- StartPosition: CenterScreen
- TransparencyKey: Black
កំណត់Propertiesរបស់Button LOGIN
- Name : cmdlogin
- AcceptButton : cmdlogin
- BackColor : White
- BackgroundImage : រូបភាពរបស់អ្នកណាមួយដែលមានកន្ទុយ(.png) ឬអាចទាញយកResourceពី< a href="">ទីនេះ
- BackgroundImagelayout: Stretch
កំណត់Propertiesរបស់TextBox Username
- Name : txtusername
- BackColor: ScrollBar
- BorderStyle: FixedSingle
- Tag:admin (អ្នកអាចដាក់អ្វីក៏បានសំរាប់ជាឈ្មោះអ្នកប្រើ(Username)
កំណត់Propertiesរបស់TextBox Password
- Name : txtpassword
- BackColor: ScrollBar
- BorderStyle: FixedSingle
- Tag:12345 (អ្នកអាចដាក់អ្វីក៏បានសំរាប់ជាលេខសំងាត់(Password)
- PasswordChar: ♥ (អ្នកអាចដាក់អីក៏បាន)
អនុវត្តការសរសេរកូដ
- Public Class frmLogin
- Dim drag As Boolean
- Dim Y As Integer
- Dim X As Integer
- Private Sub cmdlogin_Click(sender As Object, e As EventArgs) Handles cmdlogin.Click
- If txtUsername.Text = txtUsername.Tag And txtpassword.Text = txtpassword.Tag Then
- MessageBox.Show("Username and Password accepted.", "LOGIN FORM", MessageBoxButtons.OK, MessageBoxIcon.Information)
- txtUsername.Clear()
- txtpassword.Clear()
- txtUsername.Focus()
- Else
- MessageBox.Show("Niether Username nor Password accepted.", "LOGIN FORM", MessageBoxButtons.OK, MessageBoxIcon.Error)
- txtpassword.Clear()
- txtUsername.Focus()
- txtUsername.SelectionStart = 0
- txtUsername.SelectionLength = Len(txtUsername.Text)
- End If
- End Sub
- Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
- drag = True
- Y = Windows.Forms.Cursor.Position.Y - Me.Top
- X = Windows.Forms.Cursor.Position.X - Me.Left
- End Sub
- Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
- If e.Button = Windows.Forms.MouseButtons.Left Then
- If drag Then
- Me.Top = Windows.Forms.Cursor.Position.Y - Y
- Me.Left = Windows.Forms.Cursor.Position.X - X
- End If
- End If
- End Sub
- Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
- drag = False
- End Sub
- End Class