Jump to content
Sign in to follow this  

PNG - remove from Gui

Recommended Posts


Task: Display a PNG, and remove it on command.

I searched and read the help file for some time. I came up with a solution but that was not nice (was something like fill the previous image with the backgroundcolor...)

So I re-used the example of the PNG display (with a little mod) and ask kindly if someone could give me a hint on the _remove() function.

I think there is a easier method or isn't there one?

I attached the images but I think it does not matter just use any png files._png.zip

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

Global $hGUI, $hImage, $hGraphic, $hImage1

; Create GUI
$hGUI = GUICreate("Show PNG", 500, 500)

; Load PNG image
$hImage = _GDIPlus_ImageLoadFromFile("big.png")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

; Loop until the user exits.
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        case $button1
        case $button2

; Clean up resources

func _remove()
    ;~ mmmh

func _change()
    $hImage = _GDIPlus_ImageLoadFromFile("small.png")
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0,300,300,0,0,300,300)

; Draw PNG image
Func MY_WM_PAINT($hWnd, $msg, $wParam, $lParam)
    #forceref $hWnd, $Msg, $wParam, $lParam
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hImage, 0, 0,300,300,0,0,300,300)
    _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE)
EndFunc   ;==>MY_WM_PAINT

Share this post

Link to post
Share on other sites

..a last try ...  So simple that I missed the answer? Any help except "read help file" ?

Share this post

Link to post
Share on other sites

What do you mean with remove? You mean clear the image? If yes then try this:

func _remove()
    _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0)



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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites

thx for your answer. As I read a lot of posting from you (UEZ) about GDIPlus here, I think it is the best I could do.

(in other words if you came up with a similar idea like me, there is nothing better - see my first post).

I thought maybe there is something, that is better than "clear". (like destroy object, recreate or what ever)

Sounds not very thankful, didn't it?

But I am thankful.

I honor your response as "solved". thx.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.