Imports System.Runtime.InteropServices

Public Class frmAccesoConfig
#Region "Mov. Pantalla"
    <DllImport("user32.Dll", EntryPoint:="ReleaseCapture")>
    Private Shared Sub ReleaseCapture()

    End Sub

    <DllImport("user32.Dll", EntryPoint:="SendMessage")>
    Private Shared Sub SendMessage(hWnd As IntPtr, wMsg As Integer, wParam As Integer, lParam As Integer)

    End Sub

#End Region
    Private Sub PanelBarraTitulo_MouseMove(sender As Object, e As MouseEventArgs) Handles PanelBarraTitulo.MouseMove
        ReleaseCapture()
        SendMessage(Me.Handle, &H112&, &HF012&, 0)
    End Sub

    Private Sub frmAcceso_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove
        ReleaseCapture()
        SendMessage(Me.Handle, &H112&, &HF012&, 0)
    End Sub

    Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        Acceso()
    End Sub
    Sub Acceso()
        Try
            Dim varPassM As String = Desencriptar(My.Settings.MasterPass)

            If Me.txtPassword.Text = varPassM Then
                If GlobalVariables.varConfig = False Then
                    FrmMain.BtnITConfig.BackColor = Color.FromArgb(245, 97, 27)
                    Me.Close()
                    frmConfig.ShowDialog()
                ElseIf GlobalVariables.varConfig = True Then
                    frmConfig.ShowDialog()
                    Me.Close()
                End If

            Else
                MsgBox("Usuario o Contraseña Inválidos.", MsgBoxStyle.Information, "Mensaje del Sistema")
            End If
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Critical)
        End Try
    End Sub

    Private Sub txtPassword_Click(sender As Object, e As EventArgs) Handles txtPassword.Click
        txtPassword.Text = ""
        txtPassword.Focus()
    End Sub

    Private Sub txtPassword_KeyDown(sender As Object, e As KeyEventArgs) Handles txtPassword.KeyDown
        If e.KeyCode = Keys.Enter Then
            Acceso()
        End If
    End Sub

    Private Sub btnCerrar_Click(sender As Object, e As EventArgs) Handles btnCerrar.Click
        Me.Dispose()
    End Sub

    Private Sub frmAccesoConfig_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.txtPassword.Text = ""
        txtPassword.Focus()
    End Sub
End Class