找回密码
 加入
搜索
查看: 12616|回复: 28

[GUI管理] [已解决]子窗口中按Tab键无效?

 火.. [复制链接]
发表于 2011-5-23 08:18:04 | 显示全部楼层 |阅读模式
本帖最后由 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-5-23 09:34:23 | 显示全部楼层
#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
 楼主| 发表于 2011-5-23 10:55:20 | 显示全部楼层
回复 2# 3mile


      非常感谢,基本能达到要求,但不是很理想,因为当光标在子窗口里时,主窗口就变成不是当前窗口了(主窗口标题变灰色)。
    不知其他前辈是否有更好的方法?
发表于 2011-5-23 12:12:30 | 显示全部楼层
回复  3mile


      非常感谢,基本能达到要求,但不是很理想,因为当光标在子窗口里时,主窗口就变成 ...
nnlenx 发表于 2011-5-23 10:55

你说什么?完全不理解啊
发表于 2011-5-23 12:14:32 | 显示全部楼层
回复 3# nnlenx

"当前窗口",只有一个的吧?可以同时激活几个窗口??
 楼主| 发表于 2011-5-23 12:33:34 | 显示全部楼层
本帖最后由 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#楼的代码运行后的图:(主窗口这几个字是灰色的)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2011-5-23 12:55:06 | 显示全部楼层
用的是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
发表于 2011-5-23 12:56:51 | 显示全部楼层
回复 2# 3mile

这几天一直为子窗的切换头疼,你的 [软件自动安装器](ico 或 png )切换子窗时,

在 XP 内表现为主窗边框轻微闪动,在 WIN7内,这个闪动成为跳动了,视觉上很别扭,

更换子窗样式和扩展样式,可以不跳了,但子窗不能切换了。。。不知你有否发现这个。。。
发表于 2011-5-23 12:57:58 | 显示全部楼层
本帖最后由 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
发表于 2011-5-23 13:03:51 | 显示全部楼层
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
 楼主| 发表于 2011-5-23 13:05:29 | 显示全部楼层
郊果和我6#楼的一样了,都是在创建子窗口时不,指定父窗口

我要的是要在指定父窗口的前提下,也要达到一样的效果
发表于 2011-5-23 13:06:45 | 显示全部楼层
其实只要把
$Form1 = GUICreate("子窗口", 400, 400, 10, 10,$WS_CHILD,0,$Form0)
代码中的0改为0x00C00000就可以了啊
发表于 2011-5-23 13:13:08 | 显示全部楼层
回复 9# 3mile

不行, 不指定父窗句柄, 子窗根本不显示
发表于 2011-5-23 13:16:20 | 显示全部楼层
哦,不好意思,我再看下先
 楼主| 发表于 2011-5-23 13:27:36 | 显示全部楼层
回复 12# m765555


  正是如此,非常感谢!
同时也对给我回复的前辈们表示感谢!谢谢!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-16 11:58 , Processed in 0.087824 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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