Problema con fondo y botones
Publicado: 12 Ene 2012, 07:22
Verán tengo un autopatch para una aplicación, el código original venia sólo con el típico form de autoit, le puse imágenes BMP y jpg de fondo(la jpg de fondo, haciendo de form) pero ahora quise cambiarla poniendo una imagen PNG en vez de una jpg o bmp pude adaptar código de una aplicación del foro de autoit en ingles pero no me funciona del todo, el programa tiene botones pero los botones desaparecen cosa que deberían mostrarse encima de la imagen que se supone es el fondo pero, la imagen se ve lo que se supone es el fondo y los botones no ni su mini-navegador, desearía saber que puse mal en el código siguiente va todo el proyecto(imágenes no, se puede poner cualquiera) dejaré un ejemplo para que entiendan mejor mi problema:
Como se ve:
Como debería verse:
Como pueden ver, los botones van arriba, les agradecería de mucho su ayuda, también dejo el código sin ninguna modificación osea, como lo tenía sin imágenes png solo jpg por si les sirve(El de arriba es el el que me está dando los problemas este es su "source" original)
Y el código que tome para las imagenes png
Como se ve:
Como debería verse:
Código: Seleccionar todo
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIplus.au3>
#include <Memory.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include<INet.au3>
#include <Process.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
$Titolo="autopatch"
$NomeLauncher="cleitne.exe"
$LinkItemShop="http://miip"
$Linkpack="http://miip/servers/pack/pack.rar"
$LinkVersione="http://miip/version.txt"
$LinkRegistrazione="http://miip"
FileInstall("zpak.exe",@ScriptDir & "\zpak.exe")
; <== VARIABILI DA MODIFICARE
Local $Lampeggio=false,$Stato=true,$Timer=TimerInit()
Opt("MustDeclareVars", 0)
Global Const $AC_SRC_ALPHA = 1
;~ Global Const $ULW_ALPHA = 2
; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "/fondo.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
; Extract image width and height from PNG
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$Main=GUICreate($Titolo, 650, 414, Default, Default, $WS_POPUP, $WS_EX_LAYERED)
GUICtrlSetState(-1, $GUI_DISABLE)
SetBitmap($Main, $hImage, 0)
; Register notification messages
GUIRegisterMsg($WM_HSCROLL , "WM_HSCROLL" )
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState(@SW_SHOW)
;fade in png background
For $i = 0 To 255 Step 10
SetBitmap($Main, $hImage, $i)
Next
Local Const $STM_SETIMAGE = 0x0172
$Bottone1=GUICtrlCreateButton("Iniciar juego",500,50,123,36,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone1,"patchskin/btn_startgame_fs.bmp")
$Bottone2=GUICtrlCreateButton("Ociones",500,90,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone2,"patchskin/btn_settings_fs.bmp")
$Bottone3=GUICtrlCreateButton("Registrar",500,125,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone3,"patchskin/btn_newaccount_fs.bmp")
$Bottone4=GUICtrlCreateButton("Donaciones",500,160,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone4,"patchskin/btn_donations.bmp")
$Bottone5=GUICtrlCreateButton("Actualizar",500,190,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone5,"patchskin/btn_update1.bmp")
$Bottone6=GUICtrlCreateButton("Salir",500,210,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone6,"patchskin/btn_quit_fs.bmp")
$Bottone7=GUICtrlCreateButton("Minimizar",590,10,16,15,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone7,"patchskin/_1.bmp")
$Bottone8=GUICtrlCreateButton("Cerrar",610,10,16,15,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone8,"patchskin/x1.bmp")
;~ $Pic = GUICtrlCreatePic($hImage, $width, $height, Default, Default, $WS_EX_LAYERED, $STM_SETIMAGE)
GUICtrlSetImage ($Main,"patchskin/main2.bmp")
$object = ObjCreate("Shell.Explorer.2")
$object_ctrl = GUICtrlCreateObj($object, 10, 35, 475, 355)
GUISetState(@SW_SHOW)
_ControlloAggiornamenti()
#include <GUIConstants.au3>
#include <IE.au3>
_IENavigate($object, "http://www.google.com")
GUISetState()
$controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $Main)
GUIDelete($controlGui)
;fade out png background
For $i = 255 To 255 Step -10
SetBitmap($Main, $hImage, $i)
Next
; Release resources
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
While 1
If $Lampeggio=true then _Lampeggio()
Switch GUIGetMsg()
Case -3
Exit
Case $Bottone1
Run($NomeLauncher)
Exit
Case $Bottone2
if not ProcessExists("config.exe") then RunWait("config.exe")
Case $Bottone3
_RunDOS("start " & $LinkRegistrazione)
Case $Bottone4
_RunDOS("start " & $LinkItemShop)
Case $Bottone5
_Aggiorna()
Case $Bottone6
Exit
Case $Bottone8
Exit
Case $Bottone7
GUISetState(@SW_MINIMIZE)
EndSwitch
WEnd
Func _ControlloAggiornamenti()
If IniRead("patch.cfg","Patcher","Actualizacion",0)<_INetGetSource($LinkVersione) then
$Lampeggio=true
else
GUICtrlSetState($Bottone5,128)
EndIf
EndFunc
Func _Lampeggio()
If TimerDiff($Timer)>500 and $Stato=true then
GUICtrlSetImage ($Bottone5,"patchskin/btn_update2.bmp")
$Stato=false
elseif TimerDiff($Timer)>1000 and $Stato=false then
GUICtrlSetBkColor($Bottone5,-1)
$Stato=true
$Timer=TimerInit()
EndIf
EndFunc
; SetBitMap
; ====================================================================================================
Func SetBitmap($Main, $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($Main, $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
; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself.
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
$aRet = DllCall("shell32.dll", "long", "ShellExecute", _
"hwnd", 0, _
"string", "", _
"string", $sCmd, _
"string", $sArg, _
"string", $sFolder, _
"int", $rState)
If @error Then Return 0
$RetVal = $aRet[0]
If $RetVal > 32 Then
Return 1
Else
Return 0
EndIf
EndFunc ;==>_ShellExecute
Func WM_HSCROLL($hWnd, $iMsg, $iwParam, $ilParam)
EndFunc
; ===============================================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ===============================================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
if ($hWnd = $Main) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION
EndFunc
Func _Aggiorna()
$Lampeggio=false
GUICtrlSetBkColor($Bottone5,-1)
GUICtrlSetState($Bottone5,128)
GUICtrlDelete($Bottone5)
$Info=GUICtrlCreateLabel("Descarga en curso...",10, 8, 100, 21)
InetGet($Linkpack,@ScriptDir & "\pack.rar")
GUICtrlSetData($Info,"Instalando...")
_RunDOS("zpak.exe x -y pack.rar")
FileDelete(@ScriptDir & "\pack.rar")
GUICtrlDelete($Info)
MsgBox(64,"Actualizado","La actualización finalizó, ya puedes jugar!")
EndFunc
Código: Seleccionar todo
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GDIplus.au3>
#include <Memory.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include<INet.au3>
#include <Process.au3>
$Titolo="Hidra autopatch"
$NomeLauncher="mt2fire.bin"
$LinkItemShop="http://miip"
$Linkpack="http://miip/servers/pack/pack.rar"
$LinkVersione="http://miip/version.txt"
$LinkRegistrazione="http://miip"
FileInstall("zpak.exe",@ScriptDir & "\zpak.exe")
; <== VARIABILI DA MODIFICARE
Local $Lampeggio=false,$Stato=true,$Timer=TimerInit()
$Main=GUICreate($Titolo,630, 438, Default, Default, $WS_POPUP)
GUICtrlSetState(-1, $GUI_DISABLE)
$Bottone1=GUICtrlCreateButton("Iniciar juego",500,50,123,36,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone1,"patchskin/btn_startgame_fs.bmp")
$Bottone2=GUICtrlCreateButton("Ociones",500,90,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone2,"patchskin/btn_settings_fs.bmp")
$Bottone3=GUICtrlCreateButton("Registrar",500,125,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone3,"patchskin/btn_newaccount_fs.bmp")
$Bottone4=GUICtrlCreateButton("Donaciones",500,160,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone4,"patchskin/btn_donations.bmp")
$Bottone5=GUICtrlCreateButton("Actualizar",500,190,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone5,"patchskin/btn_update1.bmp")
$Bottone6=GUICtrlCreateButton("Salir",500,210,123,21,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone6,"patchskin/btn_quit_fs.bmp")
$Bottone7=GUICtrlCreateButton("Minimizar",590,10,16,15,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone7,"patchskin/_1.bmp")
$Bottone8=GUICtrlCreateButton("Cerrar",610,10,16,15,$BS_BITMAP)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetImage ($Bottone8,"patchskin/x1.bmp")
$Pic1 = GUICtrlCreatePic("patchskin/fondo.jpg",0,0,630, 438, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)
$Mysql = GUICtrlCreateInput("Conexión MySql", 4, 413, 91, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetBkColor($Mysql,0x888888)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
$Login = GUICtrlCreateInput("Estado Login", 95, 413, 91, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetBkColor($Login,0x888888)
$Ch1 = GUICtrlCreateInput("Estado Ch1", 186, 413, 91, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetBkColor($Ch1,0x888888)
$Web = GUICtrlCreateInput("Conexión Web", 277, 413, 91, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetFont(-1, 8, 400, 0, "Tahoma")
GUICtrlSetBkColor($Web,0x888888)
$object = ObjCreate("Shell.Explorer.2")
$object_ctrl = GUICtrlCreateObj($object, 5, 35, 440, 355)
GUISetState(@SW_SHOW)
_ControlloAggiornamenti()
Mysql()
Login()
Ch1()
Web()
#include <GUIConstants.au3>
#include <IE.au3>
_IENavigate($object, "http://miip/xmages.html")
GUISetState()
While 1
If $Lampeggio=true then _Lampeggio()
Switch GUIGetMsg()
Case -3
Exit
Case $Bottone1
Run($NomeLauncher)
Exit
Case $Bottone2
if not ProcessExists("configuracion.exe") then RunWait("configuracion.exe")
Case $Bottone3
_RunDOS("start " & $LinkRegistrazione)
Case $Bottone4
_RunDOS("start " & $LinkItemShop)
Case $Bottone5
_Aggiorna()
Case $Bottone6
Exit
Case $Bottone8
Exit
Case $Bottone7
GUISetState(@SW_MINIMIZE)
EndSwitch
WEnd
Func Mysql()
TCPStartup()
$var=TCPConnect("http://miip","33060")
if $var < 0 Then
SetButt(False)
Return False
Else
SetButt(True)
Return True
EndIf
EndFunc
Func Login()
TCPStartup()
$var=TCPConnect("http://miip","11002")
if $var < 0 Then
Loginestado(False)
Return False
Else
Loginestado(True)
Return True
EndIf
EndFunc
Func Ch1()
TCPStartup()
$var=TCPConnect("http://miip","13000")
if $var < 0 Then
EstadoCh1(False)
Return False
Else
EstadoCh1(True)
Return True
EndIf
EndFunc
Func Web()
TCPStartup()
$var=TCPConnect("http://miip","8080")
if $var < 0 Then
EstadoWeb(False)
Return False
Else
EstadoWeb(True)
Return True
EndIf
EndFunc
Func _ControlloAggiornamenti()
If IniRead("patch.cfg","Patcher","Actualizacion",0)<_INetGetSource($LinkVersione) then
$Lampeggio=true
else
GUICtrlSetState($Bottone5,128)
EndIf
EndFunc
Func SetButt($Stato)
if $Stato = true Then
GUICtrlSetData($Mysql,"MySql: Online")
GUICtrlSetBkColor($Mysql,0xB7FF00)
Else
GUICtrlSetData($Mysql,"MySql: Offline")
GUICtrlSetBkColor($Mysql,0xFF0000)
EndIf
EndFunc
Func Loginestado($Stato)
if $Stato = true Then
GUICtrlSetData($Login,"Login: Online")
GUICtrlSetBkColor($Login,0xB7FF00)
Else
GUICtrlSetData($Login,"Login: Offline")
GUICtrlSetBkColor($Login,0xFF0000)
EndIf
EndFunc
Func EstadoCh1($Stato)
if $Stato = true Then
GUICtrlSetData($Ch1,"Ch1: Online")
GUICtrlSetBkColor($Ch1,0xB7FF00)
Else
GUICtrlSetData($Ch1,"Ch1: Offline")
GUICtrlSetBkColor($Ch1,0xFF0000)
EndIf
EndFunc
Func EstadoWeb($Stato)
if $Stato = true Then
GUICtrlSetData($Web,"Web: Disponible")
GUICtrlSetBkColor($Web,0xB7FF00)
Else
GUICtrlSetData($Web,"Web: No disponible")
GUICtrlSetBkColor($Web,0xFF0000)
EndIf
EndFunc
Func _Lampeggio()
If TimerDiff($Timer)>500 and $Stato=true then
GUICtrlSetImage ($Bottone5,"patchskin/btn_update2.bmp")
$Stato=false
elseif TimerDiff($Timer)>1000 and $Stato=false then
GUICtrlSetBkColor($Bottone5,-1)
$Stato=true
$Timer=TimerInit()
EndIf
EndFunc
Func _Aggiorna()
$Lampeggio=false
GUICtrlSetBkColor($Bottone5,-1)
GUICtrlSetState($Bottone5,128)
GUICtrlDelete($Bottone5)
$Info=GUICtrlCreateLabel("Descarga en curso...",10, 8, 100, 21)
InetGet($Linkpack,@ScriptDir & "\pack.rar")
GUICtrlSetData($Info,"Instalando...")
_RunDOS("zpak.exe x -y pack.rar")
FileDelete(@ScriptDir & "\pack.rar")
GUICtrlDelete($Info)
MsgBox(64,"Actualizado","La actualización finalizó, ya puedes jugar!")
EndFunc
Código: Seleccionar todo
; Special thanks to GaryFrost for updating this to work with AutoIt v3.2.12.0!
#NoTrayIcon
#include <GDIPlus.au3>; this is where the magic happens, people
#include <GuiComboBox.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
Opt("MustDeclareVars", 0)
Global Const $AC_SRC_ALPHA = 1
;~ Global Const $ULW_ALPHA = 2
Global $old_string = "", $runthis = ""
Global $launchDir = @DesktopDir
; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\fondo.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)
; Extract image width and height from PNG
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
; Create layered window
$GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
WinSetOnTop($GUI, "", 1)
;fade in png background
For $i = 0 To 255 Step 10
SetBitmap($GUI, $hImage, $i)
Next
; create child MDI gui window to hold controls
; this part could use some work - there is some flicker sometimes...
$controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)
; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)
; just a text label
GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter", 50, 12, 140, 50)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
; combo box listing all items on desktop
$Combo = GUICtrlCreateCombo("", 210, 12, 250, -1)
GUICtrlSetFont($Combo, 12)
; set default button for Enter key activation - renders outside GUI window
$goButton = GUICtrlCreateButton("Go", $width, $height, 10, 10, $BS_DEFPUSHBUTTON)
GUISetState()
; get list of files on desktop, show in combobox
$aFileList = _FileListToArray($launchDir)
_ArraySort($aFileList, 0, 1)
$FileList = _ArrayToString($aFileList, "|", 1)
GUICtrlSetData($Combo, $FileList)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $goButton
$runthis = GUICtrlRead($Combo)
ExitLoop
EndSelect
WEnd
If $runthis <> "" Then
If FileExists($launchDir & "\" & $runthis) Then
Beep(1000, 50)
Beep(2000, 50)
_ShellExecute($runthis, "", $launchDir)
EndIf
EndIf
GUIDelete($controlGui)
;fade out png background
For $i = 255 To 0 Step -10
SetBitmap($GUI, $hImage, $i)
Next
; Release resources
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
Func GoAutoComplete()
_GUICtrlComboBox_AutoComplete($Combo)
EndFunc ;==>GoAutoComplete
; ====================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc ;==>WM_NCHITTEST
; ====================================================================================================
; SetBitMap
; ====================================================================================================
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
; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself.
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
$aRet = DllCall("shell32.dll", "long", "ShellExecute", _
"hwnd", 0, _
"string", "", _
"string", $sCmd, _
"string", $sArg, _
"string", $sFolder, _
"int", $rState)
If @error Then Return 0
$RetVal = $aRet[0]
If $RetVal > 32 Then
Return 1
Else
Return 0
EndIf
EndFunc ;==>_ShellExecute