找回密码
 加入
搜索
查看: 3374|回复: 14

回车键设置问题???

[复制链接]
发表于 2008-10-26 21:16:30 | 显示全部楼层 |阅读模式
#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 编辑 ]
发表于 2008-10-26 21:22:10 | 显示全部楼层
GUICtrlSetState ( 控件ID, 状态 )

$GUI_DEFBUTTON
 楼主| 发表于 2008-10-26 21:33:37 | 显示全部楼层
这个方法我试了一下,第一次的时候按回车可以,但是再次输入数据后按回车就不行了,可不可以把它定义成回车键啊?
发表于 2008-10-26 21:39:46 | 显示全部楼层
给个例子
#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[1][2] = [["{{enter}", $Button1]]
GUISetAccelerators($Form1_AccelTable)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
发表于 2008-10-26 21:46:01 | 显示全部楼层


$Button1 = GUICtrlCreateButton("read", 400, 80, 75, 25, 0)
Dim $Form1_AccelTable[1][2] = [["{ENTER}", $Button1]]
GUISetAccelerators($Form1_AccelTable)
GUISetState(@SW_SHOW)


[ 本帖最后由 liongodmien 于 2008-10-26 21:47 编辑 ]
 楼主| 发表于 2008-10-26 22:01:38 | 显示全部楼层
运行后提示
.au3(46,37) : ERROR: GUISetAccelerators(): undefined function.
GUISetAccelerators($Form1_AccelTable)
发表于 2008-10-26 22:10:27 | 显示全部楼层

#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[1][2] = [["{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
 楼主| 发表于 2008-10-26 22:33:34 | 显示全部楼层
你的是什么版本的啊,我这AU3无这个GUISetAccelerators函数啊
发表于 2008-10-26 22:43:33 | 显示全部楼层
我的3.2.13.7版已有此函数。
 楼主| 发表于 2008-10-26 23:30:51 | 显示全部楼层
还提示这个错误,是什么意思啊?
WARNING: #comments-end has no matching #comments-start.
ERROR: undefined macro.
 楼主| 发表于 2008-10-27 08:36:59 | 显示全部楼层
有要在吗?
 楼主| 发表于 2008-10-27 09:27:20 | 显示全部楼层
有人在吗?
发表于 2008-10-27 11:14:11 | 显示全部楼层
原帖由 s77m72 于 2008-10-26 23:30 发表
还提示这个错误,是什么意思啊?
WARNING: #comments-end has no matching #comments-start.
ERROR: undefined macro.

只定义了注释开始而没有定义注释结束!
发表于 2008-10-28 15:48:10 | 显示全部楼层
在按钮上使用$BS_DEFPUSHBUTTON样式就可以了
发表于 2016-12-31 10:57:25 | 显示全部楼层
学习学习!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-17 04:58 , Processed in 0.177936 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表