找回密码
 加入
搜索
查看: 14605|回复: 52

[系统综合] 关于父子窗口不知道是不是BUG,求高手协助测试!!

 火.. [复制链接]
发表于 2015-3-19 23:24:34 | 显示全部楼层 |阅读模式
关于父子窗口不知道是不是BUG,可以帮忙测试看看 是不是有跟我一样的情况呢??
在设计父子窗口的时候,操作上经常会卡住,控件经常会失效,觉得怪怪的,经过反复
测试 终于发现了,如果子窗口 加上了 $WS_CHILD 这个样式,就不会卡住,但是后来
发现 加了$WS_CHILD 这个样式,会导致 无法在子窗口 使用INPUT 或者 EDIT 控件
因为会无法输入

但是拿掉了$WS_CHILD 这个,在操作上又会卡住,不知道大家的情况是否一样??
有人可以帮忙测试的吗??  问题怎么解决??

卡住的情况是这样的,程序开启后 把程序缩到最小,再还原,再缩小,再还原….
有时候一次就会卡住,卡住后似乎 窗口的焦点都被子窗占走了,父窗上面的按钮全部失效
包括了 放大.. 缩小 关闭等按钮….


程序语法如下:


#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>

Opt("GUIOnEventMode", 1)

$WinMain = GUICreate("Main", 1000, 750, -1, -1, $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX + $WS_SIZEBOX)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_COMMAND")
GUISetState(@SW_SHOW, $WinMain)

$WinMainSub = GUICreate("A視窗", 300, 300, 200, 200, -1, -1, $WinMain)
_WinAPI_SetParent($WinMainSub, $WinMain)
GUISetState(@SW_SHOW, $WinMainSub)

$WinMainSub2 = GUICreate("B視窗", 300, 300, 300, 300, -1, -1, $WinMain)
_WinAPI_SetParent($WinMainSub2, $WinMain)
GUISetState(@SW_SHOW, $WinMainSub2)

$WinMainSub3 = GUICreate("C視窗", 300, 300, 400, 400, -1, -1, $WinMain)
_WinAPI_SetParent($WinMainSub2, $WinMain)
GUISetState(@SW_SHOW, $WinMainSub3)

GUISetOnEvent($GUI_EVENT_CLOSE, "GUI_COMMAND")


While 1
        Sleep(20)
WEnd



Func GUI_COMMAND()
        Switch @GUI_CtrlId

                Case $GUI_EVENT_CLOSE
                        Switch @GUI_WinHandle
                                Case $WinMain
                                        Exit
                                Case Else
                                        GUIDelete(@GUI_WinHandle)
                        EndSwitch

        EndSwitch
EndFunc   ;==>GUI_COMMAND




本帖子中包含更多资源

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

×
 楼主| 发表于 2015-3-19 23:37:29 | 显示全部楼层
回复 1# kk_lee69

到官方網站 找到一段程式  這個程式運作很正常,但是 拿掉其中 無關緊要的一行 就會出問題......
原討論的網址為:
http://www.autoitscript.com/foru ... bug-with-setparent/

If you comment out the <<<<<<<<<<<<<<<< label you get the same effect.
So I agree that it is a bug.



#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>

Global $hMain, $ahChild[1][2] = [[0, 0]], $SC_MOVE = 0xF010
$hMain = GUICreate("Parent Window", 633, 447, 192, 200)
GUICtrlCreateLabel("", 0, 0, 0, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 拿掉這一行  程式就會卡住
$mMain = GUICtrlCreateMenu("New")
$mChild = GUICtrlCreateMenuItem("Child", $mMain)
GUISetState(@SW_SHOW)

; Prevent maximised children being moved
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

While 1
    ; Use advanced GUIGetMsg to distinguish between windows
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        ; It is the parent
        Case $hMain
            ; Now check the message
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $mChild
                    CreateChild()
            EndSwitch
        ; Must be a child
        Case Else
            ; But which one?
            For $i = 1 To $ahChild[0][0]
                If $aMsg[1] = $ahChild[$i][0] Then
                    ; Check the message
                    Switch $aMsg[0]
                        Case $GUI_EVENT_CLOSE
                            GUIDelete($ahChild[$i][0])
                        Case $GUI_EVENT_MAXIMIZE
                            ; Set the Maximised flag
                            $ahChild[$i][1] = True
                        Case $GUI_EVENT_MINIMIZE
                            ; Clear the Maximised flag
                            $ahChild[$i][1] = False
                        Case $GUI_EVENT_RESTORE
                            ; Clear the Maximised flag
                            $ahChild[$i][1] = False
                    EndSwitch
                EndIf
            Next
    EndSwitch
WEnd

Func CreateChild()
    $hNew_Child = GUICreate("Child " & $ahChild[0][0] + 1, 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI , $WS_MAXIMIZEBOX))
    _WinAPI_SetParent($hNew_Child, $hMain)
    Add($ahChild, $hNew_Child)
    GUISetState()
