Jump to content

How to set Image And Change Icon


Darkbeo
 Share

Recommended Posts

Hi everyone,

After a long time, I'm coming to use AutoIt.

I do not remember almost nothing about, I wonder how I can use icons "on.ico" and "off.ico" in a GUICtrlCreatePic or to change GUISetIcon?

Script:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=icons\mouse.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Icon_Add=icons\on.ico
#AutoIt3Wrapper_Res_Icon_Add=icons\off.ico
#AutoIt3Wrapper_Res_File_Add=images\mouse.jpg, RT_RCDATA, 0_JPG_1, 0
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Project01", 118, 120, 302, 218)
GUISetIcon("icons\project.ico")
$Pic1 = GUICtrlCreatePic("", 8, 8, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Link to comment
Share on other sites

I registered here in the forum for a long time since I've used the AutoIt in 2007 for a short period of time and then had to stop using to give priority to work and study.

I am wanting to start using AutoIt, but I have forgotten a lot of things, I wonder if someone could help me with this I have little doubt that it:

How do I use the files added to the executable from the command line

#AutoIt3Wrapper_Run_After=ResHacker\ResHacker.exe -add %out%, %out%, images\img01.jpg, RT_RCDATA, IMG_JPG_0, 0
#AutoIt3Wrapper_Run_After=ResHacker\ResHacker.exe -add %out%, %out%, images\img02.jpg, RT_RCDATA, IMG_JPG_1, 0

therefore necessary to use these images in such GUICtrlCreatePic

to start implementing the GUICtrlCreatePic will have the image "Image1.bmp" standard, after the User clicks a button the image will be changed to "image2.bmp"

Could anyone help me?

Thank you for your attention

Link to comment
Share on other sites

  • Moderators

Darkbeo,

Welcome back to the AutoIt forum! :D

Q1. When I use #AutoIt3Wrapper_Res_Icon_Add the first added icon is added at index -5. So if you declare something like this:

Global Const $iOn_Icon = -5, $iOff_Icon = -6

then you can use this as syntax:

TraySetIcon(@ScriptFullPath, $iOn_Icon)
; or
$hFred = GUICtrlCreateButton("", 243, 8, 24, 24, $BS_ICON)
GUICtrlSetImage($hFred, @ScriptFullPath, $iOff_Icon, 0)

Q2. The easiest way to use added resources within the .exe is Zedna's excellent Resources UDF, which you can find here. But you MUST read the topic carefully and play with the examples until you understand what is going on. The UDF is not difficult, but if you do not get the syntax right you might as well not bother!

I hope this helps. Please ask if anything is unclear. :huggles:

M23

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

Darkbeo,

Welcome back to the AutoIt forum! :D

Q1. When I use #AutoIt3Wrapper_Res_Icon_Add the first added icon is added at index -5. So if you declare something like this:

Global Const $iOn_Icon = -5, $iOff_Icon = -6

then you can use this as syntax:

TraySetIcon(@ScriptFullPath, $iOn_Icon)
; or
$hFred = GUICtrlCreateButton("", 243, 8, 24, 24, $BS_ICON)
GUICtrlSetImage($hFred, @ScriptFullPath, $iOff_Icon, 0)

Q2. The easiest way to use added resources within the .exe is Zedna's excellent Resources UDF, which you can find here. But you MUST read the topic carefully and play with the examples until you understand what is going on. The UDF is not difficult, but if you do not get the syntax right you might as well not bother!

I hope this helps. Please ask if anything is unclear. :huggles:

M23

Thanks for the help.

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