找回密码
 加入
搜索
查看: 360|回复: 4

[GUI管理] 子窗口控件怎么控制主窗口及如何自动关闭子窗口

[复制链接]
发表于 2023-9-17 22:14:55 | 显示全部楼层 |阅读模式
1.点击子窗口控件如何能控制主窗口显示

2,当子窗口失去焦点时如何自动关闭子窗口(类似Combo效果)
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
Dim $Radios[54][5] = [[0, 0, '黑=0', 0x000000, 0],[0, 1, '棕=1', 0x800000, 1],[0, 2, '红=2', 0xFF0000, 2],[0, 3, '橙=3', 0xFFA500, 3],[0, 4, '黄=4', 0xFFFF00, 4], _
                [0, 5, '绿=5', 0x008000, 5],[0, 6, '蓝=6', 0x0000FF, 6],[0, 7, '紫=7', 0x800080, 7],[0, 8, '灰=8', 0x808080, 8],[0, 9, '白=9', 0xFFFFFF, 9], _
                [1, 0, '黑=0', 0x000000, 0],[1, 1, '棕=1', 0x800000, 1],[1, 2, '红=2', 0xFF0000, 2],[1, 3, '橙=3', 0xFFA500, 3],[1, 4, '黄=4', 0xFFFF00, 4], _
                [1, 5, '绿=5', 0x008000, 5],[1, 6, '蓝=6', 0x0000FF, 6],[1, 7, '紫=7', 0x800080, 7],[1, 8, '灰=8', 0x808080, 8],[1, 9, '白=9', 0xFFFFFF, 9], _
                [2, 0, '黑=0', 0x000000, 0],[2, 1, '棕=1', 0x800000, 1],[2, 2, '红=2', 0xFF0000, 2],[2, 3, '橙=3', 0xFFA500, 3],[2, 4, '黄=4', 0xFFFF00, 4], _
                [2, 5, '绿=5', 0x008000, 5],[2, 6, '蓝=6', 0x0000FF, 6],[2, 7, '紫=7', 0x800080, 7],[2, 8, '灰=8', 0x808080, 8],[2, 9, '白=9', 0xFFFFFF, 9], _
                [3, 0, '黑=0', 0x000000, 0],[3, 1, '棕=1', 0x800000, 1],[3, 2, '红=2', 0xFF0000, 2],[3, 3, '橙=3', 0xFFA500, 3],[3, 4, '黄=4', 0xFFFF00, 4], _
                [3, 5, '绿=5', 0x008000, 5],[3, 6, '蓝=6', 0x0000FF, 6],[3, 7, '紫=7', 0x800080, 7],[3, 8, '金=-1', 0xFFD700, -1],[3, 9, '银=-2', 0xC0C0C0, -2], _
                [4, 0, '棕=±1', 0x800000, '±1'],[4, 1, '红=±2', 0xFF0000, '±2'],[4, 2, '绿=±0.5', 0x008000, '±0.5'],[4, 3, '蓝=±0.25', 0x0000FF, '±0.25'],[4, 4, '紫=±0.1', 0x800080, '±0.1'], _
                [4, 5, '灰=±0.05', 0x808080, '±0.05'],[4, 6, '金=±5', 0xFFD700, '±5'],[4, 7, '银=±10', 0xC0C0C0, '±10'], _
                [5, 0, '棕=100ppm', 0x800000, '100ppm/℃'],[5, 1, '红=50ppm', 0xFF0000, '50ppm/℃'],[5, 2, '橙=15ppm', 0xFFA500, '15ppm/℃'],[5, 3, '黄=25ppm', 0xFFFF00, '25ppm/℃'],[5, 4, '蓝=10ppm', 0x0000FF, '10ppm/℃'], _
                [5, 5, '紫=5ppm', 0x800080, '5ppm/℃']]
