找回密码
 加入
搜索
查看: 7213|回复: 12

GUI窗体 展开与折叠功能怎么做?[已解决]

 火.. [复制链接]
发表于 2010-5-6 12:02:41 | 显示全部楼层 |阅读模式
本帖最后由 chenzhi1210 于 2010-5-7 07:23 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 381, 264, 383, 142)
$Button1 = GUICtrlCreateButton("展开/折叠↓↓↓", 65, 96, 251, 25)
$Group1 = GUICtrlCreateGroup("被折叠部分", 14, 128, 353, 105)
$Label1 = GUICtrlCreateLabel("折叠后,窗口高度变小,就看不到这里了!不要影响到状态栏", 38, 176, 301, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
$Group2 = GUICtrlCreateGroup("信息", 14, 8, 353, 73)
$Label2 = GUICtrlCreateLabel("折叠前界面", 150, 40, 64, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

                Case $Button1
        EndSwitch
WEnd
请问点击$Button1后,$Button1的功能函数怎么写?

本帖子中包含更多资源

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

×
发表于 2010-5-6 13:17:07 | 显示全部楼层
设置某函数记录窗口状态或者直接获取窗口状态,后调用WinMove.
我的例子请,请自己更改:

   If         $EditPage=1 Then
                                                WinMove($title,"",Default,Default,Default,170)
                                                GUICtrlSetData($ProButton2,"详细过程")
                                                $EditPage=2
                                        Else
                                                WinMove($title,"",Default,Default,Default,370)
                                                GUICtrlSetData($ProButton2,"隐藏过程")
                                                $EditPage=1
                                        EndIf
发表于 2010-5-6 13:38:50 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 381, 150)
$Button1 = GUICtrlCreateButton("展开", 65, 96, 251, 25)
$Group1 = GUICtrlCreateGroup("被折叠部分", 14, 128, 353, 105)
$Label1 = GUICtrlCreateLabel("折叠后,窗口高度变小,就看不到这里了!不要影响到状态栏", 38, 176, 301, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
$Group2 = GUICtrlCreateGroup("信息", 14, 8, 353, 73)
$Label2 = GUICtrlCreateLabel("折叠前界面", 150, 40, 64, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

                Case $Button1
                        If GUICtrlRead($Button1) = "展开" Then
                                WinMove  ($Form1,"", Default, Default, Default , 264)
                                GUICtrlSetData($Button1,"折叠")
                        ElseIf GUICtrlRead($Button1) = "折叠" Then
                                WinMove  ($Form1,"", Default, Default,Default , 150)
                                GUICtrlSetData($Button1,"展开")
                        EndIf
        EndSwitch
WEnd
 楼主| 发表于 2010-5-6 21:09:16 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt('GUIResizeMode', 802)


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 381, 150)
$Button1 = GUICtrlCreateButton("展开", 65, 96, 251, 25)
$Group1 = GUICtrlCreateGroup("被折叠部分", 14, 128, 353, 105)
$Label1 = GUICtrlCreateLabel("折叠后,窗口高度变小,就看不到这里了!不要影响到状态栏", 38, 176, 301, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
GUICtrlSetResizing($StatusBar1,64)
$Group2 = GUICtrlCreateGroup("信息", 14, 8, 353, 73)
$Label2 = GUICtrlCreateLabel("折叠前界面", 150, 40, 64, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

                Case $Button1
                        If GUICtrlRead($Button1) = "展开" Then
                                WinMove  ($Form1,"", Default, Default, Default , 264)
                                GUICtrlSetData($Button1,"折叠")
                        ElseIf GUICtrlRead($Button1) = "折叠" Then
                                WinMove  ($Form1,"", Default, Default,Default , 180)
                                GUICtrlSetData($Button1,"展开")
                        EndIf
        EndSwitch
WEnd
以上代码,在展开或折叠时,状态栏不能根随着变化位置,不能保持定位在底部,请问怎么解决?
 楼主| 发表于 2010-5-6 21:35:04 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt('GUIResizeMode', 802)


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 381, 150)
$Button1 = GUICtrlCreateButton("展开", 65, 96, 251, 25)
$Group1 = GUICtrlCreateGroup("被折叠部分", 14, 128, 353, 105)
$Label1 = GUICtrlCreateLabel("折叠后,窗口高度变小,就看不到这里了!不要影响到状态栏", 38, 176, 301, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hStatus = _GUICtrlStatusBar_Create($Form1)
$Group2 = GUICtrlCreateGroup("信息", 14, 8, 353, 73)
$Label2 = GUICtrlCreateLabel("折叠前界面", 150, 40, 64, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
#EndRegion ### END Koda GUI section ###

Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
        _GUICtrlStatusBar_Resize($hStatus)
        Return $GUI_RUNDEFMSG
EndFunc
        
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1
                        If GUICtrlRead($Button1) = "展开" Then
                                WinMove  ($Form1,"", Default, Default, Default , 264)
                                GUICtrlSetData($Button1,"折叠")
                        ElseIf GUICtrlRead($Button1) = "折叠" Then
                                WinMove  ($Form1,"", Default, Default,Default , 180)
                                GUICtrlSetData($Button1,"展开")
                        EndIf
        EndSwitch
WEnd
已经解决!
感谢大家的帮助!
发表于 2010-5-7 00:40:50 | 显示全部楼层
几年不来,又学到新东西了。
发表于 2010-5-12 10:57:51 | 显示全部楼层
刚好需要这个,谢谢谢谢
发表于 2010-5-12 12:44:31 | 显示全部楼层
及学习了有收藏了!谢谢楼主!
发表于 2010-5-13 09:00:56 | 显示全部楼层
又学到新东西
发表于 2010-5-17 10:24:12 | 显示全部楼层
呵呵温习一下。。
发表于 2014-6-22 21:21:49 | 显示全部楼层
内容找的就是这功能
发表于 2015-2-18 21:32:12 | 显示全部楼层
不错 刚好需要 顶起~~~
发表于 2015-2-18 21:45:36 | 显示全部楼层
支持,学习了~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-28 14:11 , Processed in 0.087849 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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