nullschritt Posted March 15, 2015 Share Posted March 15, 2015 Hello friends, I'mw orking on a loginf orm for one of my projects, and I'm having a problem. I want to overlay some pngs on top of an animated gif. I'm tryign to do this by making a child window then using gdi to render the png to the child window, but the png wont render on the child window. The files including the script are at http://prodynamics.tk/login.zip sorry it was too big to upload to the forum ( : Link to comment Share on other sites More sharing options...
nullschritt Posted March 15, 2015 Author Share Posted March 15, 2015 An alternative attempt. This one correctly creates the png, but on its own independent gui. When I try to get this gui as a child to my main gui, the function fails does gdi+ not like to render of child windows? expandcollapse popup#include <File.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include "_GUIResourcePic.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <GDIPlus.au3> Global $sFile, $label1 ; Make GUI Global $hGui = GUICreate("Secure Instant Messenger - Login - BETA", 720, 405) Global $iCtrlID = GUICtrlCreatePic("", 0, 0, 720, 405, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetState(-1, $GUI_DISABLE) _GUICtrlPic_SetImage($iCtrlID, @ScriptDir&"\background.gif", True) GUISetState() ;~ Global $Child = GUICreate('Input', 335, 134, -1, -1, $WS_POPUP, $WS_EX_TOPMOST, $hGui) ;~ _GDIPlus_StartUp() ;~ Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&"\loginform.png") DisplayImage(@ScriptDir&"\loginform.png", 335, 134) ;~ Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Child) ;~ _GDIPlus_GraphicsDrawImage($hGraphic, $hImage,-10, 0) GUISetState() Global $iPlay = 1 ;~ $Label1 = GUICtrlCreateLabel("Version 0.1.0.0", 152, 64, 139, 19) ;~ GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; Loop till end While 1 Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd Func DisplayImage($sFile, $iPosX = -1, $iPosY = -1, $iAlpha = 0xFF, $bTopmost = True) Local Const $hBmp_Background = _GDIPlus_BitmapCreateFromFile($sFile) ;load the image If @error Then Return SetError(1, 0, 0) ;image cannot be loaded Local Const $iW = _GDIPlus_ImageGetWidth($hBmp_Background), $iH = _GDIPlus_ImageGetHeight($hBmp_Background) ;get the dimension of the background image Local Const $hGUI = GUICreate("", $iW, $iH, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST * $bTopmost, $WS_EX_TOOLWINDOW)) ;create GUI with appropriate styles and extented style (borderless transparent GUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH, Default, $GUI_WS_EX_PARENTDRAG) ;create a hidden label for GUI dragging GUISetState(@SW_SHOW, $hGUI) ;show GUI Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;define an empty bitmap where all the gfx stuff will copied to Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the context to the bitmap to be able to copy / draw to the bitmap _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp_Background, 0, 0, $iW, $iH) ;draw background image to the empty bitmap ;display GDI+ with transparency on desktop Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ image to GDI to display it on the screen using GDI functions Local Const $hScrDC = _WinAPI_GetDC($hGUI) ;get the device context (dc) handle of the GUI Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) ;create a compatible dc handle Local Const $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) ;selects the GDI bitmap object into the specified device context Local Const $tSize = DllStructCreate($tagSIZE) ;create a $tagSIZE struct (x = width, y = height) DllStructSetData($tSize, "X", $iW) ;set data for width DllStructSetData($tSize, "Y", $iH) ;set data for height Local $tSource = DllStructCreate($tagPOINT) ;create a $tagPOINT struct (x = x position, y = y position) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) ;create $tagBLENDFUNCTION struct -> see help file for more info DllStructSetData($tBlend, "Alpha", $iAlpha) ;set the alpha channel of the GUI -> 255 = opaque, 0 = transparent DllStructSetData($tBlend, "Format", 1) ;set the format to 1 -> bitmap has alpha channels DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hGUI, "handle", $hScrDC, "ptr", 0, "struct*", $tSize, "handle", $hMemDC, "struct*", $tSource, "dword", 0, "struct*", $tBlend, "dword", $ULW_ALPHA) ;display bitmap on screen ;release resources otherwise memory will filled up (memory leak) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) Local $aResource[7] = [$hGUI, $hScrDC, $hHBitmap, $hMemDC, $tBlend, $tSize, $tSource] ;return the handle to release it later Return $aResource EndFunc ;==>DisplayImage ; This function releases the resources of a specific image and closes it Func ReleaseResources(ByRef $aResource) If Not IsArray($aResource) Then Return SetError(1, 0, 0) If UBound($aResource) <> 7 Then Return SetError(2, 0, 0) _WinAPI_ReleaseDC($aResource[0], $aResource[1]) _WinAPI_DeleteDC($aResource[3]) _WinAPI_DeleteObject($aResource[2]) GUIDelete($aResource[0]) EndFunc ;==>ReleaseResources ; To fade in an image leave $bIn at default (True); to fade out specify False. ; There are also options to set the ending transparency level (0 transparent, 255 opaque), speed and delay. ; If you change the speed or delay be sure to specify $bIn and $iTrans, otherwise you'll wonder why the fade-in or out isn't what you hoped for. ; The default values are specified in the function below. Func _Fader($res1, $bIn = True, $iTrans = 255, $speed = 3, $delay = 10 ) If Not IsArray($res1) Then Return SetError(1, 0, 0) If UBound($res1) <> 7 Then Return SetError(2, 0, 0) Switch $bIn Case True For $a = 0 To $iTrans Step $speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next Case Else For $a = $iTrans To 0 Step -$speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next EndSwitch EndFunc ;==>_FadeIn Link to comment Share on other sites More sharing options...
nullschritt Posted March 15, 2015 Author Share Posted March 15, 2015 (edited) Edit: Nope, I was just being an idiot, I didn't change anything. Still having a problem constraining the child gui to within the main. Edited March 15, 2015 by nullschritt Link to comment Share on other sites More sharing options...
UEZ Posted March 15, 2015 Share Posted March 15, 2015 (edited) This this (without any child gui): expandcollapse popup#AutoIt3Wrapper_UseX64=n #include <WindowsConstants.au3> #include "_GDIPlus_GIFAnim.au3" _GDIPlus_Startup() Global $binGIFAnim = Binary(FileRead(@ScriptDir & "\background.gif" )) Global $hGIFImage = _GDIPlus_BitmapCreateFromMemory($binGIFAnim) Global Const $iW = _GDIPlus_ImageGetWidth($hGIFImage), $iH = _GDIPlus_ImageGetHeight($hGIFImage) Global Const $hGUI = GUICreate("GIF Anim UDF Example", $iW, $iH) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUISetState() Global $iCurrentFrame = 0 Global Const $iAnimDimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFImage) Global Const $tGUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFImage, $iAnimDimCount) Global Const $iAnimFrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFImage, $tGUID) Global Const $aFrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFImage, $iAnimFrameCount) Global Const $hBitmap_Login = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\loginform.png"), $iW_Login = _GDIPlus_ImageGetWidth($hBitmap_Login), $iH_Login = _GDIPlus_ImageGetHeight($hBitmap_Login) GUIRegisterMsg($WM_TIMER, "PlayAnimPreview") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 50, "int", 0) Do If GUIGetMsg() = -3 Then ;$GUI_EVENT_CLOSE = -3 GUIRegisterMsg($WM_TIMER, "") _GDIPlus_BitmapDispose($hGIFImage) _GDIPlus_BitmapDispose($hBitmap_Login) _GDIPlus_Shutdown() GUIDelete() Exit EndIf Until False Func PlayAnimPreview() Local $iDelay = $aFrameDelays[$iCurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFImage, $tGUID, $iCurrentFrame) Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) ;_GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFImage, 0, 0, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Login, $iW_Login / 2, ($iH - $iH_Login) / 2, $iW_Login, $iH_Login) Local $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172 , 0, $hBitmap_GDI)) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 _WinAPI_DeleteObject($hBitmap_GDI) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBmp) If TimerDiff($iTimerCurrentFrame) > $iDelay Then $iCurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iCurrentFrame > UBound($aFrameDelays) - 1 Then $iCurrentFrame = 0 EndFunc ;==>PlayAnimPreview You need _GDIPlus_GIFAnim.au3 which can be found here: Edited March 15, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nullschritt Posted March 16, 2015 Author Share Posted March 16, 2015 (edited) @UEZ Where do I get _GDIPlus_GIFAnim.au3? Edit: nvm I found it. Edited March 16, 2015 by nullschritt Link to comment Share on other sites More sharing options...
nullschritt Posted March 16, 2015 Author Share Posted March 16, 2015 (edited) Works perfect, thanks. Edit: But how do I define the position of the png? right now it's just in the middle of the gui. I dont even see where it's been added to the gui, just where it's been loaded from the file. I don't understand how you're placing it on the gui, care to elaborate? Edit: Nevermind, I found all my answers in the function. Edited March 16, 2015 by nullschritt Link to comment Share on other sites More sharing options...
nullschritt Posted March 16, 2015 Author Share Posted March 16, 2015 (edited) @UEZ, I figured out how to add a second gift over the first, but it flickers, is this unavoidable or it just how I have it coded?expandcollapse popup#AutoIt3Wrapper_UseX64=n #include <WindowsConstants.au3> #include <GUIConstants.au3> #include "_GDIPlus_GIFAnim.au3" _GDIPlus_Startup() if $cmdlineraw="/childmovewith" Then sleep(1000) while 1 $mainpos = WinGetPos("Secure Instant Messenger (SIM) - Login") if @error Then Exit if WinExists("Secure Instant Messenger (SIM) - Login") == 1 Then WinMove('*SIM*USER*', "", $mainpos[0]+40,$mainpos[1]+330) WinMove('*SIM*PASS*', "",$mainpos[0]+40,$mainpos[1]+370) sleep(5) EndIf WEnd Exit EndIf if @Compiled Then ShellExecute(@ScriptFullPath, "/childmovewith") EndIf Global $binGIFAnim = Binary(FileRead(@ScriptDir & "\background.gif" )) Global $hGIFImage = _GDIPlus_BitmapCreateFromMemory($binGIFAnim) Global $binGIFAnim2 = Binary(FileRead(@ScriptDir & "\8-cell.gif" )) Global $hGIFImage2 = _GDIPlus_BitmapCreateFromMemory($binGIFAnim2) Global Const $iW = _GDIPlus_ImageGetWidth($hGIFImage), $iH = _GDIPlus_ImageGetHeight($hGIFImage) Global Const $iW2 = _GDIPlus_ImageGetWidth($hGIFImage2), $iH2 = _GDIPlus_ImageGetHeight($hGIFImage2) Global Const $hGUI = GUICreate("Secure Instant Messenger (SIM) - Login", $iW, $iH) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) Global Const $iPic2 = GUICtrlCreatePic("", 40, 0, $iW, $iH) GUISetState() $mainpos = WinGetPos("Secure Instant Messenger (SIM) - Login") $login= GUICreate('*SIM*USER*', 240, 18, $mainpos[0]+40,$mainpos[1]+330, $WS_POPUP, $WS_EX_TRANSPARENT, $hGUI) $Input = GUICtrlCreateInput('Username', -1, -1, 241, 20) GUICtrlSetBkColor(-1, 0x1C1E21) GUICtrlSetColor(-1, 0xFFFFFF) GUISetState() $login= GUICreate('*SIM*PASS*', 240, 18, $mainpos[0]+40,$mainpos[1]+370, $WS_POPUP, $WS_EX_TRANSPARENT, $hGUI) $Input = GUICtrlCreateInput('password', -1, -1, 241, 20, $ES_PASSWORD) GUICtrlSetBkColor(-1, 0x1C1E21) GUICtrlSetColor(-1, 0xFFFFFF) GUISetState() WinActivate("Secure Instant Messenger (SIM) - Login") Global $iCurrentFrame = 0 Global $iCurrentFrame2 = 0 Global Const $iAnimDimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFImage) Global Const $tGUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFImage, $iAnimDimCount) Global Const $iAnimFrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFImage, $tGUID) Global Const $aFrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFImage, $iAnimFrameCount) Global Const $iAnimDimCount2 = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFImage2) Global Const $tGUID2 = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFImage2, $iAnimDimCount2) Global Const $iAnimFrameCount2 = _GDIPlus_GIFAnimGetFrameCount($hGIFImage2, $tGUID2) Global Const $aFrameDelays2 = _GDIPlus_GIFAnimGetFrameDelays($hGIFImage2, $iAnimFrameCount2) Global Const $hBitmap_Login = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\loginform.png"), $iW_Login = _GDIPlus_ImageGetWidth($hBitmap_Login), $iH_Login = _GDIPlus_ImageGetHeight($hBitmap_Login) GUIRegisterMsg($WM_TIMER, "PlayAnimPreview") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 50, "int", 0) Do If GUIGetMsg() = -3 Then ;$GUI_EVENT_CLOSE = -3 GUIRegisterMsg($WM_TIMER, "") _GDIPlus_BitmapDispose($hGIFImage) _GDIPlus_BitmapDispose($hBitmap_Login) _GDIPlus_Shutdown() GUIDelete() Exit EndIf Until False Func PlayAnimPreview() if WinActive("Secure Instant Messenger (SIM) - Login") Then Local $iDelay = $aFrameDelays[$iCurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFImage, $tGUID, $iCurrentFrame) Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) ;_GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFImage, 0, 0, $iW, $iH) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Login, 10, 280, $iW_Login, $iH_Login) Local $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172 , 0, $hBitmap_GDI)) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 _WinAPI_DeleteObject($hBitmap_GDI) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBmp) If TimerDiff($iTimerCurrentFrame) > $iDelay Then $iCurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iCurrentFrame > UBound($aFrameDelays) - 1 Then $iCurrentFrame = 0 EndIf PlayAnimPreview2() EndFunc ;==>PlayAnimPreview Func PlayAnimPreview2() if WinActive("Secure Instant Messenger (SIM) - Login") Then Local $iDelay = $aFrameDelays2[$iCurrentFrame2] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFImage2, $tGUID2, $iCurrentFrame2) Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW2, $iH2) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) ;_GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFImage2, 0, 0, $iW2, $iH2) Local $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic2, 0x0172 , 0, $hBitmap_GDI)) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 _WinAPI_DeleteObject($hBitmap_GDI) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBmp) If TimerDiff($iTimerCurrentFrame) > $iDelay Then $iCurrentFrame2 += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iCurrentFrame2 > UBound($aFrameDelays2) - 1 Then $iCurrentFrame2 = 0 EndIf EndFunc ;==>PlayAnimPreview Edited March 16, 2015 by nullschritt Link to comment Share on other sites More sharing options...
UEZ Posted March 16, 2015 Share Posted March 16, 2015 (edited) What about this?expandcollapse popup#AutoIt3Wrapper_UseX64=n #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "_GDIPlus_GIFAnim.au3" _GDIPlus_Startup() Global Const $hGIFAnim1 = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\background.gif") Global Const $hGIFAnim2 = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\8-cell.gif") Global Const $hBitmap_Login = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\loginform.png"), $iW_Login = _GDIPlus_ImageGetWidth($hBitmap_Login), $iH_Login = _GDIPlus_ImageGetHeight($hBitmap_Login) Global $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate() Global $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, -0.15) Global $pColorMatrix = DllStructGetPtr($tColorMatrix) _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, $pColorMatrix) Global Const $iW1 = _GDIPlus_ImageGetWidth($hGIFAnim1), $iH1 = _GDIPlus_ImageGetHeight($hGIFAnim1) Global Const $iW2 = _GDIPlus_ImageGetWidth($hGIFAnim2), $iH2 = _GDIPlus_ImageGetHeight($hGIFAnim2) Global Const $hGUI = GUICreate("GIF Anim UDF Example", $iW1, $iH1), $iPosX = 195, $iPosY = 150 GUISetBkColor(0x1C1E21, $hGUI) Global Const $iInputUsr = GUICtrlCreateInput("", $iPosX, $iPosY, 200, 30) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetColor(-1, 0x1C1E21) GUICtrlSetFont(-1, 14) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, 0, "<username>") Global Const $iInputPwd = GUICtrlCreateInput("", $iPosX, $iPosY + 50, 200, 30, $ES_PASSWORD) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetColor(-1, 0x1C1E21) GUICtrlSetFont(-1, 14) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, 0, "<password>") Global Const $iBtnEnter = GUICtrlCreateLabel(ChrW(0x25BA), $iPosX + 262, $iPosY + 22, 30, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 20) GUICtrlSetBkColor(-1, 0x1C1E21) GUICtrlSetColor(-1, 0x42474C) ControlFocus($hGUI, "", $iBtnEnter) GUISetState() Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, $iW1, $iH1) Global $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD) Global $aRect Do $aRect = ControlGetPos($hChild, "", 0) _GDIPlus_RegionCombineRect($hRegion, $aRect[0], $aRect[1], $aRect[2], $aRect[3], 3) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) Until Not $hChild _GDIPlus_GraphicsSetClipRegion($hGraphic, $hRegion) _GDIPlus_RegionDispose($hRegion) Global $iAnim1CurrentFrame = 0, $iAnim2CurrentFrame = 0 Global Const $iAnim1DimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFAnim1) Global Const $tAnim1GUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFAnim1, $iAnim1DimCount) Global Const $iAnim1FrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFAnim1, $tAnim1GUID) Global Const $aAnim1FrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFAnim1, $iAnim1FrameCount) Global Const $iAnim2DimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFAnim2) Global Const $tAnim2GUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFAnim2, $iAnim2DimCount) Global Const $iAnim2FrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFAnim2, $tAnim2GUID) Global Const $aAnim2FrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFAnim2, $iAnim2FrameCount) GUIRegisterMsg($WM_TIMER, "PlayAnimPreview") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 50, "int", 0) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") _GDIPlus_ImageAttributesDispose($hAttribute_Alpha) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hGIFAnim1) _GDIPlus_BitmapDispose($hGIFAnim2) _GDIPlus_BitmapDispose($hBitmap_Login) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtnEnter MsgBox(0, "Test", ":-)") EndSwitch Until False Func PlayAnimPreview() Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW1, $iH1) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) Anim1($hGfx) Anim2($hGfx) ;~ _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Login, $iW_Login / 2, ($iH1 - $iH_Login) / 2, $iW_Login, $iH_Login) _GDIPlus_GraphicsDrawImageRectRect($hGfx, $hBitmap_Login, 0, 0, $iW_Login, $iH_Login, $iW_Login / 2, ($iH1 - $iH_Login) / 2, $iW_Login, $iH_Login, $hAttribute_Alpha) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBmp, 0, 0, $iW1, $iH1) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBmp) EndFunc ;==>PlayAnimPreview Func Anim1(ByRef $hGfx) Local $iDelayAnim1 = $aAnim1FrameDelays[$iAnim1CurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFAnim1, $tAnim1GUID, $iAnim1CurrentFrame) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFAnim1, 0, 0, $iW1, $iH1) If TimerDiff($iTimerCurrentFrame) > $iDelayAnim1 Then $iAnim1CurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iAnim1CurrentFrame > UBound($aAnim1FrameDelays) - 1 Then $iAnim1CurrentFrame = 0 EndFunc ;==>Anim1 Func Anim2(ByRef $hGfx) Local $iDelayAnim2 = $aAnim2FrameDelays[$iAnim2CurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFAnim2, $tAnim2GUID, $iAnim2CurrentFrame) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFAnim2, 0, $iW2 / 4, $iW2, $iH2) If TimerDiff($iTimerCurrentFrame) > $iDelayAnim2 Then $iAnim2CurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iAnim2CurrentFrame > UBound($aAnim2FrameDelays) - 1 Then $iAnim2CurrentFrame = 0 EndFunc ;==>Anim2 Edited March 16, 2015 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nullschritt Posted March 16, 2015 Author Share Posted March 16, 2015 (edited) What about this? expandcollapse popup#AutoIt3Wrapper_UseX64=n #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include "_GDIPlus_GIFAnim.au3" _GDIPlus_Startup() Global Const $hGIFAnim1 = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\background.gif") Global Const $hGIFAnim2 = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\8-cell.gif") Global Const $hBitmap_Login = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\loginform.png"), $iW_Login = _GDIPlus_ImageGetWidth($hBitmap_Login), $iH_Login = _GDIPlus_ImageGetHeight($hBitmap_Login) Global $hAttribute_Alpha = _GDIPlus_ImageAttributesCreate() Global $tColorMatrix = _GDIPlus_ColorMatrixCreateTranslate(0, 0, 0, -0.15) Global $pColorMatrix = DllStructGetPtr($tColorMatrix) _GDIPlus_ImageAttributesSetColorMatrix($hAttribute_Alpha, 0, True, $pColorMatrix) Global Const $iW1 = _GDIPlus_ImageGetWidth($hGIFAnim1), $iH1 = _GDIPlus_ImageGetHeight($hGIFAnim1) Global Const $iW2 = _GDIPlus_ImageGetWidth($hGIFAnim2), $iH2 = _GDIPlus_ImageGetHeight($hGIFAnim2) Global Const $hGUI = GUICreate("GIF Anim UDF Example", $iW1, $iH1), $iPosX = 195, $iPosY = 150 GUISetBkColor(0x1C1E21, $hGUI) Global Const $iInputUsr = GUICtrlCreateInput("", $iPosX, $iPosY, 200, 30) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetColor(-1, 0x1C1E21) GUICtrlSetFont(-1, 14) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, 0, "<username>") Global Const $iInputPwd = GUICtrlCreateInput("", $iPosX, $iPosY + 50, 200, 30, $ES_PASSWORD) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetColor(-1, 0x1C1E21) GUICtrlSetFont(-1, 14) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, 0, "<password>") Global Const $iBtnEnter = GUICtrlCreateLabel(ChrW(0x25BA), $iPosX + 262, $iPosY + 22, 30, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 20) GUICtrlSetBkColor(-1, 0x1C1E21) GUICtrlSetColor(-1, 0x42474C) ControlFocus($hGUI, "", $iBtnEnter) GUISetState() Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, $iW1, $iH1) Global $hChild = _WinAPI_GetWindow($hGUI, $GW_CHILD) Global $aRect Do $aRect = ControlGetPos($hChild, "", 0) _GDIPlus_RegionCombineRect($hRegion, $aRect[0], $aRect[1], $aRect[2], $aRect[3], 3) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) Until Not $hChild _GDIPlus_GraphicsSetClipRegion($hGraphic, $hRegion) _GDIPlus_RegionDispose($hRegion) Global $iAnim1CurrentFrame = 0, $iAnim2CurrentFrame = 0 Global Const $iAnim1DimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFAnim1) Global Const $tAnim1GUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFAnim1, $iAnim1DimCount) Global Const $iAnim1FrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFAnim1, $tAnim1GUID) Global Const $aAnim1FrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFAnim1, $iAnim1FrameCount) Global Const $iAnim2DimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFAnim2) Global Const $tAnim2GUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFAnim2, $iAnim2DimCount) Global Const $iAnim2FrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFAnim2, $tAnim2GUID) Global Const $aAnim2FrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFAnim2, $iAnim2FrameCount) GUIRegisterMsg($WM_TIMER, "PlayAnimPreview") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", 50, "int", 0) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") _GDIPlus_ImageAttributesDispose($hAttribute_Alpha) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hGIFAnim1) _GDIPlus_BitmapDispose($hGIFAnim2) _GDIPlus_BitmapDispose($hBitmap_Login) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtnEnter MsgBox(0, "Test", ":-)") EndSwitch Until False Func PlayAnimPreview() Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW1, $iH1) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) Anim1($hGfx) Anim2($hGfx) ;~ _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Login, $iW_Login / 2, ($iH1 - $iH_Login) / 2, $iW_Login, $iH_Login) _GDIPlus_GraphicsDrawImageRectRect($hGfx, $hBitmap_Login, 0, 0, $iW_Login, $iH_Login, $iW_Login / 2, ($iH1 - $iH_Login) / 2, $iW_Login, $iH_Login, $hAttribute_Alpha) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBmp, 0, 0, $iW1, $iH1) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBmp) EndFunc ;==>PlayAnimPreview Func Anim1(ByRef $hGfx) Local $iDelayAnim1 = $aAnim1FrameDelays[$iAnim1CurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFAnim1, $tAnim1GUID, $iAnim1CurrentFrame) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFAnim1, 0, 0, $iW1, $iH1) If TimerDiff($iTimerCurrentFrame) > $iDelayAnim1 Then $iAnim1CurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iAnim1CurrentFrame > UBound($aAnim1FrameDelays) - 1 Then $iAnim1CurrentFrame = 0 EndFunc ;==>Anim1 Func Anim2(ByRef $hGfx) Local $iDelayAnim2 = $aAnim2FrameDelays[$iAnim2CurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFAnim2, $tAnim2GUID, $iAnim2CurrentFrame) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFAnim2, 0, $iW2 / 4, $iW2, $iH2) If TimerDiff($iTimerCurrentFrame) > $iDelayAnim2 Then $iAnim2CurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iAnim2CurrentFrame > UBound($aAnim2FrameDelays) - 1 Then $iAnim2CurrentFrame = 0 EndFunc ;==>Anim2 Fantastic! With a few modifications I've got exactly what I want. I'll be sure to mention your name in the contributors section of my project. (: Edit: Also it might be a little irrelevant to my project, but I'm curious. How did you get the the username and password boxes to always default back to their default texts? I only see those values set once, or does the way you've set them, make them always return to default? Edited March 16, 2015 by nullschritt Link to comment Share on other sites More sharing options...
nullschritt Posted March 16, 2015 Author Share Posted March 16, 2015 Okay, so, I hate to be a nag but I've been playing with this for a while, I'm trying to get an invisible control over top of an image so that I can detect when the image is clicked on. see below: Global Const $iBtnsignup = GUICtrlCreateLabel("register", 560, 340, 156, 51, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 20) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) But instead of creating a see through label it makes the background grey? I'm assuming because the transparent flag actually just makes the background color of the gui, though I may be wrong. How might I go about detecting the clicking of images rendered by GDI? And of course, thanks so much for all your help, you've been extremely resourceful with this topic, I am an absolute noob to GDI+ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now