找回密码
 加入
搜索
查看: 3380|回复: 3

[GUI管理] 鱼与熊掌可兼得?怎样实现GUI窗口渐变且控件不失效,详见实例效果

[复制链接]
发表于 2015-4-1 10:36:12 | 显示全部楼层 |阅读模式
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
#Include <File.au3>
$Form1 = GUICreate("",400,200,-1,-1)
$Input = GUICtrlCreateInput(" 点  击  此  处  选  择  文  件",100,51,200,21)
GUICtrlSetState(-1,$GUI_DISable)
$Button1 = GUICtrlCreateButton("确认",100,100,76, 25)
$Button2 = GUICtrlCreateButton("退出",225,100,76, 25)
GUISetState(@SW_SHOW)
AdlibEnable("Timer")
While 1
        
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE,$Button2
                        Exit
                Case $GUI_EVENT_PRIMARYDOWN
                        $pos = GUIGetCursorInfo($Form1)
                        If $pos[4] = $Input Then
                                $oPath = FileSelectFolder("选择一个文件夹","")
                                GUICtrlSetData($Input,$oPath)
                        EndIf
                Case $Button1
                        $path = GUICtrlRead($Input)
                        $oFile = _FileListToArray($path,"*.xls",1)
                        If @error Then 
                                MsgBox(16,"!警告!","请正确选择文件夹")
                        Else
                                MsgBox(64,"ok","okokokokokokokokokokokok")
                        EndIf
        EndSwitch
WEnd


Func Timer()

                For $a =100 To 255
                        GUISetBkColor("0x"&Hex($a,2)&"0000",$Form1)
                        Sleep(20)
                Next
                For $a = 0 To 255
                        GUISetBkColor("0xff"&Hex($a,2)&"00",$Form1)
                        Sleep(20)
                Next
                For $a = 0 To 200
                        GUISetBkColor("0xffff"&Hex($a,2),$Form1)
                        Sleep(20)
                Next
                For $a = 200 To 0 Step -1
                        GUISetBkColor("0xffff"&Hex($a,2),$Form1)
                        Sleep(20)
                Next
                For $a = 255 To 0 step -1
                        GUISetBkColor("0xff"&Hex($a,2)&"00",$Form1)
                        Sleep(20)
                Next
                For $a = 255 To 100 step -1
                        GUISetBkColor("0x"&Hex($a,2)&"0000",$Form1)
                        Sleep(20)
                Next
EndFunc






        
发表于 2015-4-1 13:09:28 | 显示全部楼层
本帖最后由 netegg 于 2015-4-1 14:15 编辑

[au3]#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Opt("MustDeclareVars", 1)
Opt('GUIOnEventMode', 0)
_Example()

Func _Example()
        Local $hGUI, $hGraphics, $hBrush, $button, $msg
        ;        GUISetOnEvent()
        ; Initialize GDI+
        _GDIPlus_Startup()
       
        $hGUI = GUICreate("_GDIPlus_LineBrushCreate Example", 400, 200)
        $button = GUICtrlCreateButton('', 10, 10, 100, 30)
        GUISetState()
        $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
        ; Create a linear gradient brush that changes gradually from red to green
        $hBrush = _GDIPlus_LineBrushCreate(0, 0, 50, 100, 0xFFFF0000, 0xFF00FF00, 1) ; Flip the brush
       
        ; Fill a rectangle with the linear gradient brush
        _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, 400, 200, $hBrush)
       
       
        While 1
                $msg = GUIGetMsg()
                Switch $msg
                        Case $button
                                MsgBox(0, 0, 0)
                        Case -3
                                ExitLoop
                EndSwitch
        WEnd
        _GDIPlus_BrushDispose($hBrush)
        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_Shutdown()
        $GUI_EVENT_CLOSE
EndFunc   ;==>_Example
[/au3]似乎不是很稳定,再想想吧

评分

参与人数 1金钱 +10 收起 理由
ap112 + 10

查看全部评分

 楼主| 发表于 2015-4-8 13:50:37 | 显示全部楼层
回复 2# netegg


    好像是不很稳定,没其他好方法了吗?不要GDI+
发表于 2015-4-8 15:01:40 | 显示全部楼层
闪瞎…
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>

$Form1 = GUICreate("", 400, 200, -1, -1)
$Input = GUICtrlCreateInput(" 点  击  此  处  选  择  文  件", 100, 51, 200, 21)
GUICtrlSetState(-1, $GUI_DISable)
$Button1 = GUICtrlCreateButton("确认", 100, 100, 76, 25)
$Button2 = GUICtrlCreateButton("退出", 225, 100, 76, 25)
GUISetState(@SW_SHOW)
$aColor = _ArrayCreat()
$iColor = 0
AdlibRegister("Timer", 20)

While 1

        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        Exit
                Case $GUI_EVENT_PRIMARYDOWN
                        $pos = GUIGetCursorInfo($Form1)
                        If $pos[4] = $Input Then
                                $oPath = FileSelectFolder("选择一个文件夹", "")
                                GUICtrlSetData($Input, $oPath)
                        EndIf
                Case $Button1
                        $path = GUICtrlRead($Input)
                        $oFile = _FileListToArray($path, "*.xls", 1)
                        If @error Then
                                MsgBox(16, "!警告!", "请正确选择文件夹")
                        Else
                                MsgBox(64, "ok", "okokokokokokokokokokokok")
                        EndIf
        EndSwitch
WEnd

Func _ArrayCreat()
        Local $aColor[1500], $x = 0
        For $a = 100 To 255
                $x += 1
                $aColor[$x] = "0x" & Hex($a, 2) & "0000"
        Next
        For $a = 0 To 255
                $x += 1
                $aColor[$x] = "0xff" & Hex($a, 2) & "00"
        Next
        For $a = 0 To 200
                $x += 1
                $aColor[$x] = "0xffff" & Hex($a, 2)
        Next
        For $a = 200 To 0 Step -1
                $x += 1
                $aColor[$x] = "0xffff" & Hex($a, 2)
        Next
        For $a = 255 To 0 Step -1
                $x += 1
                $aColor[$x] = "0xff" & Hex($a, 2) & "00"
        Next
        For $a = 255 To 100 Step -1
                $x += 1
                $aColor[$x] = "0x" & Hex($a, 2) & "0000"
        Next
        $aColor[0] = $x
        ReDim $aColor[$x + 1]
        Return $aColor
EndFunc   ;==>_ArrayCreat

Func Timer()
        $iColor += 1
        If $iColor = $aColor[0] Then $iColor = 1
        GUISetBkColor($aColor[$iColor], $Form1)
EndFunc   ;==>Timer
LZ的Au版本很低,AdlibRegister 改回 AdlibEnable 吧

评分

参与人数 1金钱 +10 收起 理由
ap112 + 10 咋可以不闪瞎

查看全部评分

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

本版积分规则

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

GMT+8, 2024-5-3 23:13 , Processed in 0.085244 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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