找回密码
 加入
搜索
查看: 3471|回复: 0

[GUI管理] 请教gif透明色问题

[复制链接]
发表于 2012-8-5 22:04:51 | 显示全部楼层 |阅读模式
本帖最后由 xiehuahere 于 2012-8-6 13:21 编辑

下面两种方法都一样,gif动画刷新的时候看到白色底色,很难看。
如何解决?求指教。
  
方法一:
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

#NoTrayIcon
Const $SW = @DesktopWidth
Const $SH = @DesktopHeight
Local $Gif = @ScriptDir & '\throbber.gif'
If Not FileExists($Gif) Then Exit MsgBox(48 + 262144, "Warning", "Gif file not found!")
HotKeySet("{ESC}", "_Exit")

$MGUI = GUICreate("", $SW, $SH, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000, $MGUI)
GUISetState()
$subGUI = GUICreate("", 100, 100, -1, -1, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_LAYERED, $MGUI)
$BKcolor = 0xFFFFFF
GUISetBkColor($BKcolor)
_WinAPI_SetLayeredWindowAttributes($subGUI, $BKcolor, 255)
$oIE = ObjCreate('Shell.Explorer.2')
GUICtrlCreateObj($oIE, -10, -14, 165, 160)
$oIE.navigate($Gif)
GUISetState()
Do
        Local $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func _Exit()
        Exit
EndFunc
方法二(用AniGIF.ocx):
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>

#NoTrayIcon
Const $SW = @DesktopWidth
Const $SH = @DesktopHeight
FileInstall('AniGIF.ocx', @SystemDir & '\', 1)
RunWait('REGSVR32 /S ' & @SystemDir & '\AniGIF.ocx')
FileInstall('throbber.gif', @TempDir & '\', 1)

$MGUI = GUICreate("", $SW, $SH, 0, 0, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST)
GUISetBkColor(0x000000, $MGUI)
GUISetState()
$mainwindow = GUICreate('ESC退出', @DesktopWidth, @DesktopHeight, 0, 0, BitOR($WS_POPUP, $WS_CLIPSIBLINGS), $WS_EX_LAYERED, $MGUI)
$BKcolor = 0xFFFFFF
GUISetBkColor($BKcolor)
_WinAPI_SetLayeredWindowAttributes($mainwindow, $BKcolor, 255)
GUISetState(@SW_SHOW)
WinSetOnTop($mainwindow, '', 1)
$gif = _Create_GIF_Ctrl(@TempDir & '\throbber.gif', ($SW-100)/2, ($SH-100)/2, 100, 100)

HotKeySet("{ESC}", "_Exit")
Do
        Local $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

Func _Create_GIF_Ctrl($Gif_File_Name, $Gif_x = 0, $Gif_y = 0, $Gif_w = @DesktopWidth, $Gif_H = @DesktopHeight)
        Local $Obj_gif = ObjCreate("AniGIFCtrl.AniGIF")
        Local $id_ctrl_gif = GUICtrlCreateObj($Obj_gif, $Gif_x, $Gif_y, $Gif_w, $Gif_H)
        $Obj_gif.ReadGIF($Gif_File_Name)
        $Obj_gif.Transparent = True
        $Obj_gif.Speed = 1
        $Obj_gif.Play
        Return $id_ctrl_gif
EndFunc   ;==>_Create_GIF_Ctrl

Func _Exit()
        FileDelete(@TempDir & '\throbber.gif')
        Exit
EndFunc
用到的动画文件:
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-17 07:13 , Processed in 0.081930 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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