Dim $i, $i_from, $i_to, $Radio[54]
$Form1 = GUICreate("Form1", 623, 449, 226, 115)
$Label1 = GUICtrlCreateLabel("Label1", 168, 48, 55, 25, $SS_SUNKEN)
$Label2 = GUICtrlCreateLabel("Label1", 228, 48, 55, 25, $SS_SUNKEN)
$Label3 = GUICtrlCreateLabel("Label1", 287, 48, 55, 25, $SS_SUNKEN)
$Label4 = GUICtrlCreateLabel("Label1", 347, 48, 55, 25, $SS_SUNKEN)
$Label5 = GUICtrlCreateLabel("Label1", 406, 48, 55, 25, $SS_SUNKEN)
$Label6 = GUICtrlCreateLabel("Label1", 466, 48, 55, 25, $SS_SUNKEN)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Label1
                        AdlibRegister(_SubGUI(0, 9))
                Case $Label2
                        AdlibRegister(_SubGUI(10, 19))
                Case $Label3
                        AdlibRegister(_SubGUI(20, 29))
                Case $Label4
                        AdlibRegister(_SubGUI(30, 39))
                Case $Label5
                        AdlibRegister(_SubGUI(40, 47))
                Case $Label6
                        AdlibRegister(_SubGUI(48, 53))

        EndSwitch
WEnd

Func _SubGUI($i_from, $i_to)
        $Pos = MouseGetPos()
        $SubGUI = GUICreate("", 100, 270, $Pos[0], $Pos[1], $Form1)
        GUISetFont(14)
        For $i = $i_from To $i_to
                $Radio[$i] = GUICtrlCreateRadio($Radios[$i][2], 0, 25 * ($i - $i_from), 90, 25)
                GUICtrlSetBkColor(-1, $Radios[$i][3])
        Next
        GUISetState(@SW_SHOW)
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                        Case $Radio[0] To $Radio[53]
                                GUISetBkColor($Label1, $Radios[$i][3])
                EndSwitch
        WEnd
EndFunc   ;==>_SubGUI

发表于 2023-9-17 23:05:04 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Global $Radios[54][5] = [[0, 0, '黑=0', 0x000000, 0], [0, 1, '棕=1', 0x800000, 1], [0, 2, '红=2', 0xFF0000, 2], [0, 3, '橙=3', 0xFFA500, 3], [0, 4, '黄=4', 0xFFFF00, 4], _
                [0, 5, '绿=5', 0x008000, 5], [0, 6, '蓝=6', 0x0000FF, 6], [0, 7, '紫=7', 0x800080, 7], [0, 8, '灰=8', 0x808080, 8], [0, 9, '白=9', 0xFFFFFF, 9], _
                [1, 0, '黑=0', 0x000000, 0], [1, 1, '棕=1', 0x800000, 1], [1, 2, '红=2', 0xFF0000, 2], [1, 3, '橙=3', 0xFFA500, 3], [1, 4, '黄=4', 0xFFFF00, 4], _
                [1, 5, '绿=5', 0x008000, 5], [1, 6, '蓝=6', 0x0000FF, 6], [1, 7, '紫=7', 0x800080, 7], [1, 8, '灰=8', 0x808080, 8], [1, 9, '白=9', 0xFFFFFF, 9], _
                [2, 0, '黑=0', 0x000000, 0], [2, 1, '棕=1', 0x800000, 1], [2, 2, '红=2', 0xFF0000, 2], [2, 3, '橙=3', 0xFFA500, 3], [2, 4, '黄=4', 0xFFFF00, 4], _
                [2, 5, '绿=5', 0x008000, 5], [2, 6, '蓝=6', 0x0000FF, 6], [2, 7, '紫=7', 0x800080, 7], [2, 8, '灰=8', 0x808080, 8], [2, 9, '白=9', 0xFFFFFF, 9], _
                [3, 0, '黑=0', 0x000000, 0], [3, 1, '棕=1', 0x800000, 1], [3, 2, '红=2', 0xFF0000, 2], [3, 3, '橙=3', 0xFFA500, 3], [3, 4, '黄=4', 0xFFFF00, 4], _
                [3, 5, '绿=5', 0x008000, 5], [3, 6, '蓝=6', 0x0000FF, 6], [3, 7, '紫=7', 0x800080, 7], [3, 8, '金=-1', 0xFFD700, -1], [3, 9, '银=-2', 0xC0C0C0, -2], _
                [4, 0, '棕=±1', 0x800000, '±1'], [4, 1, '红=±2', 0xFF0000, '±2'], [4, 2, '绿=±0.5', 0x008000, '±0.5'], [4, 3, '蓝=±0.25', 0x0000FF, '±0.25'], [4, 4, '紫=±0.1', 0x800080, '±0.1'], _
                [4, 5, '灰=±0.05', 0x808080, '±0.05'], [4, 6, '金=±5', 0xFFD700, '±5'], [4, 7, '银=±10', 0xC0C0C0, '±10'], _
                [5, 0, '棕=100ppm', 0x800000, '100ppm/℃'], [5, 1, '红=50ppm', 0xFF0000, '50ppm/℃'], [5, 2, '橙=15ppm', 0xFFA500, '15ppm/℃'], [5, 3, '黄=25ppm', 0xFFFF00, '25ppm/℃'], [5, 4, '蓝=10ppm', 0x0000FF, '10ppm/℃'], _
                [5, 5, '紫=5ppm', 0x800080, '5ppm/℃']]
