[已解决]子窗口中按Tab键无效?
本帖最后由 nnlenx 于 2011-5-23 13:28 编辑如下代码,Form1窗口如果不设为父窗口Form0的子窗口时,按Tab键是能正常在各输入框中切换的
一但设为子窗口时,就不行了。请各位前辈们指导一下,我哪个地方没弄对。。。
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
;Global $Form0
$Form0 = GUICreate("主窗口", 347, 258, 286, 288)
GUISetState(@SW_SHOW)
$Form1 = GUICreate("子窗口", 400, 400, 10, 10,$WS_CHILD,0,$Form0)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 16, 43, 17)
$User = GUICtrlCreateInput("", 72, 16, 169, 21)
GUICtrlSetState(-1,$GUI_FOCUS)
$Label2 = GUICtrlCreateLabel("密码:", 24, 56, 31, 17)
$Password = GUICtrlCreateInput("", 72, 54, 169, 21)
$Button1 = GUICtrlCreateButton("确定", 80, 112, 89, 33)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $User
If _IsPressed("0D") Then
MsgBox(0,0,"按下回车键")
EndIf
GUICtrlSetState($Password,$GUI_FOCUS)
Case $Password
GUICtrlSetState($Button1,$GUI_FOCUS)
EndSwitch
WEnd
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
;Global $Form0
$Form0 = GUICreate("主窗口", 402, 402, 286, 288)
GUISetState(@SW_SHOW)
$Form1 = GUICreate("子窗口", 400, 400, 0, 0,0x80880000+0x00010000,0x00000040,$Form0)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 16, 43, 17)
$User = GUICtrlCreateInput("", 72, 16, 169, 21)
GUICtrlSetState(-1,$GUI_FOCUS)
$Label2 = GUICtrlCreateLabel("密码:", 24, 56, 31, 17)
$Password = GUICtrlCreateInput("", 72, 54, 169, 21)
$Button1 = GUICtrlCreateButton("确定", 80, 112, 89, 33)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $User
If _IsPressed("0D") Then
MsgBox(0,0,"按下回车键")
EndIf
GUICtrlSetState($Password,$GUI_FOCUS)
Case $Password
GUICtrlSetState($Button1,$GUI_FOCUS)
EndSwitch
WEnd 回复 2# 3mile
非常感谢,基本能达到要求,但不是很理想,因为当光标在子窗口里时,主窗口就变成不是当前窗口了(主窗口标题变灰色)。
不知其他前辈是否有更好的方法? 回复3mile
非常感谢,基本能达到要求,但不是很理想,因为当光标在子窗口里时,主窗口就变成 ...
nnlenx 发表于 2011-5-23 10:55 http://www.autoitx.com/images/common/back.gif
你说什么?完全不理解啊 回复 3# nnlenx
"当前窗口",只有一个的吧?可以同时激活几个窗口??{:face (52):} 本帖最后由 nnlenx 于 2011-5-23 12:42 编辑
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
;Global $Form0
$Form0 = GUICreate("主窗口", 347, 258, 286, 288)
GUISetState(@SW_SHOW)
$Form1 = GUICreate("子窗口", 400, 400, 10, 10,$WS_CHILD,0)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 16, 43, 17)
$User = GUICtrlCreateInput("", 72, 16, 169, 21)
GUICtrlSetState(-1,$GUI_FOCUS)
$Label2 = GUICtrlCreateLabel("密码:", 24, 56, 31, 17)
$Password = GUICtrlCreateInput("", 72, 54, 169, 21)
$Button1 = GUICtrlCreateButton("确定", 80, 112, 89, 33)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $User
If _IsPressed("0D") Then
MsgBox(0,0,"按下回车键")
EndIf
GUICtrlSetState($Password,$GUI_FOCUS)
Case $Password
GUICtrlSetState($Button1,$GUI_FOCUS)
EndSwitch
WEnd意思是,要达到这种效果(我在这里是没有指定父窗口:$Form1 = GUICreate("子窗口", 400, 400, 10, 10,$WS_CHILD,0)
),但我想要在指定父窗口的情况下,也达到一样的效果,不知我说得明白了没有。。。
这个是我想要的图:(主窗口这几个字不是灰色的)
这个是2#楼的代码运行后的图:(主窗口这几个字是灰色的)
用的是WIN7,看不出什么不同.
不过,再试下这个是否有效?
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
;Global $Form0
$Form0 = GUICreate("主窗口", 402, 402, -1, -1)
$Form1 = GUICreate("子窗口", 400, 400, 0, 0, $WS_CHILD);,0x00000040,$Form0)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 16, 43, 17)
$User = GUICtrlCreateInput("", 72, 16, 169, 21)
GUICtrlSetState(-1, $GUI_FOCUS)
$Label2 = GUICtrlCreateLabel("密码:", 24, 56, 31, 17)
$Password = GUICtrlCreateInput("", 72, 54, 169, 21)
$Button1 = GUICtrlCreateButton("确定", 80, 112, 89, 33)
GUISetState(@SW_SHOW,$Form0)
GUISetState(@SW_SHOW,$Form1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $User
If _IsPressed("0D") Then
MsgBox(0, 0, "按下回车键")
EndIf
GUICtrlSetState($Password, $GUI_FOCUS)
Case $Password
GUICtrlSetState($Button1, $GUI_FOCUS)
Case $Button1
msgbox(0,0,guictrlread($User)&@crlf&guictrlread($Password))
EndSwitch
WEnd
回复 2# 3mile
这几天一直为子窗的切换头疼,你的 [软件自动安装器](ico 或 png )切换子窗时,
在 XP 内表现为主窗边框轻微闪动,在 WIN7内,这个闪动成为跳动了,视觉上很别扭,
更换子窗样式和扩展样式,可以不跳了,但子窗不能切换了。。。不知你有否发现这个。。。 本帖最后由 3mile 于 2011-5-23 13:03 编辑
回复 8# 131738
借用楼主的问题,请前辈看下这段代码,不知道可不可以解决子窗体闪烁的情况.
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <winapi.au3>
;Global $Form0
$Form0 = GUICreate("主窗口", 402, 402, -1, -1)
$Form1 = GUICreate("子窗口", 400, 400, 0, 0, $WS_CHILD);,0x00000040,$Form0)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 16, 43, 17)
$User = GUICtrlCreateInput("", 72, 16, 169, 21)
GUICtrlSetState(-1, $GUI_FOCUS)
$Label2 = GUICtrlCreateLabel("密码:", 24, 56, 31, 17)
$Password = GUICtrlCreateInput("", 72, 54, 169, 21)
$Button1 = GUICtrlCreateButton("确定", 80, 112, 89, 33)
_WinAPI_SetParent($Form1, $Form0)
GUISetState(@SW_SHOW, $Form0)
GUISetState(@SW_SHOW, $Form1)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $User
If _IsPressed("0D") Then
MsgBox(0, 0, "按下回车键")
EndIf
GUICtrlSetState($Password, $GUI_FOCUS)
Case $Password
GUICtrlSetState($Button1, $GUI_FOCUS)
Case $Button1
MsgBox(0, 0, GUICtrlRead($User) & @CRLF & GUICtrlRead($Password))
EndSwitch
WEnd
LZ是不是想要这样的效果,看下:#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <Misc.au3>
;Global $Form0
$Form0 = GUICreate("主窗口", 347, 258, 286, 288)
GUISetState(@SW_SHOW)
$Form1 = GUICreate("子窗口", 400, 400, 10, 10,$WS_CHILD,0x00C00000,$Form0)
$Label1 = GUICtrlCreateLabel("用户名:", 16, 16, 43, 17)
$User = GUICtrlCreateInput("", 72, 16, 169, 21)
GUICtrlSetState(-1,$GUI_FOCUS)
$Label2 = GUICtrlCreateLabel("密码:", 24, 56, 31, 17)
$Password = GUICtrlCreateInput("", 72, 54, 169, 21)
$Button1 = GUICtrlCreateButton("确定", 80, 112, 89, 33)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $User
If _IsPressed("0D") Then
MsgBox(0,0,"按下回车键")
EndIf
GUICtrlSetState($Password,$GUI_FOCUS)
Case $Password
GUICtrlSetState($Button1,$GUI_FOCUS)
EndSwitch
WEnd
郊果和我6#楼的一样了,都是在创建子窗口时不,指定父窗口
我要的是要在指定父窗口的前提下,也要达到一样的效果 其实只要把
$Form1 = GUICreate("子窗口", 400, 400, 10, 10,$WS_CHILD,0,$Form0)
代码中的0改为0x00C00000就可以了啊 回复 9# 3mile
不行, 不指定父窗句柄, 子窗根本不显示 哦,不好意思,我再看下先 回复 12# m765555
正是如此,非常感谢!
同时也对给我回复的前辈们表示感谢!谢谢!
页:
[1]
2