Sign in to follow this  
Followers 0
michaelslamet

Why GUICtrlCreatePic doesn't work after _GDIPlus_Startup() ?

11 posts in this topic

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.

Share this post


Link to post
Share on other sites



I have the same problem with SplashImageOn.

If I comment out _GDIPlus_Startup(), the image is displayed.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

DjForfun,

You are not solving the issue of the OP.

michaelslamet,

You need to dispose the image so it can be loaded again.

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

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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).


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Of course it works because the GUICtrlCreatePic releases the image (deduction).


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Yes :) (I meant you have to release it because it's locked)

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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