Sign in to follow this  
Followers 0
tip

Showing only a part of an animated gif?

3 posts in this topic

#1 ·  Posted (edited)

Hi to all,

I'm currently developing a script and I'm trying to create a nice looking gui for it. I'm using gdiplus functions to create a transparent layer and put guictrls on it. Here is a little part of my script:

_GDIPlus_Startup()

Opt("GUIOnEventMode",1)

$Background_PNG = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Background.png")
$EXIT_NORM = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Exit.png")
$MIN_NORM = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Minimize.png")

$GUI = GUICreate("TryOUT GUI", 450, 750, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $Background_PNG, 255)

$CONTROL_GUI = GUICreate("Deneme Child", 470, 270, 5,7, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)

$EXIT_AREA = GUICtrlCreateLabel("",429, 12, 20, 20)
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1, "_Halt")
$MIN_AREA = GUICtrlCreateLabel("",409, 12, 20, 20)
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1, "_Minimize")


GUISetBkColor(0x121314)
_WinAPI_SetLayeredWindowAttributes($CONTROL_GUI, 0x121314)
$ZEROGraphic = _GDIPlus_GraphicsCreateFromHWND($CONTROL_GUI)

$EXIT_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $EXIT_NORM, 0, 0, 20, 20, 429, 12, 20, 20)
$MIN_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $MIN_NORM, 0, 0, 20, 20, 409, 12, 20, 20)


GUIRegisterMsg($WM_PAINT, "DrawAll")

GUISetState(@SW_SHOW, $GUI)
GUISetState($GUI_SHOW, $CONTROL_GUI)


While 1
    Sleep(10)
WEnd



Func _Halt()
_GDIPlus_Shutdown()
GUIDelete($CONTROL_GUI)
GUIDelete($GUI)
Exit
EndFunc

Func _Minimize()
GUISetState(@SW_MINIMIZE, $GUI)
EndFunc

Func DrawAll()
_WinAPI_RedrawWindow($CONTROL_GUI, 0, 0, $RDW_UPDATENOW)
$EXIT_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $EXIT_NORM, 0, 0, 20, 20, 429, 12, 20, 20)
$MIN_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $MIN_NORM, 0, 0, 20, 20, 409, 12, 20, 20)
EndFunc

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend,$AC_SRC_ALPHA = 1

    $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 want to add an animated progress bar. So I thought I could use trancexx's UDF . It works great actually but here is the thing. I need to display only a part of my animated gif as it is the complete progress bar. Here is a basic example for what I'm trying to achieve(Imagine the progress bar is animated :graduated:):

So does anybody have an idea how to do it?

Thanks everybody in advance.

Sincerely

Tip

-----------------------------------------------------------------------------------------------------------------------------------------------------

P.S.: I've looked at other gif UDFs also but in general "creating the animation" parts are kind of above my understanding. Since I create my other ctrls with this method,

$EXIT_NORM = $EXIT_NORM = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Exit.png")(@ScriptDir & "\Exit.png")

$EXIT_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $EXIT_NORM, 0, 0, 20, 20, 429, 12, 20, 20),

I thought I could create a progress bar if a function can create an animated gif and return an image object like _GDIPlus_ImageLoadFromFile() function. I couldn't manage to do it but it might a starting point...

P.S.2: I've tried creating an embeded ie control and load gif in it but it wasn't a very decent solution since I had a right click context menu and I could move center of the page with mouse etc...

Edited by tip

[center]MsgBox_Tipped: Eye candy msgboxes/inputboxes/loginboxes. | CreateBlankBox: Semi-transparent layers with borders and rounded corners.[/center]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

error, nothing top say here but cannot delete this post.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

i was fix:

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

_GDIPlus_Startup()

Opt("GUIOnEventMode",1)

$Background_PNG = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Background.png")
$EXIT_NORM = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Exit.png")
$MIN_NORM = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Minimize.png")

$GUI = GUICreate("TryOUT GUI", 450, 750, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $Background_PNG, 255)

$CONTROL_GUI = GUICreate("Deneme Child", 470, 270, 5,7, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)

$EXIT_AREA = GUICtrlCreateLabel("",429, 12, 20, 20)
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1, "_Halt")
$MIN_AREA = GUICtrlCreateLabel("",409, 12, 20, 20)
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1, "_Minimize")


GUISetBkColor(0x121314)
_WinAPI_SetLayeredWindowAttributes($CONTROL_GUI, 0x121314)
$ZEROGraphic = _GDIPlus_GraphicsCreateFromHWND($CONTROL_GUI)

$EXIT_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $EXIT_NORM, 0, 0, 20, 20, 429, 12, 20, 20)
$MIN_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $MIN_NORM, 0, 0, 20, 20, 409, 12, 20, 20)

GUISetBkColor(0x121314)
_WinAPI_SetLayeredWindowAttributes($CONTROL_GUI, 0x121314)
$ZEROGraphic = _GDIPlus_GraphicsCreateFromHWND($CONTROL_GUI)

$EXIT_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $EXIT_NORM, 0, 0, 20, 20, 429, 12, 20, 20)
$MIN_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $MIN_NORM, 0, 0, 20, 20, 409, 12, 20, 20)


GUIRegisterMsg($WM_PAINT, "DrawAll")

GUISetState($GUI, $CONTROL_GUI)
GUISetState(@SW_SHOW, $GUI)
GUISetState(@SW_SHOW, $CONTROL_GUI)


While 1
    Sleep(10)
WEnd



Func _Halt()
_GDIPlus_Shutdown()
GUIDelete($CONTROL_GUI)
GUIDelete($GUI)
Exit
EndFunc

Func _Minimize()
GUISetState(@SW_MINIMIZE, $GUI)
EndFunc

Func DrawAll()
_WinAPI_RedrawWindow($CONTROL_GUI, 0, 0, $RDW_UPDATENOW)
$EXIT_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $EXIT_NORM, 0, 0, 20, 20, 429, 12, 20, 20)
$MIN_BUTTON = _GDIPlus_GraphicsDrawImageRectRect($ZEROGraphic, $MIN_NORM, 0, 0, 20, 20, 409, 12, 20, 20)
EndFunc

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend,$AC_SRC_ALPHA = 1

    $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

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