nullschritt Posted March 17, 2015 Share Posted March 17, 2015 (edited) Hello all, I'm trying to make a loading screen using gdi and a udf made by UEZ, the script should open a window and display the specified gif (download here: '> ) But instead it throws an error when accessing the array of frames, so I'm missing something here. script: expandcollapse popup#include <gdiplus.au3> #include <_GDIPlus_GIFAnim.au3> #include <WindowsConstants.au3> #include <memory.au3> _loadinggui() while 1 sleep(10) WEnd Func _loadinggui() Global Const $hGIFAnim3 = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Images\loading.gif") Global Const $iW3 = _GDIPlus_ImageGetWidth($hGIFAnim3), $iH3 = _GDIPlus_ImageGetHeight($hGIFAnim3) Global $loading = GUICreate("Secure Instant Messenger (SIM) - Login", $iW3, $iH3), $iPosX = 10, $iPosY = 285 GUISetBkColor(0x000000, $loading) Global $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($loading) Global $iAnim3CurrentFrame = 0 Global Const $iAnim3DimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFAnim3) Global Const $tAnim3GUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFAnim3, $iAnim3DimCount) Global Const $iAnim3FrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFAnim3, $tAnim3GUID) Global Const $aAnim3FrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFAnim3, $iAnim3FrameCount) GUIRegisterMsg($WM_TIMER, "PlayAnimPreview2") DllCall("user32.dll", "int", "SetTimer", "hwnd", $loading, "int", 0, "int", 100, "int", 0) GUISetState() EndFunc func PlayAnimPreview2() Local $hBmp2 = _GDIPlus_BitmapCreateFromScan0($iW3, $iH3) Local $hGfx2 = _GDIPlus_ImageGetGraphicsContext($hBmp2) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hBmp2, 0, 0, $iW3, $iH3) _GDIPlus_GraphicsDispose($hGfx2) _GDIPlus_BitmapDispose($hBmp2) Anim3($hGfx2) EndFunc Func Anim3(ByRef $hGfx) Local $iDelayAnim3 = $aAnim3FrameDelays[$iAnim3CurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFAnim3, $tAnim3GUID, $iAnim3CurrentFrame) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFAnim3, 20, 5, $iW3, $iH3) If TimerDiff($iTimerCurrentFrame) > $iDelayAnim3 Then $iAnim3CurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iAnim3CurrentFrame > UBound($aAnim3FrameDelays) - 1 Then $iAnim3CurrentFrame = 0 EndFunc ;==>Anim3 I feel like I'm missing something incredibly simple... Edited March 17, 2015 by nullschritt Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 17, 2015 Moderators Share Posted March 17, 2015 That is great that you're trying to make that, good for you! I do not, however, see a question.. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
nullschritt Posted March 17, 2015 Author Share Posted March 17, 2015 That is great that you're trying to make that, good for you! I do not, however, see a question.. Sorry, I wasn't thinking I edited it and added my problem. Link to comment Share on other sites More sharing options...
UEZ Posted March 17, 2015 Share Posted March 17, 2015 Yes, you forgot to start GDI+ _GDIPlus_Startup() When done don't forget the _GDIPlus_Shutdown() 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 17, 2015 Author Share Posted March 17, 2015 Yes, you forgot to start GDI+ _GDIPlus_Startup() When done don't forget the _GDIPlus_Shutdown() Okay I added _GDIPlus_Startup() before any gdi functions and I'm still getting the same error >.< Link to comment Share on other sites More sharing options...
nullschritt Posted March 17, 2015 Author Share Posted March 17, 2015 Okay right, nevermind, I was missing the gif file from the right location. Now the gui comes up but the animation doesnt play, in fact I dont see even the first frame of the image. Link to comment Share on other sites More sharing options...
UEZ Posted March 17, 2015 Share Posted March 17, 2015 (edited) Try this:expandcollapse popup#include <gdiplus.au3> #include <_GDIPlus_GIFAnim.au3> #include <WindowsConstants.au3> #include <memory.au3> _loadinggui() Func _loadinggui() _GDIPlus_Startup() Global Const $hGIFAnim3 = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\Images\loading.gif") Global Const $iW3 = _GDIPlus_ImageGetWidth($hGIFAnim3), $iH3 = _GDIPlus_ImageGetHeight($hGIFAnim3) Global $loading = GUICreate("Secure Instant Messenger (SIM) - Login", $iW3, $iH3), $iPosX = 10, $iPosY = 285 GUISetBkColor(0x000000, $loading) Global $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($loading) Global $iAnim3CurrentFrame = 0 Global Const $iAnim3DimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hGIFAnim3) Global Const $tAnim3GUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hGIFAnim3, $iAnim3DimCount) Global Const $iAnim3FrameCount = _GDIPlus_GIFAnimGetFrameCount($hGIFAnim3, $tAnim3GUID) Global Const $aAnim3FrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hGIFAnim3, $iAnim3FrameCount) GUIRegisterMsg($WM_TIMER, "PlayAnimPreview2") DllCall("user32.dll", "int", "SetTimer", "hwnd", $loading, "int", 0, "int", 100, "int", 0) GUISetState() While 1 If GUIGetMsg() = -3 Then _GDIPlus_GraphicsDispose($hGraphic2) _GDIPlus_BitmapDispose($hGIFAnim3) _GDIPlus_Shutdown() GUIDelete() Return EndIf WEnd EndFunc ;==>_loadinggui Func PlayAnimPreview2() Local $hBmp2 = _GDIPlus_BitmapCreateFromScan0($iW3, $iH3) Local $hGfx2 = _GDIPlus_ImageGetGraphicsContext($hBmp2) Anim3($hGfx2) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hBmp2, 0, 0, $iW3, $iH3) _GDIPlus_GraphicsDispose($hGfx2) _GDIPlus_BitmapDispose($hBmp2) EndFunc ;==>PlayAnimPreview2 Func Anim3(ByRef $hGfx) Local $iDelayAnim3 = $aAnim3FrameDelays[$iAnim3CurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _GDIPlus_GIFAnimSelectActiveFrame($hGIFAnim3, $tAnim3GUID, $iAnim3CurrentFrame) _GDIPlus_GraphicsDrawImageRect($hGfx, $hGIFAnim3, 20, 5, $iW3, $iH3) If TimerDiff($iTimerCurrentFrame) > $iDelayAnim3 Then $iAnim3CurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iAnim3CurrentFrame > UBound($aAnim3FrameDelays) - 1 Then $iAnim3CurrentFrame = 0 EndFunc ;==>Anim3I see the animation. Here are some more realtime calculated animations -> http://www.autoitscript.com/forum/index.php?showtopic=150545 Edited March 17, 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...
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