找回密码
 加入
搜索
查看: 2763|回复: 4

请教PNG透明加控件

[复制链接]
发表于 2008-8-4 16:48:44 | 显示全部楼层 |阅读模式
以下代码收集而来,可以实现显示一个PNG图片的窗体,但在这个窗体内加任何控件都不会显示。
$Label1 = GUICtrlCreateLabel("au3中文论坛", 10, 10, 300, 500)
谁有解决的办法吗?谢谢。
#include <WindowsConstants.au3> 
#include <GuiConstants.au3> 
#include <GuiEdit.au3> 
#include <IE.au3> 
#include <GDIPlus.au3> 
#NoTrayIcon;脚本开始执行时不显示托盘的图标 
Opt("GUIOnEventMode", 1) ; 切换为 OnEvent 模式 


$spimg = @TempDir & "lmp-splash.png" 
FileInstall("splash.png", $spimg, 1) 

Global Const $AC_SRC_ALPHA = 1 
_GDIPlus_Startup() 
$pngSrc = $spimg 
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc) 
$width = _GDIPlus_ImageGetWidth($hImage) 
$height = _GDIPlus_ImageGetHeight($hImage) 
$Splash = GUICreate("L|M|TER Media Player", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED, $DS_MODALFRAME) 
GUISetState(@SW_LOCK) 
SetBitmap($Splash, $hImage, 0) 
GUISetState() 
WinSetOnTop($Splash, "", 1) 
For $i = 0 To 255 Step 20 
    SetBitmap($Splash, $hImage, $i) 
    Sleep(5) 
Next 


Sleep(1000) 
;这里放些耗时的初始化操作 


For $i = 255 To 0 Step -10 
    SetBitmap($Splash, $hImage, $i) 
    Sleep(10) 
Next 
GUIDelete($Splash) 
_GDIPlus_ImageDispose($hImage) 
_GDIPlus_Shutdown() 

;_ReduceMemory(@AutoItPID) 
;这里是你的主循环脚本 


Func SetBitmap($hGUI, $hImage, $iOpacity) 
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend 
    $hScrDC = _WinAPI_GetDC(0) 
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) 
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) 
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) 
    $tSize = DllStructCreate($tagSIZE) 
    $pSize = DllStructGetPtr($tSize) 
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) 
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) 
    $tSource = DllStructCreate($tagPOINT) 
    $pSource = DllStructGetPtr($tSource) 
    $tBlend = DllStructCreate($tagBLENDFUNCTION) 
    $pBlend = DllStructGetPtr($tBlend) 
    DllStructSetData($tBlend, "Alpha", $iOpacity) 
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) 
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) 
    _WinAPI_ReleaseDC(0, $hScrDC) 
    _WinAPI_SelectObject($hMemDC, $hOld) 
    _WinAPI_DeleteObject($hBitmap) 
    _WinAPI_DeleteDC($hMemDC) 
EndFunc   ;==>SetBitmap 
 楼主| 发表于 2008-8-5 15:35:35 | 显示全部楼层
嘿嘿...哪位兄弟指点一下.
 楼主| 发表于 2008-8-7 01:37:20 | 显示全部楼层
发表于 2008-8-8 15:02:23 | 显示全部楼层
难呀!看的头痛。看不懂的。

[ 本帖最后由 redapple2008 于 2008-8-8 15:03 编辑 ]
发表于 2008-12-31 13:02:47 | 显示全部楼层
很想知道,有高手帮忙解决下么
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-12-23 12:52 , Processed in 0.068917 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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