回车键设置问题???
#include <ButtonConstants.au3>#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 453, 190, 120)
$ListView1 = GUICtrlCreateListView("|||||||||||||||", 8, 200, 618, 246)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$Input1 = GUICtrlCreateInput("", 100, 16, 121, 21)
$Input2 = GUICtrlCreateInput("", 100, 56, 121, 21)
$Input3 = GUICtrlCreateInput("", 100, 96, 121, 21)
$Input4 = GUICtrlCreateInput("", 100, 136, 121, 21)
$Label1 = GUICtrlCreateLabel("id_usernum", 16, 16, 80, 17)
$Label2 = GUICtrlCreateLabel("id_key", 16, 56, 80, 17)
$Label3 = GUICtrlCreateLabel("id_name", 16, 96, 80, 17)
$Label4 = GUICtrlCreateLabel("id_idcard", 16, 136, 80, 17)
$Button1 = GUICtrlCreateButton("read", 400, 80, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
list()
EndSwitch
WEnd
Func list()
Local $listvalue, $id_usernum
$id_usernum = GUICtrlRead($Input1)
$Conn = ObjCreate("ADODB.Connection")
$Conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=RZXCard.mdb;Jet OLEDB:Database Password='rzx1218'")
$RS = ObjCreate("ADODB.Recordset")
$sentence = "select * from registerhistory where id_usernum='" & $id_usernum & "'"
$RS.ActiveConnection = $Conn
$RS.Open($sentence)
If $RS.eof Then
MsgBox(0, 0, "没有找到记录")
Else
GUICtrlSetData($Input2, $RS.Fields(3).value)
GUICtrlSetData($Input3, $RS.Fields(2).value)
GUICtrlSetData($Input4, $RS.Fields(6).value)
_GUICtrlListView_DeleteAllItems($ListView1)
For $i = 0 To ($RS.Fields.Count - 1)
_GUICtrlListView_SetColumn($ListView1, $i, $RS.Fields($i).Name)
Next
While (Not $RS.eof And Not $RS.bof)
For $i = 0 To ($RS.Fields.Count - 1)
$listvalue = $listvalue & $RS.Fields($i).value & "|" ;取得一行记录
Next
GUICtrlCreateListViewItem($listvalue, $ListView1);显示$listvalue
$RS.movenext ;移到下一条记录
$listvalue = "" ;清空
WEnd
$RS.close
$Conn.Close
EndIf
EndFunc ;==>list
这个代码中我想把$Button1设成可以按回车键来确定的要怎么设啊??
有人可以帮忙解决一下吗?
[ 本帖最后由 s77m72 于 2008-10-28 15:53 编辑 ] GUICtrlSetState ( 控件ID, 状态 )
$GUI_DEFBUTTON 这个方法我试了一下,第一次的时候按回车可以,但是再次输入数据后按回车就不行了,可不可以把它定义成回车键啊? 给个例子
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 380, 139, 192, 124)
$Button1 = GUICtrlCreateButton("Button1", 64, 16, 105, 33, 0)
GUISetState(@SW_SHOW)
Dim $Form1_AccelTable = [["{{enter}", $Button1]]
GUISetAccelerators($Form1_AccelTable)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
$Button1 = GUICtrlCreateButton("read", 400, 80, 75, 25, 0)
Dim $Form1_AccelTable = [["{ENTER}", $Button1]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
[ 本帖最后由 liongodmien 于 2008-10-26 21:47 编辑 ] 运行后提示
.au3(46,37) : ERROR: GUISetAccelerators(): undefined function.
GUISetAccelerators($Form1_AccelTable)
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 453, 190, 120)
$ListView1 = GUICtrlCreateListView("|||||||||||||||", 8, 200, 618, 246)
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
$Input1 = GUICtrlCreateInput("", 100, 16, 121, 21)
$Input2 = GUICtrlCreateInput("", 100, 56, 121, 21)
$Input3 = GUICtrlCreateInput("", 100, 96, 121, 21)
$Input4 = GUICtrlCreateInput("", 100, 136, 121, 21)
$Label1 = GUICtrlCreateLabel("id_usernum", 16, 16, 80, 17)
$Label2 = GUICtrlCreateLabel("id_key", 16, 56, 80, 17)
$Label3 = GUICtrlCreateLabel("id_name", 16, 96, 80, 17)
$Label4 = GUICtrlCreateLabel("id_idcard", 16, 136, 80, 17)
$Button1 = GUICtrlCreateButton("read", 400, 80, 75, 25, 0)
Dim $Form1_AccelTable = [["{ENTER}", $Button1]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
list()
EndSwitch
WEnd
Func list()
Local $listvalue, $id_usernum
$id_usernum = GUICtrlRead($Input1)
$Conn = ObjCreate("ADODB.Connection")
$Conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=RZXCard.mdb;Jet OLEDB:Database Password='rzx1218'")
$RS = ObjCreate("ADODB.Recordset")
$sentence = "select * from registerhistory where id_usernum='" & $id_usernum & "'"
$RS.ActiveConnection = $Conn
$RS.Open($sentence)
If $RS.eof Then
MsgBox(0, 0, "没有找到记录")
Else
GUICtrlSetData($Input2, $RS.Fields(3).value)
GUICtrlSetData($Input3, $RS.Fields(2).value)
GUICtrlSetData($Input4, $RS.Fields(6).value)
_GUICtrlListView_DeleteAllItems($ListView1)
For $i = 0 To ($RS.Fields.Count - 1)
_GUICtrlListView_SetColumn($ListView1, $i, $RS.Fields($i).Name)
Next
While (Not $RS.eof And Not $RS.bof)
For $i = 0 To ($RS.Fields.Count - 1)
$listvalue = $listvalue & $RS.Fields($i).value & "|" ;取得一行记录
Next
GUICtrlCreateListViewItem($listvalue, $ListView1);显示$listvalue
$RS.movenext ;移到下一条记录
$listvalue = "" ;清空
WEnd
$RS.close
$Conn.Close
EndIf
EndFunc ;==>list
你的是什么版本的啊,我这AU3无这个GUISetAccelerators函数啊 我的3.2.13.7版已有此函数。 还提示这个错误,是什么意思啊?
WARNING: #comments-end has no matching #comments-start.
ERROR: undefined macro. 有要在吗? 有人在吗? 原帖由 s77m72 于 2008-10-26 23:30 发表 http://www.autoitx.com/images/common/back.gif
还提示这个错误,是什么意思啊?
WARNING: #comments-end has no matching #comments-start.
ERROR: undefined macro.
只定义了注释开始而没有定义注释结束! 在按钮上使用$BS_DEFPUSHBUTTON样式就可以了 学习学习!
页:
[1]