Jump to content

Trying to make a loading screen


Recommended Posts

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:

#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 by nullschritt
Link to comment
Share on other sites

  • Moderators

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

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

Try this:

#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   ;==>Anim3
I see the animation. Here are some more realtime calculated animations -> http://www.autoitscript.com/forum/index.php?showtopic=150545 Edited 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...