新手上路 发表于 2008-7-15 09:51:41

如何实现窗口伸缩功能?





如图,点击“高级”就会变大,点击“简洁”就会缩小。

[ 本帖最后由 新手上路 于 2008-7-15 18:04 编辑 ]

ceoguang 发表于 2008-7-15 13:25:03

源码发上来SEE SEE

顽固不化 发表于 2008-7-15 13:34:08

原帖由 ceoguang 于 2008-7-15 13:25 发表 http://www.autoitx.com/images/common/back.gif
源码发上来SEE SEE

http://www.sogho.cn/blog/6/archives/2008/2008415155536.htm
应该很简单,form是可以调整的,当调小后,右边的控件可以设置为不可见,调大后,右边的控件再设置为可见。

ceoguang 发表于 2008-7-15 14:30:51

噢,我以为楼主的代码是加了皮肤的.
不过楼上的源码不没有楼主的那么完整.

新手上路 发表于 2008-7-15 15:58:29

我肯定没有源码啦。3 楼给出的链接的代码里没有写出“高级”部分的代码。

顽固不化 发表于 2008-7-15 16:03:26

原帖由 新手上路 于 2008-7-15 15:58 发表 http://www.autoitx.com/images/common/back.gif
我肯定没有源码啦。3 楼给出的链接的代码里没有写出“高级”部分的代码。
注意到啦,确实没有高级这部分源码的。我加了点高级那部分的简单代码,修改其能再3.2.13.2.1内运行的。就当切磋学习。
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=LOGO\biosclub.ico
#AutoIt3Wrapper_Outfile=e:\onekey.exe
#EndRegion ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ListBoxConstants.au3>
#include <ComboConstants.au3>


#Region ### START Koda GUI section ### Form=e:\脚本\au3\gui\onekey.kxf
Global $sysinfo1, $sysinfo2
$sysinfo1 = True
$AForm1 = GUICreate("onekey 一键备份还原", 351, 200, -1, -1, $WS_SIZEBOX + $WS_SYSMENU)
$varhd = "C:"
$getlist = "C:"
$Group1 = GUICtrlCreateGroup("", 7, 0, 337, 132)
GUICtrlSetResizing($Group1,$GUI_DOCKALL)
$Group2 = GUICtrlCreateGroup("Ghost 操作:", 13, 13, 147, 47)
GUICtrlSetResizing($Group2,$GUI_DOCKALL)

$bf = GUICtrlCreateRadio("备分", 29, 30, 55, 17)
GUICtrlSetResizing($bf,$GUI_DOCKALL)
$hy = GUICtrlCreateRadio("还原", 94, 31, 49, 17)
GUICtrlSetResizing($hy,$GUI_DOCKALL)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
$bfhy = GUICtrlCreateGroup("备份分区:", 165, 13, 172, 60)
GUICtrlSetResizing($bfhy,$GUI_DOCKALL)
$Label1 = GUICtrlCreateLabel("C:盘总体容量:" & Round(DriveSpaceTotal("c:")) & "M", 186, 34, 141, 17, $WS_DISABLED)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
;$Label1 = GUICtrlCreateLabel("", 186, 34, 141, 17,$WS_DISABLED)
$Label2 = GUICtrlCreateLabel("", 186, 52, 141, 17, $WS_DISABLED)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
$List1 = GUICtrlCreateCombo($varhd, 225, 11, 39, 20, $CBS_DROPDOWNLIST)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
;GUICtrlCreateGroup("", -99, -99, 1, 1)
;$Group4 = GUICtrlCreateGroup("Ghost镜像文件路径:", 14, 72, 324, 51)
Global $sTmpFile = 'G:\Ghost\C_WinXP.GHO'
Global $hFile = GUICtrlCreateInput("G:\Ghost\C_WinXP.GHO", 21, 90, 241, 21)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
Global $hFileSel1 = GUICtrlCreateButton("保存(S)", 268, 89, 65, 22)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
$advbt = GUICtrlCreateButton("高级(&A)", 24, 139, 65, 23)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
$Button3 = GUICtrlCreateButton("撤销(&S)", 106, 139, 65, 23)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
$Button4 = GUICtrlCreateButton("确定(&O)", 187, 139, 65, 23)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
$cancelbutton = GUICtrlCreateButton("退出(&X)", 269, 139, 65, 23)
GUICtrlSetResizing(-1,$GUI_DOCKALL)
GUICtrlSetState($hy, $GUI_CHECKED)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$var = DriveGetDrive("FIXED")
If Not @error Then
        For $i = 1 To $var
                $varhd = GUICtrlSetData($List1, StringUpper($var[$i]))
                $lasthd = StringUpper($var)
                $lastdrv = StringUpper($var[$lasthd])
        Next
