Jump to content

Why GUICtrlCreatePic doesn't work after _GDIPlus_Startup() ?


Recommended Posts

Just wonder, why GUICtrlCreatePic doesn't display image after _GDIPlus_Startup() ?

This code will not displaying example.gif:

#include <GUIConstants.au3>
#include <GDIPlus.au3>

GUICreate("GUICtrlCreatePic Example", 200, 150, -1, -1)

_GDIPlus_Startup ()
$file = @ScriptDir & "\example.gif"
$image = _GDIPlus_ImageLoadFromFile($file)
GUICtrlCreatePic($file, 1,1)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

 

If we comment the "_GDIPlus_Startup ()" the example.gif will displayed perfectly.

Link to comment
Share on other sites

  • 1 month later...

This is not _GDIPlus_Startup() related but _GDIPlus_ImageLoadFromFile() in connection with GUICtrlCreatePic().

The GUICtrlCreatePic() function returns 0 and set error = 1 but no documentation about error = 1.

I cannot tell you yet why the image is not displayed.

Br,

UEZ

Edited by UEZ

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

Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <GDIPlus.au3>

GUICreate("GUICtrlCreatePic Example", 200, 150, -1, -1)
$Ctrlpic = GUICtrlCreatePic('', 0, 0, 200, 150)
_GDIPlus_Startup()
$file = @ScriptDir & "\example.gif"
$image = _GDIPlus_ImageLoadFromFile($file)
$hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($image)
_GDIPlus_ImageDispose($image)
_WinAPI_DeleteObject(GUICtrlSendMsg($Ctrlpic, 0x0172, 0, $hBMP)) ; thank to uez
_WinAPI_DeleteObject($hBMP)
_GDIPlus_Shutdown()
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Link to comment
Share on other sites

The question is not to find a workaround rather find the root cause. I assume that this is a bug within AutoIt.
 
 
Br,
UEZ

Edited by UEZ

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

Link to comment
Share on other sites

UEZ,

This is not a workaround, can you tell me why if you use two different scripts the image can not be loaded using the GUICtrlCreatePic if it was previously loaded using _GDIPlus_ImageLoadFromFile (and not disposed).

Link to comment
Share on other sites

If you swap these lines it works, too.

 

$image = _GDIPlus_ImageLoadFromFile($file)
GUICtrlCreatePic($file, 1,1)

@FireFox: no. GUICtrlCreatePic is unfortunately a built-in function and not transparent.

Edit: ops, wrong two lines selected.

 

Br,

UEZ

Edited by UEZ

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

Link to comment
Share on other sites

Ah, now I remember why it doesn't work.  :doh:
 
Because _GDIPlus_ImageLoadFromFile($file) is locking the file and GUICtrlCreatePic() cannot load it because it is locked by GDI+ function.

No AutoIt bug!


Br,
UEZ

Edited by UEZ

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...