Sign in to follow this  
Followers 0
DarkAngel

Need some help with a loader screen

15 posts in this topic

hello .. i am trying to make a loader screen . I tried using a window and making it transparent and then tried putting the png over it, and then a IE com as a layered window over it to show the gif of the loader. However , the problem is that i cant implement the transparent png over the gui window . All i want to be displayed on the screen is a with a IE object on top of it. kind of like a splash screen image. Can someone give me an example how to go on about with this one ? :huh2: thanks in advance .

Share this post


Link to post
Share on other sites



You want a gif in a IE window ontop of a png ?


[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

err yes ... a png with a transparent background and a ie control on top for a loader gif. it should look something like a splash screen .

Share this post


Link to post
Share on other sites

you mean like this?

;Sample 1
ToolTip('Downloading background image, please wait',0,0)
if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png")
if not FileExists('grey.gif') Then InetGet("http://tinyurl.com/6x7hh96", "grey.gif")
ToolTip('')

$MY_GUIIMAGE = 'bak2.png'
$MY_GUIIMAGE2 = 'grey.gif'

Opt("GUIOnEventMode", 1); Change to OnEvent mode
HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray

#include <GDIPlus.au3>; this is where the magic happens, people
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Opt("MustDeclareVars", 0)

        Global Const $AC_SRC_ALPHA = 1
        ;~ Global Const $ULW_ALPHA         = 2
        Global $old_string = "", $runthis = ""

        ; Load PNG file as GDI bitmap
        _GDIPlus_Startup()
        $hImage = _GDIPlus_ImageLoadFromFile($MY_GUIIMAGE) ; This is UR GUI IMAGE

        ; Extract image width and height from PNG
        $width = _GDIPlus_ImageGetWidth($hImage)
        $height = _GDIPlus_ImageGetHeight($hImage)

        ; Create layered window
        $GUI = GUICreate("The Main Gui pic", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
        SetBitmap($GUI, $hImage, 0)
        ; Register notification messages
        GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
        GUISetState(@SW_SHOW)
        ;fade in png background
        For $i = 0 To 255 Step 10
            SetBitmap($GUI, $hImage, $i)
            Sleep(50)
        Next

        ; create child MDI gui window to hold controls
        ; this part could use some work - there is some flicker sometimes...
        Global $GUI_NAME = GUICreate('childgui', $width, $height, 4, 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($MY_GUIIMAGE2, 0, 0, $width, $height)
        GUICtrlSetState(-1, $GUI_DISABLE)

        $Label_Create = GUICtrlCreateLabel('Press esc to exit', 100, 106, 86, 17)
        GUICtrlSetColor(-1, 0xffffff)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

        GUISetState(@SW_SHOW)


; ====================================================================================================
; 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
While 1
    Sleep(100); Idle around
WEnd
Func _exit()
    GUIDelete($GUI_NAME)
    ;fade out png background
    For $i = 255 To 0 Step -10
        SetBitmap($GUI, $hImage, $i)
    Next

    ; Release resources
    _WinAPI_DeleteObject($hImage)
    _GDIPlus_Shutdown()
    Sleep(700)
    FileDelete('bak2.png')
    FileDelete('grey.gif')
  Exit
EndFunc

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

whoa ;) that was amazing ... far better than anything i had planned ... thanks a lot ... err help me with one more thing . i dun understand the use of the grey.gif though :huh2: . bdw .. if i need to use a loader gif on top of the png do i use a IE control ?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

whoa ;) that was amazing ... far better than anything i had planned ... thanks a lot ... err help me with one more thing . i dun understand the use of the grey.gif though :huh2: . bdw .. if i need to use a loader gif on top of the png do i use a IE control ?

You do not need to touch grey.gif, it must always be included, all you need to do is, to change the bak2.png. Just replace it with any other image & it will work. if you want to get this cool gui shape it must be npg image with transparent background.

Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

yeah that much i understood about the png thingy .... but

You do not need to touch grey.gif, it must always be included

err can u please explain why any other xyz gif would serve the same purpose ???

bdw ... i added this to the code of yours and i get a perfect solution to my problem . Thanks a lot . Do make an effort to explain about the grey.gif :huh2:

$Label_Create = GUICtrlCreateLabel('Loading', 120, 106, 86, 17)

GUICtrlSetColor(-1, 0xffffff)

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

Global $oIE = _IECreateEmbedded()

Global $history = GUICtrlCreateObj($oIE, $width/3+20,104, 160, 17)

;_IEHeadInsertEventScript($oIE, $history, "oncontextmenu", "return false")

_IENavigate($oIE, "about:blank")

$oIE.document.write('<body onselectstart="return false" oncontextmenu="return false" onclick="return false" ondragstart="return false" ondragover="return false">')

$oIE.document.body.style.border = "0px"

$oIE.document.body.topmargin = 0

$oIE.document.body.leftmargin = 0

$oIE.document.body.scroll = "no"

$oIE.document.body.bgcolor = 0x010101

$oIE.document.body.style.backgroundColor = 0x010101

$oIE.document.body.style.borderWidth = 0

$oIE.document.body.style.backgroundImage = "url(C:\Desktop3\loader.gif)";

$oIE.document.body.style.backgroundPosition='center center';

$oIE.document.body.style.backgroundRepeat='no-repeat';

Share this post


Link to post
Share on other sites

yeah that much i understood about the png thingy .... but

Do make an effort to explain about the grey.gif :huh2:

Forget the gray gif. Try this no gray gif needed:

#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

ToolTip('Downloading background image, please wait',0,0)
if not FileExists('bak2.png') Then InetGet("http://tinyurl.com/6jbew48", "bak2.png")
ToolTip('')

Opt("GUIOnEventMode", 1); Change to OnEvent mode
HotKeySet('{esc}','_exit'); ALT+1 Show / Hode Gui to tray

_GDIPlus_Startup()
$GUI = _GUICreate_Alpha("Look at the shiny", "bak2.png", 100, 162)
$myGuiHandle = WinGetHandle("Look at the shiny")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($myGuiHandle)
GUISetState()

$butGui = GUICreate("ControlGUI", 400, 400, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $myGuiHandle)
GUISetBkColor(0xABCDEF)

$label          = GUICtrlCreateLabel('Checkbox', 118, 130, 122, 22)
$btnCheckBox   = GUICtrlCreateCheckbox('Checkbox', 100, 130, 12, 12)
$btnCheckBox2   = GUICtrlCreateRadio('radio', 100, 150, 12, 12)
$radio          = GUICtrlCreateLabel('radio', 118, 149, 112, 12)

$Button1 = GUICtrlCreateButton('exit', 110, 220, 60, 23)
    GUICtrlSetBkColor(-1, 0x5099C0)
    GUICtrlSetColor(-1, 0xFFFFFF)

$label   = GUICtrlCreateLabel('_   x', 350, 25, 50, 25)
    GUICtrlSetColor(-1, 0xFFFFFF)

_WinAPI_SetLayeredWindowAttributes($butGui, 0xABCDEF, 255)


;This allows the png to be dragged by clicking anywhere on the main image.
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUICtrlSetOnEvent($Button1, "_exit")
GUISetState()


Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255)
    Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $hImage = _GDIPlus_ImageLoadFromFile($sPath)
    $width = _GDIPlus_ImageGetWidth($hImage)
    $height = _GDIPlus_ImageGetHeight($hImage)
    $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED)


    $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", $width)
    DllStructSetData($tSize, "Y", $height)
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", 1)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteObject($hImage)
    _WinAPI_DeleteDC($hMemDC)
