NicePerson Posted June 26, 2010 Share Posted June 26, 2010 I want when i click on Sign In button of my GUI, a GIF (Animated) image like this should be appear to this gui and all other things like check boxes, input boxes and text should be invisible!give me an example & here is my code:#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Any Messenger", 246, 361, 370, 150) GUISetBkColor(0xF9F9F2) $IDLabel = GUICtrlCreateLabel("ID:", 40, 56, 65, 19) $PassLabel = GUICtrlCreateLabel("Password:", 40, 122, 65, 19) $IdInput = GUICtrlCreateInput("", 35, 80, 161, 21) $PassInput = GUICtrlCreateInput("", 35, 138, 161, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL)) $Checkbox1 = GUICtrlCreateCheckbox("Remember my ID password", 35, 184, 185, 17) $Checkbox2 = GUICtrlCreateCheckbox("Sign in automatically", 35, 210, 129, 17) $Checkbox3 = GUICtrlCreateCheckbox("Sign in as invisible to everyone", 35, 237, 169, 17) $SignIn = GUICtrlCreateButton("Sign In", 72, 283, 83, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEndis it possible?how? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 26, 2010 Moderators Share Posted June 26, 2010 RMR, give me an exampleAnd what happened to that magic word - "please"? Here is one way to do it, based on some code I found in the forum from smashly. I recommend using the Search facility - there is often something to help you out there somewhere: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> Global $Gif = @ScriptDir & "\Spinner.gif" Global $i = 0, $ApX, $ApY, $ApW, $ApH, $eX, $eY $Form1_1 = GUICreate("Any Messenger", 246, 361, 370, 150) GUISetBkColor(0xF9F9F2) $IDLabel = GUICtrlCreateLabel("ID:", 40, 56, 65, 19) $PassLabel = GUICtrlCreateLabel("Password:", 40, 122, 65, 19) $IdInput = GUICtrlCreateInput("", 35, 80, 161, 21) $PassInput = GUICtrlCreateInput("", 35, 138, 161, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Checkbox1 = GUICtrlCreateCheckbox("Remember my ID password", 35, 184, 185, 17) $Checkbox2 = GUICtrlCreateCheckbox("Sign in automatically", 35, 210, 129, 17) $Checkbox3 = GUICtrlCreateCheckbox("Sign in as invisible to everyone", 35, 237, 169, 17) $SignIn = GUICtrlCreateButton("Sign In", 72, 283, 83, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SignIn Show_Gif() EndSwitch WEnd Func Show_Gif() ; based on code by smashly Local $aPos = WinGetPos($Form1_1) GUISetState(@SW_HIDE, $Form1_1) $hGUI = GUICreate("", $ApW, $ApH, $aPos[0] + (($aPos[2] - $ApW) / 2), $aPos[1] + (($aPos[3] - $ApH) / 2), $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetState() _GDIPlus_Startup() ; Load your animated gif $hImage = _GDIPlus_ImageLoadFromFile($Gif) $ApW = _GDIPlus_ImageGetWidth($hImage) $ApH = _GDIPlus_ImageGetHeight($hImage) $iBegin = TimerInit() Do ; Create a struct to hold the GUID. $tDL = DllStructCreate($tagGUID) ; Get a pointer to the GUID struct. $pDimensionIDs = DllStructGetPtr($tDL) ; Get the FrameDimensionsCount of the loaded gif $GFDC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "ptr", $hImage, "int*", 0) ; Get the FrameDimensionsList , which fills the GUID struct by passing the GUID pointer and the FrameDimensionsCount. DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsList", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $GFDC[2]) ; Get the FrameCount of the loaded gif by passing the GUID pointer $GFC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameCount", "int", $hImage, "ptr", $pDimensionIDs, "int*", 0) ; If $i = the frame count then reset $i to 0 If $i = $GFC[3] Then $i = 0 ;~ ConsoleWrite($GFC[3] & @LF) ; Select the ActiveFrame in the loaded gif by telling it. The frame starts @ 0 ($i) DllCall($ghGDIPDll, "int", "GdipImageSelectActiveFrame", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $i) ; At this point you can get the CLSID of an encoder and save the frame to file if you want.. ; Use any Encoder you like. eg: "GIF", "TIF", "BMP", "JPG" ; Transparency won't be saved. (You'd need to play with pallets to have the transparency saved) ;~ $sCLSID = _GDIPlus_EncodersGetCLSID ("PNG") ;~ _GDIPlus_ImageSaveToFileEx ($hImage, @MyDocumentsDir & "\Gif_Frame_" & $i & ".png", $sCLSID) ; The rest is just a copy and paste on updating a layered window with the loaded gif. ; I tried using _GDIPlus_GraphicsDrawImage() but no matter what I did memory was getting chewed up. leak maybe? ; But using the Update layered window and memory use seems to level out and sit pretty idle ;) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hScrDC = _WinAPI_GetDC($hGUI) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) DllStructSetData($tSize, "X", $ApW) DllStructSetData($tSize, "Y", $ApH) $pSize = DllStructGetPtr($tSize) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) DllStructSetData($tBlend, "Alpha", 255) DllStructSetData($tBlend, "Format", 1) $pBlend = DllStructGetPtr($tBlend) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) ;Tidy Up at end of each frame, otherwise memory use gets excessive in a short time. ;~ _GDIPlus_ImageDispose($hImage) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) ; By rights I should be using the const PropertyTagFrameDelay and geting the properties time delay between frames. ; I cheated , so shoot me...lol Sleep(100) $i += 1 Until TimerDiff($iBegin) > 2000 ; Run for 2 secs _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() GUIDelete($hGUI) GUISetState(@SW_SHOW, $Form1_1) EndFunc ;==>Show_Gif Your gif shows for 2 secs and then the original GUI returns. Of course, you can modify that as you wish by changing the code at the end of the function. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NicePerson Posted June 26, 2010 Author Share Posted June 26, 2010 @Melba23Thanks for reply but i want if i click on sign in button then a gif image should be appear at the same GUI.Example:When we click at sign in button on Yahoo Messenger the sleeping logo changes to a smiling image.Here is a screenshotdid u got it?Thanks,RMR Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 26, 2010 Moderators Share Posted June 26, 2010 RMR, This code puts the gif in your GUI, but it is no longer animated. I am afraid I have no idea why. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> Global $Gif = @ScriptDir & "\Spinner.gif" Global $i = 0, $ApX, $ApY, $ApW, $ApH, $eX, $eY $Form1_1 = GUICreate("Any Messenger", 246, 361, 370, 150) GUISetBkColor(0xF9F9F2) $IDLabel = GUICtrlCreateLabel("ID:", 40, 56, 65, 19) $PassLabel = GUICtrlCreateLabel("Password:", 40, 122, 65, 19) $IdInput = GUICtrlCreateInput("", 35, 80, 161, 21) $PassInput = GUICtrlCreateInput("", 35, 138, 161, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Checkbox1 = GUICtrlCreateCheckbox("Remember my ID password", 35, 184, 185, 17) $Checkbox2 = GUICtrlCreateCheckbox("Sign in automatically", 35, 210, 129, 17) $Checkbox3 = GUICtrlCreateCheckbox("Sign in as invisible to everyone", 35, 237, 169, 17) $SignIn = GUICtrlCreateButton("Sign In", 72, 283, 83, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SignIn Show_Gif() EndSwitch WEnd Func Show_Gif() ; based on code by smashly _GDIPlus_Startup() ; Load your animated gif $hImage = _GDIPlus_ImageLoadFromFile($Gif) $ApW = _GDIPlus_ImageGetWidth($hImage) $ApH = _GDIPlus_ImageGetHeight($hImage) Local $aPos = WinGetPos($Form1_1) ; Hide controls For $i = $IDLabel to $SignIn GUICtrlSetState($i, $GUI_HIDE) Next GUISetState(@SW_DISABLE, $Form1_1) ; Create GUI to hold gif $hGUI = GUICreate("", $ApW, $ApH, $aPos[0] + (($aPos[2] - $ApW) / 2), $aPos[1] + (($aPos[3] - $ApH) / 2), $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetState() ; get time stamp $iBegin = TimerInit() Do ; Create a struct to hold the GUID. $tDL = DllStructCreate($tagGUID) ; Get a pointer to the GUID struct. $pDimensionIDs = DllStructGetPtr($tDL) ; Get the FrameDimensionsCount of the loaded gif $GFDC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "ptr", $hImage, "int*", 0) ; Get the FrameDimensionsList , which fills the GUID struct by passing the GUID pointer and the FrameDimensionsCount. DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsList", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $GFDC[2]) ; Get the FrameCount of the loaded gif by passing the GUID pointer $GFC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameCount", "int", $hImage, "ptr", $pDimensionIDs, "int*", 0) ; If $i = the frame count then reset $i to 0 If $i = $GFC[3] Then $i = 0 ;~ ConsoleWrite($GFC[3] & @LF) ; Select the ActiveFrame in the loaded gif by telling it. The frame starts @ 0 ($i) DllCall($ghGDIPDll, "int", "GdipImageSelectActiveFrame", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $i) ; At this point you can get the CLSID of an encoder and save the frame to file if you want.. ; Use any Encoder you like. eg: "GIF", "TIF", "BMP", "JPG" ; Transparency won't be saved. (You'd need to play with pallets to have the transparency saved) ;~ $sCLSID = _GDIPlus_EncodersGetCLSID ("PNG") ;~ _GDIPlus_ImageSaveToFileEx ($hImage, @MyDocumentsDir & "\Gif_Frame_" & $i & ".png", $sCLSID) ; The rest is just a copy and paste on updating a layered window with the loaded gif. ; I tried using _GDIPlus_GraphicsDrawImage() but no matter what I did memory was getting chewed up. leak maybe? ; But using the Update layered window and memory use seems to level out and sit pretty idle ;) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hScrDC = _WinAPI_GetDC($hGUI) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) DllStructSetData($tSize, "X", $ApW) DllStructSetData($tSize, "Y", $ApH) $pSize = DllStructGetPtr($tSize) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) DllStructSetData($tBlend, "Alpha", 255) DllStructSetData($tBlend, "Format", 1) $pBlend = DllStructGetPtr($tBlend) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) ;Tidy Up at end of each frame, otherwise memory use gets excessive in a short time. ;~ _GDIPlus_ImageDispose($hImage) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) ; By rights I should be using the const PropertyTagFrameDelay and geting the properties time delay between frames. ; I cheated , so shoot me...lol Sleep(100) $i += 1 Until TimerDiff($iBegin) > 2000 ; Run for 2 secs _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() ; Delete gif GUI GUIDelete($hGUI) GUISetState(@SW_ENABLE, $Form1_1) GUISetState(@SW_RESTORE, $Form1_1) ; Reshow controls For $i = $IDLabel to $SignIn GUICtrlSetState($i, $GUI_SHOW) Next EndFunc ;==>Show_Gif You will have to wait until someone more knowledgeable about GDI comes along! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NicePerson Posted June 26, 2010 Author Share Posted June 26, 2010 Melba23 Thanks for an idea but it is no longer animated? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 26, 2010 Moderators Share Posted June 26, 2010 RMR,This code puts the gif in your GUI, but it is no longer animated. I am afraid I have no idea why. ...You will have to wait until someone more knowledgeable about GDI comes along! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Authenticity Posted June 26, 2010 Share Posted June 26, 2010 It was a simple mistake. Very nice example Melba: In Show_Gif, code should be: ; Hide controls For $i = $IDLabel to $SignIn GUICtrlSetState($i, $GUI_HIDE) Next ; Simple mistake $i = 0 ; or use $j, $k, etc.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 27, 2010 Moderators Share Posted June 27, 2010 Authenticity, Thanks for that hint - too many bits of patched together code colliding! RMR, This now gives you an animated gif: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> Global $Gif = @ScriptDir & "\Spinner.gif" Global $i = 0, $ApX, $ApY, $ApW, $ApH, $eX, $eY $Form1_1 = GUICreate("Any Messenger", 246, 361, 370, 150) GUISetBkColor(0xF9F9F2) $IDLabel = GUICtrlCreateLabel("ID:", 40, 56, 65, 19) $PassLabel = GUICtrlCreateLabel("Password:", 40, 122, 65, 19) $IdInput = GUICtrlCreateInput("", 35, 80, 161, 21) $PassInput = GUICtrlCreateInput("", 35, 138, 161, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Checkbox1 = GUICtrlCreateCheckbox("Remember my ID password", 35, 184, 185, 17) $Checkbox2 = GUICtrlCreateCheckbox("Sign in automatically", 35, 210, 129, 17) $Checkbox3 = GUICtrlCreateCheckbox("Sign in as invisible to everyone", 35, 237, 169, 17) $SignIn = GUICtrlCreateButton("Sign In", 72, 283, 83, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SignIn Show_Gif() EndSwitch WEnd Func Show_Gif() ; based on code by smashly _GDIPlus_Startup() ; Load your animated gif $hImage = _GDIPlus_ImageLoadFromFile($Gif) $ApW = _GDIPlus_ImageGetWidth($hImage) $ApH = _GDIPlus_ImageGetHeight($hImage) Local $aPos = WinGetPos($Form1_1) ; Hide controls For $j = $IDLabel to $SignIn GUICtrlSetState($j, $GUI_HIDE) Next GUISetState(@SW_DISABLE, $Form1_1) ; Create GUI to hold gif $hGUI = GUICreate("", $ApW, $ApH, $aPos[0] + (($aPos[2] - $ApW) / 2), $aPos[1] + (($aPos[3] - $ApH) / 2), $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetState() ; get time stamp $iBegin = TimerInit() Do ; Create a struct to hold the GUID. $tDL = DllStructCreate($tagGUID) ; Get a pointer to the GUID struct. $pDimensionIDs = DllStructGetPtr($tDL) ; Get the FrameDimensionsCount of the loaded gif $GFDC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "ptr", $hImage, "int*", 0) ; Get the FrameDimensionsList , which fills the GUID struct by passing the GUID pointer and the FrameDimensionsCount. DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsList", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $GFDC[2]) ; Get the FrameCount of the loaded gif by passing the GUID pointer $GFC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameCount", "int", $hImage, "ptr", $pDimensionIDs, "int*", 0) ; If $i = the frame count then reset $i to 0 If $i = $GFC[3] Then $i = 0 ;~ ConsoleWrite($GFC[3] & @LF) ; Select the ActiveFrame in the loaded gif by telling it. The frame starts @ 0 ($i) DllCall($ghGDIPDll, "int", "GdipImageSelectActiveFrame", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $i) ; At this point you can get the CLSID of an encoder and save the frame to file if you want.. ; Use any Encoder you like. eg: "GIF", "TIF", "BMP", "JPG" ; Transparency won't be saved. (You'd need to play with pallets to have the transparency saved) ;~ $sCLSID = _GDIPlus_EncodersGetCLSID ("PNG") ;~ _GDIPlus_ImageSaveToFileEx ($hImage, @MyDocumentsDir & "\Gif_Frame_" & $i & ".png", $sCLSID) ; The rest is just a copy and paste on updating a layered window with the loaded gif. ; I tried using _GDIPlus_GraphicsDrawImage() but no matter what I did memory was getting chewed up. leak maybe? ; But using the Update layered window and memory use seems to level out and sit pretty idle ;) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hScrDC = _WinAPI_GetDC($hGUI) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) DllStructSetData($tSize, "X", $ApW) DllStructSetData($tSize, "Y", $ApH) $pSize = DllStructGetPtr($tSize) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) DllStructSetData($tBlend, "Alpha", 255) DllStructSetData($tBlend, "Format", 1) $pBlend = DllStructGetPtr($tBlend) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) ;Tidy Up at end of each frame, otherwise memory use gets excessive in a short time. ;~ _GDIPlus_ImageDispose($hImage) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) ; By rights I should be using the const PropertyTagFrameDelay and geting the properties time delay between frames. ; I cheated , so shoot me...lol Sleep(100) $i += 1 Until TimerDiff($iBegin) > 2000 ; Run for 2 secs _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() ; Delete gif GUI GUIDelete($hGUI) GUISetState(@SW_ENABLE, $Form1_1) GUISetState(@SW_RESTORE, $Form1_1) ; Reshow controls For $j = $IDLabel to $SignIn GUICtrlSetState($j, $GUI_SHOW) Next EndFunc ;==>Show_Gif M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NicePerson Posted June 27, 2010 Author Share Posted June 27, 2010 Thanks Melba for helping me a lot! RMR Link to comment Share on other sites More sharing options...
martin Posted June 27, 2010 Share Posted June 27, 2010 Good example M23, I applaud your persistence. If the script has lots of controls and more than one window it could become difficult to loop through all of the controls, especially if they are not created in order. In that situation, and as an alternative way of hiding them, you could do this. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPI.au3> #include <editconstants.au3> Global $Gif = @ScriptDir & "\Spinner.gif" Global $i = 0, $ApX, $ApY, $ApW, $ApH, $eX, $eY $Form1_1 = GUICreate("Any Messenger", 246, 361, 370, 150) ;add the gui colour or any images or controls that you want to be seen when the gif shows ;eg ;GUISetBkColor(0xccaa99) $Form2 = GUICreate("",246,361,0,0,$WS_CHILD,-1,$Form1_1) GUISetBkColor(0xF9F9F2) $IDLabel = GUICtrlCreateLabel("ID:", 40, 56, 65, 19) $PassLabel = GUICtrlCreateLabel("Password:", 40, 122, 65, 19) $IdInput = GUICtrlCreateInput("", 35, 80, 161, 21) $PassInput = GUICtrlCreateInput("", 35, 138, 161, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Checkbox1 = GUICtrlCreateCheckbox("Remember my ID password", 35, 184, 185, 17) $Checkbox2 = GUICtrlCreateCheckbox("Sign in automatically", 35, 210, 129, 17) $Checkbox3 = GUICtrlCreateCheckbox("Sign in as invisible to everyone", 35, 237, 169, 17) $SignIn = GUICtrlCreateButton("Sign In", 72, 283, 83, 25, $WS_GROUP) GUISetState(@SW_SHOW) GUISetState(@SW_SHOW,$Form1_1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $SignIn Show_Gif() EndSwitch WEnd Func Show_Gif() ; based on code by smashly _GDIPlus_Startup() ; Load your animated gif $hImage = _GDIPlus_ImageLoadFromFile($Gif) $ApW = _GDIPlus_ImageGetWidth($hImage) $ApH = _GDIPlus_ImageGetHeight($hImage) Local $aPos = WinGetPos($Form1_1) ; Hide controls GUISetState(@SW_HIDE,$Form2) ; Create GUI to hold gif $hGUI = GUICreate("", $ApW, $ApH, $aPos[0] + (($aPos[2] - $ApW) / 2), $aPos[1] + (($aPos[3] - $ApH) / 2), $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetState() ; get time stamp $iBegin = TimerInit() Do ; Create a struct to hold the GUID. $tDL = DllStructCreate($tagGUID) ; Get a pointer to the GUID struct. $pDimensionIDs = DllStructGetPtr($tDL) ; Get the FrameDimensionsCount of the loaded gif $GFDC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "ptr", $hImage, "int*", 0) ; Get the FrameDimensionsList , which fills the GUID struct by passing the GUID pointer and the FrameDimensionsCount. DllCall($ghGDIPDll, "int", "GdipImageGetFrameDimensionsList", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $GFDC[2]) ; Get the FrameCount of the loaded gif by passing the GUID pointer $GFC = DllCall($ghGDIPDll, "int", "GdipImageGetFrameCount", "int", $hImage, "ptr", $pDimensionIDs, "int*", 0) ; If $i = the frame count then reset $i to 0 If $i = $GFC[3] Then $i = 0 ;~ ConsoleWrite($GFC[3] & @LF) ; Select the ActiveFrame in the loaded gif by telling it. The frame starts @ 0 ($i) DllCall($ghGDIPDll, "int", "GdipImageSelectActiveFrame", "ptr", $hImage, "ptr", $pDimensionIDs, "int", $i) ; At this point you can get the CLSID of an encoder and save the frame to file if you want.. ; Use any Encoder you like. eg: "GIF", "TIF", "BMP", "JPG" ; Transparency won't be saved. (You'd need to play with pallets to have the transparency saved) ;~ $sCLSID = _GDIPlus_EncodersGetCLSID ("PNG") ;~ _GDIPlus_ImageSaveToFileEx ($hImage, @MyDocumentsDir & "\Gif_Frame_" & $i & ".png", $sCLSID) ; The rest is just a copy and paste on updating a layered window with the loaded gif. ; I tried using _GDIPlus_GraphicsDrawImage() but no matter what I did memory was getting chewed up. leak maybe? ; But using the Update layered window and memory use seems to level out and sit pretty idle ;) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hScrDC = _WinAPI_GetDC($hGUI) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) DllStructSetData($tSize, "X", $ApW) DllStructSetData($tSize, "Y", $ApH) $pSize = DllStructGetPtr($tSize) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) DllStructSetData($tBlend, "Alpha", 255) DllStructSetData($tBlend, "Format", 1) $pBlend = DllStructGetPtr($tBlend) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) ;Tidy Up at end of each frame, otherwise memory use gets excessive in a short time. ;~ _GDIPlus_ImageDispose($hImage) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) ; By rights I should be using the const PropertyTagFrameDelay and geting the properties time delay between frames. ; I cheated , so shoot me...lol Sleep(100) $i += 1 Until TimerDiff($iBegin) > 2000 ; Run for 2 secs _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() ; Delete gif GUI GUIDelete($hGUI) ; Reshow controls GUISetState(@SW_SHOW,$Form2) EndFunc ;==>Show_Gif 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. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 27, 2010 Moderators Share Posted June 27, 2010 martin, Nice suggestion - I will remember that one! Thanks. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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