Func _AES128($mode,$way,$data,$pass);;使用AES 256 加密解密
Switch $mode
Case 0;;加密
_Crypt_Startup()
Return _Crypt_EncryptData($data,$pass, $way)
Case 1;;解密
_Crypt_Startup()
Return _Crypt_DecryptData($data,$pass, $way)
EndSwitch
EndFunc
Func _whos();;找出有谁,放进选单
Dim $ClogID
Dim $YN = 'N'
$addfld = ObjCreate("ADODB.Connection");;<<++++++从DB取得上一次浏览范围
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $Clog )
while Not $RS.eof And Not $RS.bof
$ClogID = $RS.Fields (1).value
$rs.movenext
WEnd
$rs.close
$addfld.Close;;<<++++++从DB取得上一次浏览范围
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBEnterpriseTable )
GUICtrlSetData($Range,'All','All');;介面显示为All
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If StringInStr($RS.Fields (1).value,$ClogID) = 1 Then $YN = 'Y'
If $RS.Fields (1).value <> '' Then $str = $RS.Fields (1).value
If $RS.Fields (1).value = '' Then $str = 'N/A'
GUICtrlSetData($Range,$str,$ClogID)
$rs.movenext
WEnd
If $YN = 'Y' Then GUICtrlSetData($Range,$ClogID,$ClogID)
If $YN = 'N' Then GUICtrlSetData($Range,'All','All')
$rs.close
$addfld.Close
EndFunc
Func _Range()
$ReadRange = GUICtrlRead($Range)
$SerchItem = "whos"
$CValue = '1'
$addfld = ObjCreate("ADODB.Connection");;<<+++++++纪录选择的范围到DB
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $Clog & " set whos='"&$ReadRange&"' WHERE id" & " = " & $CValue)
$addfld.close;;<<+++++++纪录选择的范围到DB
GUICtrlSendMsg($ListView1,$LVM_DELETEALLITEMS,0,0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
If $ReadRange = "All" Then;;列出全部
$RS.Open ("Select * From " & $DBEnterpriseTable )
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If $RS.Fields (2).value = '' Or $RS.Fields (2).value = Null Or $RS.Fields (2).value = False Then
;;
Else
GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1 )
GUICtrlSetBkColor (-1,0xE9E9E9) ;;设置 偶数行项目背景颜色
EndIf
$rs.movenext
WEnd
Else;;列出指定主人
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & $SerchItem & " ='"&$ReadRange&"'") ;;完整查询语法
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1)
GUICtrlSetBkColor (-1,0xE9E9E9) ;;设置 偶数行项目背景颜色
$rs.movenext
WEnd
EndIf
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
EndFunc
Func _Password();变更密码
$ROldPass = GUICtrlRead($OldPassword)
$RNewPass = GUICtrlRead($NewPassword)
$RCNewPass = GUICtrlRead($ConfirmPasswordAgain)
$Value = '1' ;;密码 所在的 ID
If $FirstUse = 0 Then
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBData )
$DBTEXT = $RS.Fields (2).value
$rs.close
$addfld.Close
EndIf
If $FirstUse = 0 Then
$a=StringSplit($ROldPass,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$ENCPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
EndIf
If $FirstUse = 0 Then
If $ENCPass <> $DBTEXT Then
MsgBox(262144+48,'错误','输入的原始密码错误!请重新再试一次。',$MB_OK)
Return
EndIf
EndIf
If $RNewPass <> $RCNewPass Then
MsgBox(262144+48,'错误','输入的两次新密码不相符!请确认后重试。',$MB_OK)
Return
EndIf
$a=StringSplit($RNewPass,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$ENCPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
$addfld = ObjCreate("ADODB.Connection");;<<+++++++纪录选择的范围到DB
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $DBData & " set pass='"&$ENCPass&"' WHERE id" & " = " & $Value)
$addfld.close;;<<+++++++纪录选择的范围到DB
If $FirstUse = 0 Then
MsgBox(262144+64,'完成','已更新密码!请以新密码重新登入。',5,$MB_OK)
Exit
Else
$FirstUse = 0
EndIf
EndFunc
Func AForm1Close() ;;关闭本程序
If WinExists("关于 "&$Title & ' v' & $ver) Then
GUIDelete($About_gui)
Return 0
Else
If MsgBox(262144+36, "", "确定要退出吗?") = 6 Then
Exit
EndIf
EndIf
EndFunc
Func Button1Click();;查询资料
GUICtrlSetState($Button1,$GUI_DISABLE)
Serch()
GUICtrlSetState($Button1,@SW_ENABLE)
EndFunc
Func Button3Click();;清空栏位
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
GUICtrlSetData($WID,'')
GUICtrlSetState($Enterprise,$GUI_FOCUS) ;;预设光标所在位置
EndFunc
Func Button6Click();;全部删除(删除资料表,可用做索引号重置)
GUICtrlSetState($Button6,$GUI_DISABLE)
$MSGCheck = MsgBox(32+4,'警告','您确定要删除所有帐号资料吗?' & @CRLF & @CRLF & "此操作不能回復,请谨慎使用。" )
If $MSGCheck = 6 Then
DeleteWorkerTable()
Else
Return
EndIf
GUICtrlSetState($Button6,@SW_ENABLE)
Return
EndFunc
Func _runL2()
MsgBox(0,0,'run')
EndFunc
Func Button8Click();;清除列表
GUICtrlSetState($Button8,$GUI_DISABLE)
Clear()
GUICtrlSetState($Button8,@SW_ENABLE)
EndFunc
Func Button9Click ();;复製资料
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
If $Strnspin[1]='0' Then
MsgBox(48,'错误','您没有选择任一项目!')
Return
Else
dataup()
EndIf
EndFunc
Func Button10Click ();;覆写资料
$ReadPrincipal = GUICtrlRead($Principal)
$ReadTelPhone1 = GUICtrlRead($TelPhone1)
GUICtrlSetState($Button10,$GUI_DISABLE)
$RWID = GUICtrlRead($WID)
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
If $ReadPrincipal = '' Then
MsgBox(48,'错误','NC帐号为必填项目!')
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
If StringIsDigit($RWID) = 1 Then;;是否仅包含数字
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & " ID = " & $RWID)
$MSGCheck = MsgBox(32+4,'[编辑] - 警告','您确定将资料写入此ID位置吗?' & @CRLF & @CRLF & "索引号:" & $RS.Fields (0).value & @CRLF & "帐号:" & $RS.Fields (2).value & @CRLF & "备注:" & $RS.Fields (2).value )
$rs.close
$addfld.Close
If $MSGCheck = 6 Then
back()
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
ElseIf $Strnspin[1]='0' Then
MsgBox(48,'错误','您没有选择任一项目!')
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
If $EID = Null Then
$MSGCheck = MsgBox(32+4,'[覆写] - 警告','您确定要覆写到该笔资料吗?' & @CRLF & @CRLF & "索引号:" & $Strnspin[1] & @CRLF & "帐号:" & $Strnspin[3] & @CRLF & "备注:" & $Strnspin[4] )
If $MSGCheck = 6 Then
back()
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
EndIf
If $EID <> Null Then
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & " ID = " & $EID) ;;模煳查询语法
$MSGCheck = MsgBox(32+4,'[编辑] - 警告','您确定要完成编辑本笔资料吗?' & @CRLF & @CRLF & "索引号:" & $RS.Fields (0).value & @CRLF & "帐号:" & $RS.Fields (2).value & @CRLF & "备注:" & $RS.Fields (4).value )
$rs.close
$addfld.Close
If $MSGCheck = 6 Then
back()
$EID = Null
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
$MSGCheckA = MsgBox(32+4,'[编辑] - 警告','那您要更新资料到所选项吗?' & @CRLF & @CRLF & "索引号:" & $Strnspin[1] & @CRLF & "帐号:" & $Strnspin[3] & @CRLF & "备注:" & $Strnspin[4])
If $MSGCheckA = 6 Then
$EID = Null
back()
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
EndIf
EndIf
EndIf
EndFunc
Func Button11Click ();;删除所选项目
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$MSGCheck = MsgBox(32+4,'警告','您定要删除该笔资料吗?' & @CRLF & @CRLF & "索引号:" & $Strnspin[1] & @CRLF & "帐号:" & $Strnspin[3] & @CRLF & "备注:" & $Strnspin[4] )
If $MSGCheck = 6 Then
del()
Else
Return
EndIf
EndFunc
Func read();;读取资料到LIST
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBEnterpriseTable )
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If $RS.Fields (2).value = '' Or $RS.Fields (2).value = Null Or $RS.Fields (2).value = False Then
;;
Else
GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1 )
EndIf
$rs.movenext
WEnd
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
$EID = Null
_whos()
_SerchNull()
EndFunc
Func _SerchNull();;搜索没有资料的ID
Local $L
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & 'userid IS NULL OR' & " userid = ''")
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
$L = $L & '|' & $RS.Fields (0).value
$rs.movenext
WEnd
GUICtrlSetData($WID,'' & '|'& $L,'')
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
EndFunc
Func del();;删除项目(屏蔽/保留索引号)
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$NULL = ''
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $DBEnterpriseTable & " set whos='"&$NULL&"',userid='"&$NULL&"',pass='"&$NULL&"',deputation='"&$NULL&"' WHERE id" & " = " & $Strnspin[1])
$addfld.close
read()
EndFunc
Func dataup();;复製所选资料到编辑窗格
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBEnterpriseTable & " WHERE id" & " = " & $Strnspin[1])
$a=StringSplit(BinaryToString(_AES128(1,$CALG_AES_128,$RS.Fields (3).value,$AES_pwd)),"|",2);;<<++++++解密DEC
For $i=0 To UBound($a)-1
$a[$i]=ChrW($a[$i])
Next
$UserPass=""
For $i=0 To UBound($a)-1
$UserPass=$UserPass&$a[$i]
Next;;<<++++++解密DEC
GUICtrlSetData($Enterprise,$RS.Fields (1).value)
GUICtrlSetData($Principal,$RS.Fields (2).value)
GUICtrlSetData($TelPhone1,$UserPass)
GUICtrlSetData($FaxPhone1,$RS.Fields (4).value)
$rs.movenext
$rs.close
$addfld.Close
EndFunc
Func back();;复写(更新)所选项目的资料
$ReadEnterprise = GUICtrlRead($Enterprise)
If $ReadEnterprise = '' Then $ReadEnterprise = 'N/A'
$ReadPrincipal = GUICtrlRead($Principal)
$ReadTelPhone1 = GUICtrlRead($TelPhone1);;<<++++++加密ENC
$a=StringSplit($ReadTelPhone1,"",2)
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$UserPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
$ReadFaxPhone1 = GUICtrlRead($FaxPhone1)
$RWID = GUICtrlRead($WID)
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
If StringIsDigit($RWID) = 1 Then;;$WID= 指定写入ID,=1 >>> 有数字 非空白
$addfld.execute("update " & $DBEnterpriseTable & " set whos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $RWID)
ElseIf $EID <> Null Then
$addfld.execute("update " & $DBEnterpriseTable & " set whos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $EID)
ElseIf $EID = Null Then
$addfld.execute("update " & $DBEnterpriseTable & " set whos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $Strnspin[1])
Else
$addfld.execute("update " & $DBEnterpriseTable & " set whos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $Strnspin[1])
EndIf
$addfld.close
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
GUICtrlSetData($WID,'')
_Range()
EndFunc
Func Serch();;搜索(支援模煳搜索)
$ReadFaxPhone1 = GUICtrlRead($FaxPhone1);;备注
$ReadEnterprise = GUICtrlRead($Enterprise);;主人
$ReadPrincipal = GUICtrlRead($Principal);;帐号
;;SQL万用字元查询,将单独的特殊字元[]起来,才能不出错,新增*查询。用法:** %% __
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '[' Then $ReadEnterprise = '[[]'
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '_' Then $ReadEnterprise = '[_]'
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '%' Then $ReadEnterprise = '[%]'
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '*' Then $ReadEnterprise = '[%]'
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '[' Then $ReadPrincipal = '[[]'
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '_' Then $ReadPrincipal = '[_]'
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '%' Then $ReadPrincipal = '[%]'
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '*' Then $ReadPrincipal = '[%]'
;;文字内包含万用字元查询,字串裡含有万用字元,且长度不等于1,进行替换
If StringRegExp($ReadEnterprise,'[') = 0 And StringLen($ReadEnterprise) <> 1 Then $ReadEnterprise = StringReplace($ReadEnterprise,'[','[[]')
If StringRegExp($ReadEnterprise,'*') = 0 And StringLen($ReadEnterprise) <> 1 Then $ReadEnterprise = StringReplace($ReadEnterprise,'*','%')
If StringRegExp($ReadPrincipal,'[') = 0 And StringLen($ReadPrincipal) <> 1 Then $ReadPrincipal = StringReplace($ReadPrincipal,'[','[[]')
If StringRegExp($ReadPrincipal,'*') = 0 And StringLen($ReadPrincipal) <> 1 Then $ReadPrincipal = StringReplace($ReadPrincipal,'*','%')
If $ReadFaxPhone1 = "" And $ReadEnterprise = "" And $ReadPrincipal = "" Then
MsgBox( 48 , "错误" , "您无输入搜寻条件!" )
Return
ElseIf $ReadEnterprise = "" And $ReadPrincipal = "" Then
$SerchItem = "deputation"
$InputItem = $ReadFaxPhone1
ElseIf $ReadFaxPhone1 = "" And $ReadPrincipal = "" Then
$SerchItem = "whos"
$InputItem = $ReadEnterprise
ElseIf $ReadFaxPhone1 = "" And $ReadEnterprise = "" Then
$SerchItem = "userid"
$InputItem = $ReadPrincipal
Else
MsgBox( 48 , "错误" , "搜寻条件一次只能为一个!" )
Return
EndIf
GUICtrlSendMsg($ListView1,$LVM_DELETEALLITEMS,0,0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & $SerchItem & " like'%"&$InputItem&"%'") ;;模煳查询语法
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1)
$rs.movenext
WEnd
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
EndFunc
Func Clear();;清空列表
GUICtrlSendMsg($ListView1,$LVM_DeleteALLITEMS,0,0) ;;清空列表
EndFunc
Func DeleteWorkerTable();;删除并重建帐号资料表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.Execute("DROP TABLE " & $DBEnterpriseTable);;删除帐号记录的表
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
;;建立 "表"
$addTbl.Execute("CREATE TABLE " & $DBEnterpriseTable);;建立帐号记录的表
;;建立 "栏(位)名"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.Execute("ALTER TABLE " & $DBEnterpriseTable & " ADD id identity(1, 1) primary key,whos text(255) ,userid text(255) ,pass text(255) ,deputation text(255)" )
$addfld.Close
read()
MsgBox(64,"完成","已成功删除并重建帐号资料表!")
Return
EndFunc
Func Button2Click() ;;将资料写入(新增进)资料库
$ReadPrincipal = GUICtrlRead($Principal)
$ReadTelPhone1 = GUICtrlRead($TelPhone1)
GUICtrlSetState($Button2,$GUI_DISABLE)
;;读取输入的值
$ReadEnterprise = GUICtrlRead($Enterprise)
If $ReadEnterprise = '' Then $ReadEnterprise = 'N/A'
$ReadFaxPhone1 = GUICtrlRead($FaxPhone1)
$RWID = GUICtrlRead($WID)
$a=StringSplit($ReadTelPhone1,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$UserPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
;;输出资料至DB
If $ReadPrincipal <> '' Then ;;判断"范围"是否为空
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
If $RWID = '' Then $addfld.Execute("insert into "&$DBEnterpriseTable&" (whos,userid,pass,deputation) values('"&$ReadEnterprise&"','"&$ReadPrincipal&"','"&$UserPass&"','"&$ReadFaxPhone1&"')")
If $RWID <> '' Then
$MSGCheck = MsgBox(32+4,'警告','您确定要新增该笔资料至 索引号:' & $RWID & ' 吗?')
If $MSGCheck = 6 Then
$addfld.execute("update " & $DBEnterpriseTable & " set whos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $RWID)
Else
GUICtrlSetState($Button2,@SW_ENABLE)
Return
EndIf
EndIf
$addfld.close
_whos()
_Range()
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
GUICtrlSetState($Enterprise,$GUI_FOCUS) ;;预设光标所在位置
Else
MsgBox(48,'错误','范围为必填项目!')
GUICtrlSetState($Enterprise,$GUI_FOCUS)
EndIf
GUICtrlSetState($Button2,@SW_ENABLE)
EndFunc
;登录选项窗体(by Flyself)
Func _login()
Local $errorNumber = 0, $dbuserName, $dbuserPass
Global $NONEAACTIVECOLOR = 0x9898f8
Global $MARK_1 = 0
;登录窗体
Local $Form_login = GUICreate("登入介面", 300, 195,-1,-1,$WS_CAPTION + $WS_POPUP + $WS_SYSMENU)
GUICtrlCreateLabel('欢迎使用 '&$Title, 0, 15, 300, 25, $SS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);;控件透明
GUICtrlSetFont(-1,$fontsize+1,$font_xing,$font_var,$font_name)
GUICtrlSetColor(-1,0x1260FF)
Local $login_Label1 = GUICtrlCreateLabel("帐号", 20, 55, 55, 20, $SS_RIGHT)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_Input1 = GUICtrlCreateInput("admin", 85, 50, 115, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_Label2 = GUICtrlCreateLabel("密码", 20, 100, 55, 20, $SS_RIGHT)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_Input2 = GUICtrlCreateInput("", 85, 95, 115, 24, $ES_PASSWORD)
GUICtrlSetState(-1,$GUI_FOCUS) ;;预设光标所在位置
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_ok = GUICtrlCreateButton("登入", 50, 145, 75, 25, $BS_DEFPUSHBUTTON)
Local $login_cancel = GUICtrlCreateButton("取消", 175, 145, 75, 25)
GUICtrlCreateLabel("预设:admin", 210, 55, 120, 17)
GUICtrlSetColor(-1, 0x3399FF)
GUICtrlCreateLabel("预设:空", 210, 100, 120, 17)
GUICtrlSetColor(-1, 0x3399FF)
GUISetState(@SW_SHOW, $Form_login)
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $login_cancel
Exit
Case $login_ok ;登录用户进入主窗体
$puser = GUICtrlRead($login_Input1)
$ppassword = GUICtrlRead($login_Input2)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBData )
$a=StringSplit($ppassword,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$ENCPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
$dbuserName = $RS.Fields(1).value
$dbuserPass = $RS.Fields(2).value
$rs.close
$addfld.Close
If $puser = '' Then
$dbuserName = Null
$dbuserPass = Null
MsgBox(48,'错误','请输入帐号!',$MB_OK)
GUICtrlSetData($login_Input2, "")
ElseIf $puser <> $dbuserName And $ENCPass <> $dbuserPass Then
$dbuserName = Null
$dbuserPass = Null
$errorNumber += 1
GUICtrlSetData($login_Input2, "")
If $errorNumber = 3 Then
MsgBox(16,'错误','输入的帐号或密码错误次数过多,将关闭本软体!',$MB_OK)
Exit
Else
MsgBox(48,'错误','输入的帐号或密码错误!请重新再试一次。',$MB_OK)
EndIf
ElseIf $puser = $dbuserName And $ENCPass = $dbuserPass Then
$dbuserName = Null
$dbuserPass = Null
GUISetState(@SW_HIDE, $Form_login)
Return 1
Else
$dbuserName = Null
$dbuserPass = Null
$errorNumber += 1
GUICtrlSetData($login_Input2, "")
If $errorNumber = 3 Then
MsgBox(16,'错误','输入的帐号或密码错误次数过多,将关闭本软体!',$MB_OK)
Exit
Else
MsgBox(48,'错误','输入的帐号或密码错误!请重新再试一次。',$MB_OK)
EndIf
EndIf
EndSwitch
WEnd
EndFunc ;==>_login
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam);<<<<<<<<<+++LISTVIEW
;;右键菜单
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView1,$hWndListView2, $SelectedID, $hWndTab
$hWndListView1 = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView1 = GUICtrlGetHandle($ListView1)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
;;双击判断,感谢 "漠北雪~狼"
Case $NM_CLICK ; 左击
;;
Case $NM_DBLCLK ; 双击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
;;MsgBox(0, "", "未选定")
Return
EndIf
_runL2()
Case $NM_RCLICK ; 右击
If _GUICtrlListView_GetSelectedIndices($hWndListView1) = "" Then
_GUICtrlMenu_SetItemDisabled($Menu1, 1)
_GUICtrlMenu_SetItemDisabled($Menu1, 2)
Else
_GUICtrlMenu_SetItemEnabled($Menu1, 1)
_GUICtrlMenu_SetItemEnabled($Menu1, 2)
EndIf
$SelectedID = _GUICtrlMenu_TrackPopupMenu($Menu1, $hWndListView1, -1, -1, 1, 1, 2)
If $SelectedID = $MenuAdd Then;;新增
If GUICtrlRead($Button9) = '开启编辑窗>' Then
sAdditem()
If GUICtrlRead($Principal) = '' Then Return
EndIf
Button2Click()
EndIf
If $SelectedID = $MenuEdit Then;;编辑
If GUICtrlRead($Button9) = '开启编辑窗>' Then
sAdditem()
EndIf
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$EID = $Strnspin[1]
dataup();;复製资料到编辑框
EndIf
If $SelectedID = $MenuDel Then;;删除
Button11Click()
EndIf
Case $LVN_HOTTRACK ;;滑鼠经过事件
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $HotItem = _GUICtrlListView_GetHotItem($ListView1) ;;列
If $HotItem <>-1 Then
$SubItem=DllStructGetData($tInfo, "SubItem")
If $SubItem = 3 Then
ToolTip(_GUICtrlListView_GetItemText ($ListView1,$HotItem,$SubItem))
$MouseNotInListView = 0
Else
If $MouseNotInListView = 0 Then ToolTip("")
$MouseNotInListView = 1
EndIf
Else
If $MouseNotInListView = 0 Then ToolTip("")
$MouseNotInListView = 1
EndIf
Case $NM_DBLCLK
If _GUICtrlListView_GetSelectedIndices($hWndListView1) <> "" Then MsgBox(0,"","您点击了编辑")
Case $LVN_COLUMNCLICK ; A column was clicked
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
_DebugPrint("$LVN_COLUMNCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
_GUICtrlListView_SimpleSort($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
; No return value
Case $LVN_KEYDOWN ; A key has been pressed
$tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
_DebugPrint("$LVN_KEYDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @LF & _
"-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
; No return value
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_KILLFOCUS ; The control has lost the input focus
_DebugPrint("$NM_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
;Return 1 ; not to allow the default processing
Return 0 ; allow the default processing
Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
_DebugPrint("$NM_RETURN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
Case $NM_SETFOCUS ; The control has received the input focus
_DebugPrint("$NM_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint
;;----------Start 程式下方的资讯列所用涵式,出自作者:钟隐(mysql查询) ----------
Func CreateSystemMenuItem($hWin, $sText, $hMenu = -1, $bIsPopup = False, $nPos = 0xFFFFFFFF); 0xFFFFFFFF means "insert at the end"
If $hMenu = -1 Then $hMenu = GetSystemMenu($hWin, 0)
Local $nID = GUICtrlCreateDummy()
Local $nFlags = 0
If $sText = "" Then
$nFlags = $MF_SEPARATOR
ElseIf $bIsPopup Then
$nID = CreatePopupMenu()
$nFlags = $MF_POPUP
EndIf
$nFlags = BitOR($MF_BYPOSITION, $nFlags)
$nResult = InsertMenu($hMenu, $nPos, $nFlags, $nID, $sText)
Return $nID
EndFunc ;==>CreateSystemMenuItem
Func RemoveMenu($hWin, $SYSCOMMAND)
$dSysMenu = DllCall("User32.dll", "hwnd", "GetSystemMenu", "hwnd", $hWin, "int", 0)
$hSysMenu = $dSysMenu[0]
DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", $SYSCOMMAND, "int", 0)
DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $hWin)
EndFunc
Func CreatePopupMenu()
Local $hMenu = DllCall("user32.dll", "hwnd", "CreatePopupMenu")
Return $hMenu[0]
EndFunc ;==>CreatePopupMenu
Func CheckMenuItem($hMenu, $nID, $nFlags)
DllCall("user32.dll", "int", "CheckMenuItem", _
"hwnd", $hMenu, _
"int", $nID, _
"int", $nFlags)
EndFunc ;==>CheckMenuItem
Func GetSystemMenu($hWnd, $bRevert)
Local $hMenu = DllCall("user32.dll", "hwnd", "GetSystemMenu", _
"hwnd", $hWnd, _
"int", $bRevert)
Return $hMenu[0]
EndFunc ;==>GetSystemMenu
Func InsertMenu($hMenu, $nPosition, $nFlags, $nIDNewItem, $lpNewItem)
Local $nResult = DllCall("user32.dll", "int", "InsertMenu", _
"hwnd", $hMenu, _
"int", $nPosition, _
"int", $nFlags, _
"int", $nIDNewItem, _
"str", $lpNewItem)
Return $nResult[0]
EndFunc ;==>InsertMenu
Func _newuseLogin()
;登录窗体
Local $Form_newuseLogin = GUICreate("密码设定", 470, 260,-1, -1)
GUISetBkColor(0xFFF0F5)
GUICtrlCreateLabel('密码预设为空,建议设定密码,以保护资料安全', 20, 35, 430, 25, $SS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);;控件透明
GUICtrlSetFont(-1,$fontsize+1,$font_xing,$font_var,$font_name)
GUICtrlSetColor(-1,0x1260FF)
GUICtrlCreateLabel('新用户密码:',40,95,115,25)
$NewPassword = GUICtrlCreateInput('',155,88,250,25,$ES_PASSWORD)
If $FirstUse = 1 Then GUICtrlSetState($NewPassword,$GUI_FOCUS) ;;预设光标所在位置
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
GUICtrlCreateLabel('确认用户密码:',40,140,115,25)
$ConfirmPasswordAgain = GUICtrlCreateInput('',155,133,250,25,$ES_PASSWORD)
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
$login_ok = GUICtrlCreateButton('设定新密码',185,190,100,30,$BS_DEFPUSHBUTTON)
GUICtrlCreateGroup('',-99,-99,1,1)
GUICtrlCreateLabel("", 0, 0, 470, 280, 0x04000000, 0x00100000)
GUISetState(@SW_SHOW, $Form_newuseLogin)
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete($Form_newuseLogin)
Return 1
Case $login_ok
_Password()
GUIDelete($Form_newuseLogin)
Return 1
EndSwitch
WEnd
EndFunc
Func _cPass()
If BitAND(WinGetState($cPass_gui, ""), 2) And IsHWnd($cPass_gui) Then
GUIDelete($cPass_gui)
Return 0
EndIf
$XY=WinGetPos($Form1) ;;取得Form1大小
If BitAND(WinGetState($Form1), 2) Then
$size = WinGetPos($Form1)
$cPass_gui = GUICreate("密码设定", 470, 260, ($XY[2]-470)/2, ($XY[3]-260)/5, -1, 0x00000040 + 0x00000010 + 0x00000080, $Form1)
GUISetBkColor(0xFFF0F5)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
Else
$cPass_gui = GUICreate("密码设定", 470, 260, ($XY[2]-470)/2, ($XY[3]-260)/5, -1, 0x00000040 + 0x00000010 + 0x00000080)
GUISetBkColor(0xFFF0F5)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
EndIf
GUISetOnEvent(-3, "main")
GUICtrlCreateGroup('密码设定',20,20,430,200)
GUICtrlCreateLabel('旧用户密码:',40,50,125,25)
$OldPassword = GUICtrlCreateInput('',180,48,250,25,$ES_PASSWORD)
GUICtrlSetState(-1,$GUI_FOCUS) ;;预设光标所在位置
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
If $FirstUse = 1 Then GUICtrlSetState($OldPassword,@SW_DISABLE)
GUICtrlCreateLabel('新用户密码:',40,90,125,25)
$NewPassword = GUICtrlCreateInput('',180,88,250,25,$ES_PASSWORD)
If $FirstUse = 1 Then GUICtrlSetState($NewPassword,$GUI_FOCUS) ;;预设光标所在位置
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
GUICtrlCreateLabel('确认用户密码:',40,130,125,25)
$ConfirmPasswordAgain = GUICtrlCreateInput('',180,128,250,25,$ES_PASSWORD)
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
GUICtrlCreateButton('变更密码',40,170,100,30,$BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1,'_Password')
GUICtrlCreateGroup('',-99,-99,1,1)
GUICtrlCreateLabel("", 0, 0, 470, 280, 0x04000000, 0x00100000)
GUISetState(@SW_SHOWNOACTIVATE, $cPass_gui)
EndFunc
Func about();关于窗口
If BitAND(WinGetState($About_gui, ""), 2) And IsHWnd($About_gui) Then
GUIDelete($About_gui)
Return 0
EndIf
$XY=WinGetPos($Form1) ;;取得Form1大小
If BitAND(WinGetState($Form1), 2) Then
$size = WinGetPos($Form1)
$About_gui = GUICreate("关于 "&$Title & ' v' & $ver, 670, 220, ($XY[2]-670)/2, ($XY[3]-220)/5, -1, 0x00000040 + 0x00000010 + 0x00000080, $Form1)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
GUISetBkColor(0xFFF0F5)
Else
$About_gui = GUICreate("关于 "&$Title & ' v' & $ver, 670, 220, ($XY[2]-670)/2, ($XY[3]-220)/5, -1, 0x00000040 + 0x00000010 + 0x00000080)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
GUISetBkColor(0xFFF0F5)
EndIf
GUISetOnEvent(-3, "main")
Global $guitext6 = GUICtrlCreateLabel("软体名称:"&$Title, 160, 50, 390, 30)
GUICtrlSetFont(-1, 16, 600)
GUICtrlSetColor(-1, 0x800080)
Global $guitext7 = GUICtrlCreateLabel("作者:"&$Author, 160, 90, 390, 20)
GUICtrlSetFont(-1, 10, 300)
GUICtrlSetColor(-1, 0xFF00FF)
Global $guitext8 = GUICtrlCreateLabel("版本:" & $ver, 160, 110, 390, 20)
GUICtrlSetFont(-1, 10, 300)
GUICtrlSetColor(-1, 0x808080)
GUICtrlCreateLabel($Copyright, 160, 130, 505, 20)
GUICtrlSetFont(-1, 10, 300)
GUICtrlSetColor(-1, 0x808080)
GUISetState(@SW_SHOWNOACTIVATE, $About_gui)
EndFunc ;==>about
Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
$nID = BitAND($wParam, 0x0000FFFF)
Switch $nID
Case $nItem1
about()
EndSwitch
EndFunc ;==>WM_SYSCOMMAND
Func main()
Switch @GUI_CtrlId
Case -3
Switch @GUI_WinHandle
Case $about_gui
GUIDelete($about_gui)
Case $cPass_gui
GUIDelete($cPass_gui)
EndSwitch
EndSwitch
EndFunc
;;----------End 程式下方的资讯列所用涵式,出自作者:钟隐(mysql查询) ----------
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| Input浮水说明文字 |
;;| 作者:钟隐(mysql查询) |
;;| 网址: |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Func _CheckInput($hWnd, $ID, $InputDefText, ByRef $DefaultInputData, ByRef $Mark)
If $Mark = 0 And _IsFocused($hWnd, $ID) And $DefaultInputData = $InputDefText Then
$Mark = 1
GUICtrlSetData($ID, "")
GUICtrlSetColor($ID, 0x000000)
$DefaultInputData = ""
ElseIf $Mark = 1 And Not _IsFocused($hWnd, $ID) And $DefaultInputData = "" And GUICtrlRead($ID) = "" Then
$Mark = 0
$DefaultInputData = $InputDefText
GUICtrlSetData($ID, $DefaultInputData)
GUICtrlSetColor($ID, $NONEAACTIVECOLOR)
EndIf
EndFunc ;==>_CheckInput
Func _IsFocused($hWnd, $nCID)
Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
EndFunc ;==>_IsFocused
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 使用API将窗体保持最前 |
;;| 作者:健啖客WTohrV |
;;| 网址:http://www.manew.com/blog-166183-23254.html |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Func _SetWindowPos($hWnd,$x,$y,$cX,$cY,$hWndInsertAfter = -1,$wFlags = 1)
;使用API将窗体保持最前 x,y -->>座标 $hWndInsertAfter >> Z位置、深度(3D)
DllCall("user32.dll","long","SetWindowPos","long",$hWnd,"long",$hWndInsertAfter,"long",$x,"long",$y,"long",$cX,"long",$cY,"long",$wFlags)
EndFunc;==>_SetWindowPos
;;Yashied
;;https://www.autoitscript.com/forum/topic/97365-how-to-convert-a-hicon-to-a-32-bit-hbitmap/?do=findComment&comment=700670
Func _CreateBitmapFromIcon($iBackground, $sIcon, $iIndex, $iWidth, $iHeight)
Local $hDC, $hBackDC, $hBackSv, $hIcon, $hBitmap
$hDC = _WinAPI_GetDC(0)
$hBackDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight)
$hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap)
$hIcon = _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight)
If Not @error Then
_WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL)
_WinAPI_DestroyIcon($hIcon)
EndIf
_WinAPI_SelectObject($hBackDC, $hBackSv)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_DeleteDC($hBackDC)
Return $hBitmap
EndFunc ;==>_CreateBitmapFromIcon
Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight)
Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd')
Local $Ret = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0)
If (@error) Or ($Ret[0] = 0) Then
Return SetError(1, 0, 0)
EndIf
$hIcon = DllStructGetData($tIcon, 1)
If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then
Return SetError(1, 0, 0)
EndIf
Return $hIcon
EndFunc ;==>_WinAPI_PrivateExtractIcon
Func SaveCurrentWorkerTable();;汇出当前资料(感谢autoit3.cn上的chzj589大大)
MsgBox(0,0,'汇出')
EndFunc
Func ImportWorkerTable();;汇入资料
MsgBox(0,0,'汇入')
EndFunc
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| API视窗置顶 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Func _Topping()
If GUICtrlRead($menu2item1) = 65 Then ;;65 = 选中置顶,ini裡的1 = 启用置顶,0则否
_SetWindowPos($Form1,-1,-1,-1,-1,$HWND_TOPMOST,$SWP_NOMOVE+$SWP_NOSIZE);;置顶
EndIf
If GUICtrlRead($menu2item1) = 68 Then ;;68 = 未选中
_SetWindowPos($Form1,-1,-1,-1,-1,$HWND_NOTOPMOST,$SWP_NOMOVE+$SWP_NOSIZE);;取消置顶
EndIf
EndFunc