EndFunc   ;==>CreateChild

Func Add(ByRef $aArray, $hHandle)
    ; Increase the number of children
    $aArray[0][0] += 1
    ; Resize the array
    ReDim $aArray[$aArray[0][0] + 1][2]
    ; Add the child details
    $aArray[$aArray[0][0]][0] = $hHandle
    $aArray[$aArray[0][1]][1] = False
EndFunc   ;==>Add

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
        ConsoleWrite($hWnd&@TAB&$wParam&@CRLF)
    For $i = 1 To $ahChild[0][0]
        ; Does the message come from a child?
        If $hWnd = $ahChild[$i][0] Then
            ; Is the child maximised?
            If $ahChild[$i][1] Then
                ;Is it a MOVE mesage?
                If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False
                ExitLoop
            EndIf
        EndIf
    Next

    Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAND
发表于 2015-3-20 11:40:53 | 显示全部楼层
回复 2# kk_lee69
谢谢分享

本帖子中包含更多资源

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

×
 楼主| 发表于 2015-3-20 13:00:59 | 显示全部楼层
回复 3# chzj589

你會有主控件失效的情況嗎??
发表于 2015-3-20 13:09:36 | 显示全部楼层
回复 4# kk_lee69
不会啊,我是用2楼的代码
 楼主| 发表于 2015-3-20 13:11:10 | 显示全部楼层
回复 5# chzj589

那可以幫我測試一下 用二樓的代碼  註釋掉 <<<<<<<<<<<<<<<<  這一行的控件後測試一下嗎??
发表于 2015-3-20 13:14:36 | 显示全部楼层
回复 6# kk_lee69

注释掉主窗口失控,这一句有什么影响吗?
发表于 2015-3-20 13:23:00 | 显示全部楼层
回复 7# chzj589
刚又试了一下,可以注释掉,但要有其它控件就行。
GUICtrlCreateLabel("", 0, 0, 0, 0 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 拿掉這一行  程式就會卡住

上一行换下一行就行
$Input1 = GUICtrlCreateInput("", 10, 16, 200, 21
 楼主| 发表于 2015-3-20 13:24:59 | 显示全部楼层
回复 7# chzj589

多按幾次  最小化 與還原之後  就不能還原了  似乎 像  子窗口變成 焦點  而父窗口的功能就完全失效
发表于 2015-3-20 13:29:36 | 显示全部楼层
回复 9# kk_lee69
三个子窗口都按了20次以上,没出现问题。
 楼主| 发表于 2015-3-20 13:32:52 | 显示全部楼层
回复 10# chzj589
你的作業系統??
 楼主| 发表于 2015-3-20 13:34:59 | 显示全部楼层
回复 8# chzj589
不要加入任何˙控件  直接註解掉 第七行  然後 按 父窗口的放大縮小
发表于 2015-3-20 13:47:58 | 显示全部楼层
回复 12# kk_lee69

$hMain = GUICreate("Parent Window", 633, 447, 192, 200)

GUICtrlCreateLabel("", 0, 0, 0, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 拿掉這一行  程式就會卡住

$mMain = GUICtrlCreateMenu("New")

$mChild = GUICtrlCreateMenuItem("Child", $mMain)

GUISetState(@SW_SHOW)



; Prevent maximised children being moved

GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
注释掉-GUICtrlCreateLabel("", 0, 0, 0, 0)
主窗口除了Menu控件,没有其它控件不能运行。
我用的是--3.3.13.18版本
 楼主| 发表于 2015-3-20 13:55:05 | 显示全部楼层
回复 13# chzj589

@@ 我的版本 可以運行@@ v3.3.8.1  會卡住@@
发表于 2015-3-20 13:59:39 | 显示全部楼层
回复 14# kk_lee69
主窗口不放任何控件,我也不能点击放大缩小。
但只要有任何一个控件就行
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-2 09:34 , Processed in 0.086121 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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