鱼与熊掌可兼得?怎样实现GUI窗口渐变且控件不失效,详见实例效果
#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 = $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
本帖最后由 netegg 于 2015-4-1 14:15 编辑
#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
似乎不是很稳定,再想想吧 回复 2# netegg
好像是不很稳定,没其他好方法了吗?不要GDI+ 闪瞎…#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 = $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, $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 = $x
ReDim $aColor[$x + 1]
Return $aColor
EndFunc ;==>_ArrayCreat
Func Timer()
$iColor += 1
If $iColor = $aColor Then $iColor = 1
GUISetBkColor($aColor[$iColor], $Form1)
EndFunc ;==>Timer
LZ的Au版本很低,AdlibRegister 改回 AdlibEnable 吧
页:
[1]