Что нового

_GUICreateAlfa + AutoIt3Wrapper

saraconor

Новичок
Сообщения
357
Репутация
2
Помогите пожалуйста, как можно использовать png файл через _GUICreateAlfa, включенный в скрипт с помощью Wrapper?
Код:
#include <WindowsConstants.au3>
#include "_GUICreateAlfa.au3"

#AutoIt3Wrapper_Res_File_Add=1.png, png, IMG    ; ?

$prov = _GUICreateAlfa("",@ScriptDir&"\1.png")
sleep(1000)
exit
 

Вложения

Последнее редактирование:

joiner

Модератор
Локальный модератор
Сообщения
3 035
Репутация
503
Код:
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <GDIPlus.au3>

#AutoIt3Wrapper_Res_File_Add=1.png, png, IMG    
_GDIPlus_Startup()
_WinExFF()
_GDIPlus_Shutdown()

Func _WinExFF()
    Local $hInstance = _WinAPI_GetModuleHandle(0)
    Local $hImage = _LoadResourceImage($hInstance, 'png', "img")
    If @error Then Return
    Local $XW = _GDIPlus_ImageGetWidth($hImage)
    Local $YH = _GDIPlus_ImageGetHeight($hImage)
    Local $hGui = GUICreate('', $XW, $YH, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED, $WS_EX_TOPMOST))
    GUISetState(@SW_SHOW, $hGui)
    Local $hScrDC = _WinAPI_GetDC($hGui)
    Local $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    Local $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    Local $tSize = DllStructCreate($tagSIZE)
    Local $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, 'X', $XW)
    DllStructSetData($tSize, 'Y', $YH)
    Local $tSource = DllStructCreate($tagPOINT)
    Local $pSource = DllStructGetPtr($tSource)
    Local $tBlend = DllStructCreate($tagBLENDFUNCTION)
    Local $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, 'Format', 1)
    For $i = 0 To 255 Step 5
        DllStructSetData($tBlend, 'Alpha', $i)
        _WinAPI_UpdateLayeredWindow($hGui, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
        Sleep(30)
    Next
    Sleep(1000)
    For $i = 255 To 0 Step -5
        DllStructSetData($tBlend, 'Alpha', $i)
        _WinAPI_UpdateLayeredWindow($hGui, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
        Sleep(30)
    Next
    GUIDelete($hGui)
    _GDIPlus_ImageDispose($hImage)
    _WinAPI_ReleaseDC($hGui, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>_WinExFF

Func _LoadResourceImage($hInstance, $sResType, $sResName, $iResLanguage = 0)
    Local $hInfo, $hData, $pData, $iSize, $hMem, $pMem, $hStream, $hImage
    If $iResLanguage Then
        $hInfo = _WinAPI_FindResourceEx($hInstance, $sResType, $sResName, $iResLanguage)
    Else
        $hInfo = _WinAPI_FindResource($hInstance, $sResType, $sResName)
    EndIf
    $hData = _WinAPI_LoadResource($hInstance, $hInfo)
    $iSize = _WinAPI_SizeOfResource($hInstance, $hInfo)
    $pData = _WinAPI_LockResource($hData)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    $hMem = DllCall("kernel32.dll", "ptr", "GlobalAlloc", "uint", 2, "ulong_ptr", $iSize)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    $pMem = DllCall("kernel32.dll", "ptr", "GlobalLock", "ptr", $hMem[0])
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    DllCall("kernel32.dll", "none", "RtlMoveMemory", "ptr", $pMem[0], "ptr", $pData, "ulong_ptr", $iSize)
    DllCall("kernel32.dll", "int", "GlobalUnlock", "ptr", $hMem[0])
    $hStream = _WinAPI_CreateStreamOnHGlobal($hMem[0])
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    $hImage = DllCall("gdiplus.dll", "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "ptr*", 0)
    If (@error) Or ($hImage[0]) Or (Not $hImage[2]) Then
        $hImage = 0
    EndIf
    DllCall("kernel32.dll", "ptr", "GlobalFree", "ptr", $hMem[0])
    If Not IsArray($hImage) Then
        Return SetError(1, 0, 0)
    EndIf
    Return $hImage[2]
EndFunc   ;==>_LoadResourceImage
 
Верх