以下代码收集而来,可以实现显示一个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
|