Jump to content

Embed image resource into exe and load into picture controls - (Moved)


Recommended Posts

I am trying to embed a few images(jpg/gif/png) into my project so I don't have to have the files available on the system at runtime.  Note that I plan to programmatically change the pictures based on current status so the picture in $picKeyFoundYes will not be static.

So I put the following in the Compile->res add files->extra files tab:

D:\Data\MyProgs\AutoIt\Update Tool\approved.jpg,images,ONE
D:\Data\MyProgs\AutoIt\Update Tool\check.gif,images,TWO

I would like to somehow pull each of these images and assign them to a picture control.  Below is my attempt but it is not working.

; Load images
;~ $picKeyFoundYes = GUICtrlCreatePic("", 145, 160, 24, 24) (commented because this line is already above in script
;~ $hImage = _GUIImageList_Create(16, 16, 5, 1)
$hImage = _GUIImageList_Create()
If @Compiled Then
    _GUIImageList_Add($hImage, @ScriptFullPath, 1)
    _GUIImageList_Add($hImage, @ScriptFullPath, 2)
    mb(@error)
Else
    _GUIImageList_Add($hImage, "approved.jpg")
    _GUIImageList_Add($hImage, "check.gif")
    mb(@error)
    ; How do I put one of the images from the imagelist in the picture control?
;~  GUICtrlSetImage($picKeyFoundYes, $hImage[0])
EndIf

Maybe I'm just not referencing the two images in the $hImage image list properly.  This seems like a basic task but I'm struggling so I would appreciate any guidance on it.

Thanks all

Edited by schuc
Link to comment
Share on other sites

I should note that at the top of the script in the AutoIt3Wrapper_GUI #Region, it added:

#AutoIt3Wrapper_Res_File_Add=D:\Data\MyProgs\AutoIt\Update Tool\approved.jpg,images,ONE
#AutoIt3Wrapper_Res_File_Add=D:\Data\MyProgs\AutoIt\Update Tool\check.gif,images,TWO

...so apparently the resources were added, but I don't know how to reference them and set the image to a picture control.

Thanks for any assistance

Link to comment
Share on other sites

Update: I just discovered ResourcesEx and am implementing that and having success.  The issue I have now is that my images are large and taking over the whole GUI.  I see there is an option for resize, but that isn't doing anything for my JPG files it seems.

Link to comment
Share on other sites

4 hours ago, schuc said:

I am trying to embed a few images(jpg/gif/png) into my project so I don't have to have the files available on the system at runtime.

You can also have a look at : file-to-base64-string-code-generator-v120-build-2020-06-05-embed-your-files-easily

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

2 hours ago, Musashi said:

Thanks for your reply Musashi.  I was able to get it all going with ResourcesEx.  I wasn't able to get the bitmap to load so I just used the JPG version I had of the same and now all load and size to control properly.

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:

Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...