EndIf
While 1
        $Msg = GUIGetMsg()
        Select
                Case $Msg = $cancelbutton Or $Msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $Msg = $hy
                        $sysinfo1 = True
                        $sysinfo2 = False
                        $bfhyt = "还原分区:"
                        ;GUICtrlSetData($bfhy, $bfhyt)
                        GUICtrlSetData($hFileSel1, "打开(&O)")
                        ControlDisable("", "", $Button4)
                        ControlHide("", "", $Label2)
                        GUICtrlSetData($Label1, $getlist & "盘总体容量:" & Round(DriveSpaceTotal($getlist)) & "M")
                Case $Msg = $bf
                        $sysinfo2 = True
                        $sysinfo1 = False
                        $bfhyt = "备份分区:"
                        ;GUICtrlSetData($bfhy, $bfhyt)
                        GUICtrlSetData($hFileSel1, "保存(&S)")
                        ControlEnable("", "", $Button4)
                        ControlEnable("", "", $Button3)
                        ControlShow("", "", $Label2)
                        GUICtrlSetData($Label1, $getlist & "盘已用空间:" & (Round(DriveSpaceTotal($getlist)) - Round(DriveSpaceFree($getlist))) & "M")
                        GUICtrlSetData($Label2, $lastdrv & "盘可用空间:" & Round(DriveSpaceFree($lastdrv)) & "M")
                Case $Msg = $hFileSel1
                        If $bfhyt = "还原分区:" Then
                                Global $sTmpFile = FileOpenDialog("Select ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "(*.gho;)")
                                If @error Then ContinueLoop
                                GUICtrlSetData($hFile, $sTmpFile)
                        Else
                                Global $sTmpFile = FileSaveDialog("Select ", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "(*.gho;)")
                                If @error Then ContinueLoop
                                GUICtrlSetData($hFile, $sTmpFile)
                        EndIf
                Case $Msg = $List1
                        ;If BitAnd(GUICtrlRead($hy), $GUI_DEFBUTTON) Then
                        If $sysinfo1 = True Then
                                $getlist = GUICtrlRead($List1)
                                GUICtrlSetData($Label1, $getlist & "盘总体容量:" & (Round(DriveSpaceTotal($getlist))) & "M")
                        Else
                                GUICtrlSetData($Label1, $getlist & "盘已用空间:" & (Round(DriveSpaceTotal($getlist)) - Round(DriveSpaceFree($getlist))) & "M")
                        EndIf
                        If $sysinfo2 = True Then
                                $getlist = GUICtrlRead($List1)
                                GUICtrlSetData($Label1, $getlist & "盘已用空间:" & (Round(DriveSpaceTotal($getlist)) - Round(DriveSpaceFree($getlist))) & "M")
                        Else
                                GUICtrlSetData($Label1, $getlist & "盘总体容量:" & (Round(DriveSpaceTotal($getlist))) & "M")
                        EndIf
                Case $Msg = $advbt
                        $GorJ=GUICtrlRead($advbt)
                        gochange($GorJ)
                        ;GUICtrlSetData($advbt, "简洁(&S)")

        EndSelect
WEnd

Func gochange($GorJ)
        $XY=WinGetPos($AForm1)
        if $GorJ="简洁(&S)" Then
                GUICtrlSetData($advbt, "高级(&S)")
                $newY=$XY-100
        Else
                GUICtrlSetData($advbt, "简洁(&S)")
                $newY=$XY+100
        EndIf
        WinMove($AForm1,"",$XY,$XY,$XY,$newY)
EndFunc

新手上路 发表于 2008-7-15 18:04:16

楼上高手!
页: [1]
查看完整版本: 如何实现窗口伸缩功能?