Dim $i, $i_from, $i_to, $Radio[54]
$Form1 = GUICreate("Form1", 623, 449)
$Label1 = GUICtrlCreateLabel("Label1", 168, 48, 55, 25, $SS_SUNKEN)
$Label2 = GUICtrlCreateLabel("Label1", 228, 48, 55, 25, $SS_SUNKEN)
$Label3 = GUICtrlCreateLabel("Label1", 287, 48, 55, 25, $SS_SUNKEN)
$Label4 = GUICtrlCreateLabel("Label1", 347, 48, 55, 25, $SS_SUNKEN)
$Label5 = GUICtrlCreateLabel("Label1", 406, 48, 55, 25, $SS_SUNKEN)
$Label6 = GUICtrlCreateLabel("Label1", 466, 48, 55, 25, $SS_SUNKEN)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Label1
                        _SubGUI(0, 9, $nMsg)
                Case $Label2
                        _SubGUI(10, 19, $nMsg)
                Case $Label3
                        _SubGUI(20, 29, $nMsg)
                Case $Label4
                        _SubGUI(30, 39, $nMsg)
                Case $Label5
                        _SubGUI(40, 47, $nMsg)
                Case $Label6
                        _SubGUI(48, 53, $nMsg)

        EndSwitch
WEnd

Func _SubGUI($i_from, $i_to , $iCtrlID)
        $Pos = MouseGetPos()
        $SubGUI = GUICreate("", 100, 270, $Pos[0], $Pos[1], $Form1)
        GUISetFont(14)
        For $i = $i_from To $i_to
                $Radio[$i] = GUICtrlCreateRadio($Radios[$i][2], 0, 25 * ($i - $i_from), 90, 25)
                GUICtrlSetBkColor(-1, $Radios[$i][3])
        Next
        GUISetState(@SW_SHOW)
        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                GUIDelete($SubGUI)
                                Return
                        Case $Radio[$i_from] To $Radio[$i_to]
                                $index = $i_from +  $nMsg -$Radio[$i_from]
                                GUICtrlsetBkColor($iCtrlID, $Radios[$index][3])
                EndSwitch
                If WinGetHandle('[active]') <> $SubGUI Then
                        GUIDelete($SubGUI)
                        Return
                EndIf
        WEnd
EndFunc   ;==>_SubGUI

 楼主| 发表于 2023-9-18 09:47:31 | 显示全部楼层

虽然暂时还没看明白,但看起来好牛屁的样子...
发表于 2023-9-18 10:14:12 | 显示全部楼层
$SubGUI = GUICreate("", 100, 270, $Pos[0], $Pos[1], $Form1)  两位都掉了两位参数……
 楼主| 发表于 2023-9-18 10:52:03 | 显示全部楼层
afan 发表于 2023-9-18 10:14
$SubGUI = GUICreate("", 100, 270, $Pos[0], $Pos[1], $Form1)  两位都掉了两位参数……

啥参数???

============
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 02:42 , Processed in 0.136714 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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