Jump to content

Show image in GUI


Go to solution Solved by UEZ,

Recommended Posts

Hey guys,

Im trying to show an image in gui preferable bmp or png as it needs to be good quality and jpg just doesnt cut it, however i cant get the image to show...

.bmp works in koda but doesnt work when i try to load it in autoit and as for PNG i noticed i have to use GDI plus? i tried writing abit of code and i dont see why its not working - what am i doing wrong?

Global Const $IMAGE_BITMAP = 0
Global Const $STM_SETIMAGE = 0x0172
Global $msg
Global Const $idPic = GUICtrlCreatePic("\\fbnecl3\inzb\Documents\Load Support\Tom\Projects\Dashboard\Charts\scorecard.png", 183, 144, 985, 577)
_GDIPlus_Startup()
Global Const $png = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUITorus.png")
Global Const $hImage = _GDIPlus_ImageLoadFromFile($png)
Global Const $Bmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
 Case $GUI_EVENT_CLOSE
                _WinAPI_DeleteObject($Bmp)
            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_Shutdown()
            GUIDelete($lscscreen)
            Exit
    
    EndSwitch
WEnd
Link to post
Share on other sites

I don't know for sure, but have you used a unc path for an image before?  I have only ever used local paths which I have created as a resource directory on the target machine I am running on.  I can say with certainty that I have used @scriptdir and a local path, but have not tried a unc or network path really.

Link to post
Share on other sites

Yep i use absolute paths for all of my gui' images and never have an issue.. it just seems to be with .bmp and .png

i just cant understand why the .bmp loads in koda and not in autoit - ultimately i want to use the .png but i would settle for getting the .bmp to work. - i am still a noob so im going to bet money im doing something wrong lol

Edited by 13lack13lade
Link to post
Share on other sites
  • Solution

Try this:

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>

Global Const $STM_SETIMAGE = 0x0172
Global $msg
Global Const $lscscreen = GUICreate("Test", 985, 577)
Global Const $idPic = GUICtrlCreatePic("", 183, 144, 985, 577)
_GDIPlus_Startup()
Global Const $png = StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\Torus.png") ;$png = "\\fbnecl3\inzb\Documents\Load Support\Tom\Projects\Dashboard\Charts\scorecard.png"
Global Const $hImage = _GDIPlus_ImageLoadFromFile($png)
Global Const $Bmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $Bmp))
GUISetState(@SW_SHOW)



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
 Case $GUI_EVENT_CLOSE
            _WinAPI_DeleteObject($Bmp)
            _GDIPlus_ImageDispose($hImage)
            _GDIPlus_Shutdown()
            GUIDelete($lscscreen)
            Exit

    EndSwitch
WEnd

Br,

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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...