nxbigdaddy 发表于 2010-1-11 23:11:04

如何实现客户端的登录及页面切换???

本帖最后由 nxbigdaddy 于 2010-1-12 18:29 编辑

我想找做一个小工具,需要先登录,验证方面我都可以实现,就是不知道,登录的过程怎么实现,有大侠给说说吗!?

范统.贾 发表于 2010-1-12 03:52:34

登陆什么?
表述不清楚。

水木子 发表于 2010-1-12 09:25:26

本帖最后由 水木子 于 2010-1-12 09:28 编辑

LZ是要这样吗?#NoTrayIcon
#Include <Array.au3>
#Include <GuiEdit.au3>
#include <WindowsConstants.au3>
$dir = @ScriptDir&"\Data.ini"

$Form1 = GUICreate("登陆界面", 330, 220)
$Label1 = GUICtrlCreateLabel("账号:", 40, 50, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("密码:", 40, 100, 52, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("注册", 260, 50, 36, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$Input1 = GUICtrlCreateInput("", 90, 50, 160, 21)
$Input2 = GUICtrlCreateInput("", 90, 100, 160, 21, BitOR($ES_LOWERCASE, $ES_PASSWORD))
$Button1 = GUICtrlCreateButton("登陆", 100, 168, 70, 30, $WS_GROUP)
$Button2 = GUICtrlCreateButton("退出", 200, 168, 70, 30, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $Button2 ,-3
                        Exit
                Case $Button1
                        Login()
                Case $Label3
                        zhuce()
        EndSwitch
WEnd

Func Login()
        $zh = GUICtrlRead($Input1)
        $Pass = GUICtrlRead($Input2)
        If $zh <> '' And $Pass <> '' Then
                $a = IniRead($dir, "Data", $zh, "NotFound")
                If $a == $Pass Then
                        MsgBox(64,'提示','登陆成功,谢谢使用。')
                Else
                        MsgBox(48 ,'错误' ,'密码错误,请确认。')
                EndIf       
        Else
                MsgBox(48 ,'错误' ,'请正确输入登陆信息')
        EndIf       
EndFunc       

Func zhuce()
        GUISetState(@SW_DISABLE,$Form1)
        $Form11 = GUICreate("注册账号", 300, 260)
        $Label11 = GUICtrlCreateLabel("账号:", 50, 30, 52, 24)
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label12 = GUICtrlCreateLabel("密码:", 50, 100, 52, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label13 = GUICtrlCreateLabel("确认密码:", 20, 150, 84, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Input11 = GUICtrlCreateInput("", 100, 30, 150, 21)
    $Input12 = GUICtrlCreateInput("", 100, 100, 150, 21, BitOR($ES_LOWERCASE, $ES_PASSWORD))
    $Input13 = GUICtrlCreateInput("", 100, 150, 150, 21, BitOR($ES_LOWERCASE, $ES_PASSWORD))
    $Button11 = GUICtrlCreateButton("注册", 100, 200, 60, 30, $WS_GROUP)
    $Button12 = GUICtrlCreateButton("取消", 200, 200, 60, 30, $WS_GROUP)
        $Button13 = GUICtrlCreateButton("确认账号是否可用", 100, 55, 150, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)

    While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case -3,$Button12
                                        GUISetState(@SW_ENABLE,$Form1)         
                                        GUIDelete($Form11)                     
                                        ExitLoop
                        Case $Button11
                                        $zh = GUICtrlRead($Input11)
                                        $Pass1 = GUICtrlRead($Input12)
                                        $Pass2 = GUICtrlRead($Input13)
                                        If $zh <> "" And $Pass1 <> "" And $Pass2 <> "" Then
                                                If $Pass1 == $Pass2 Then
                                                        IniWrite ( $dir, "Data", $zh, $Pass1 )
                                                        MsgBox(64 ,'提示' ,'注册成功')
                                                Else
                                                        MsgBox(48 ,'错误' ,'请确认两次密码输入相同')
                                                EndIf       
                                        Else
                                                MsgBox(48 ,'错误' ,'请正确输入注册信息')
                                        EndIf       
                        Case $Button13                                       
                                        $a = IniReadSection($dir ,"Data")
                                        $zh = GUICtrlRead($Input11)
                                        If $zh <> '' Then
                                                If        _ArraySearch($a, $zh) = -1 Then
                                                        GUICtrlSetData($Button13,'此账号可用')
                                                Else
                                                        GUICtrlSetData($Button13,'此账号已注册')
                                                EndIf
                                        Else
                                                GUICtrlSetData($Button13,'账号不能留空')
                                        EndIf       
                EndSwitch
        WEnd
EndFunc               

nxbigdaddy 发表于 2010-1-13 17:20:13

谢谢楼上,切换界面如何实现呢!?
页: [1]
查看完整版本: 如何实现客户端的登录及页面切换???