EndFunc ;==>_GUICreate_Alpha

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hwnd = WinGetHandle("Look at the shiny")) And ($iMsg = $WM_NCHITTEST) Then
    Return $HTCAPTION
    EndIf
EndFunc

Func _exit()
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
     GUIDelete($GUI)
    Sleep(200)
    FileDelete('bak2.png')
  Exit
EndFunc

While 1
    Sleep(100)
WEnd

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

errr ... i loved the former ... thanks anyway for showing me the way ;) bdw ... the minimize and cancel buttons dun work nor can the gui be dragged! :huh2:

Share this post


Link to post
Share on other sites

errr ... i loved the former ... thanks anyway for showing me the way ;) bdw ... the minimize and cancel buttons dun work nor can the gui be dragged! :huh2:

close in the top right corner is not supposed to work. Its just a label. can be coded to, if mousepos this label coords & left mouse button cliked close gui.

I adve no problems dragging gui.

You probably just tried to click on the label area & tried to drag, you must click on an empty area to drag it.


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

Yeah i noticed it after posting it .. Done the closing function and minimizing code. But still cant move by dragging anywhere in the gui ...

Share this post


Link to post
Share on other sites

im using autoit ver 3.3.6.1

if you are using the same, then i have no clue


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

I'm using 3.3.6.1 and I can't get it to move either. You overlaid the GUI with another GUI (Control GUI) and it's interfering with the WM_NCHITTEST function. If I change that to point to the Control GUI, then only the controls move. If I comment out the If...Then statement in the WM_NCHITTEST function, I can move the control gui by itself, and if I move the main gui they both move together.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

errr can i be explained a bit about the WM_NCHITTEST message for the layered window ?

Share this post


Link to post
Share on other sites

I'm using 3.3.6.1 and I can't get it to move either. You overlaid the GUI with another GUI (Control GUI) and it's interfering with the WM_NCHITTEST function. If I change that to point to the Control GUI, then only the controls move. If I comment out the If...Then statement in the WM_NCHITTEST function, I can move the control gui by itself, and if I move the main gui they both move together.

How comes only I can move it? & i use same code iposted in post nr 8#

Check this made a capture, it works.

http://www.mediafire.com/download.php?nrsjm8duy7jsrd2


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
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
Sign in to follow this  
Followers 0