Jump to content
Sign in to follow this  
myspacee

guidelete() to load new image [!?]

Recommended Posts

myspacee

Hello to all,

in these days i work with gui and images. I need to update an image into my gui.

Notice flickering when destroy my gui to load newer image, and lot of memory use.

So i investigate about image update function, but can't obtain nothing ..

Anyone can help me ?

In this example I destroy merlin to load other images, How update them instead ?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $gui, $guiPos, $pic, $picPos

Example2()


;----- example 2
Func Example2()
    Local $msg
    
    $gui = GUICreate("test transparentpic", 200, 100)
    $pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)
    GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 0, 0)

    GUISetState(@SW_SHOW, $pic)
;~  GUISetState(@SW_SHOW, $gui)

    HotKeySet("{ESC}", "main")
    HotKeySet("{LEFT}", "left")
    HotKeySet("{RIGHT}", "right")
    HotKeySet("{DOWN}", "down")
    HotKeySet("{UP}", "up")
    $picPos = WinGetPos($pic)
    $guiPos = WinGetPos($gui)

    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc  ;==>Example2

Func main()
    exit
EndFunc  ;==>main

Func left()
    GUIDelete()
    $gui = GUICreate("test transparentpic", 200, 100)
    $pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)
    GUICtrlCreatePic(@SystemDir & "\oobe\images\backover.jpg", 0, 0, 0, 0)

    GUISetState(@SW_SHOW, $pic)
EndFunc  ;==>left

Func right()
    GUIDelete()
    $gui = GUICreate("test transparentpic", 200, 100)
    $pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)
    GUICtrlCreatePic(@SystemDir & "\oobe\images\nextover.jpg", 0, 0, 0, 0)

    GUISetState(@SW_SHOW, $pic)
    
    
EndFunc  ;==>right

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] + 10)
EndFunc  ;==>down

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] - 10)
EndFunc  ;==>up

Thank you,

m.

Share this post


Link to post
Share on other sites
GEOSoft

That code needs some serious cleanup but here is a minor re-write

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $Frm_Gui, $Frm_GuiPos, $pic, $picPos

Example2()


;----- example 2
Func Example2()
    Local $msg
    
    $Frm_gui = GUICreate("test transparentpic", 200, 100)
    GUISetState(@SW_SHOW)
    Global $Frm_pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $Frm_Gui)
    Global $Image = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 0, 0)

    GUISetState(@SW_SHOW, $Frm_Pic)
;~   GUISetState(@SW_SHOW, $Frm_Gui)

    HotKeySet("{ESC}", "main")
    HotKeySet("{LEFT}", "left")
    HotKeySet("{RIGHT}", "right")
    HotKeySet("{DOWN}", "down")
    HotKeySet("{UP}", "up")
    $Frm_PicPos = WinGetPos($Frm_Pic)
    $Frm_GuiPos = WinGetPos($Frm_Gui)

    Do
        $msg = GUIGetMsg()
    Until $msg = $Frm_Gui_EVENT_CLOSE
EndFunc;==>Example2

Func main()
    exit
EndFunc;==>main

Func left()
 ;GUIDelete()
 ;$Frm_Gui = GUICreate("test transparentpic", 200, 100)
 ;$Frm_Pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $Frm_Gui)
    GUICtrlSetImage($Image, @SystemDir & "\oobe\images\backover.jpg")

 ;GUISetState(@SW_SHOW, $Frm_Pic)
EndFunc;==>left

Func right()
 ;GUIDelete()
 ;$Frm_Gui = GUICreate("test transparentpic", 200, 100)
 ;$Frm_Pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $Frm_Gui)
 ;$Image = GUICtrlCreatePic(@SystemDir & "\oobe\images\nextover.jpg", 0, 0, 0, 0)
      GUICtrlSetImage($Image, @SystemDir & "\oobe\images\nextover.jpg")
 ;GUISetState(@SW_SHOW, $Frm_Pic)
    
    
EndFunc;==>right

Func down()
    $PicPos = WinGetPos($Frm_Pic)
    WinMove($Frm_Pic, "", $PicPos[0], $PicPos[1] + 10)
EndFunc;==>down

Func up()
    $PicPos = WinGetPos($Frm_Pic)
    WinMove($Frm_Pic, "", $PicPos[0], $PicPos[1] - 10)
EndFunc;==>up

EDIT: Declared $Frm_Pic as a Global

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
myspacee

thank you for reply,

my code is taken from help, real script is more clean ^_^

try now and say if i can adapt,

Thank you again,

m.

_________edit

Ok cosmetic changes but works in my script, modify your exaple :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global $gui, $guiPos, $pic, $picPos

Example2()


;----- example 2
Func Example2()
    Local $msg
    
    $gui = GUICreate("test transparentpic", 200, 100)
    $pic = GUICreate("", 68, 71, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)
    Global $Image = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 0, 0)
    GUISetState(@SW_SHOW, $pic)


    HotKeySet("{ESC}", "main")
    HotKeySet("{LEFT}", "left")
    HotKeySet("{RIGHT}", "right")
    HotKeySet("{DOWN}", "down")
    HotKeySet("{UP}", "up")
    $picPos = WinGetPos($pic)
    $guiPos = WinGetPos($gui)

    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc ;==>Example2

Func main()
    exit
EndFunc ;==>main

Func left()
    GUICtrlSetImage($Image, @SystemDir & "\oobe\images\backover.jpg")
EndFunc ;==>left

Func right()
    GUICtrlSetImage($Image, @SystemDir & "\oobe\images\nextover.jpg")
EndFunc ;==>right

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] + 10)
EndFunc ;==>down

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic, "", $picPos[0], $picPos[1] - 10)
EndFunc ;==>up
Edited by myspacee

Share this post


Link to post
Share on other sites
GEOSoft

Also read my edit

Nevermind. I see it was already Globalized.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  

×