Jump to content

GUISetIcon example broken?


rilian
 Share

Go to solution Solved by UEZ,

Recommended Posts

I was looking at the example code for GUISetIcon. It is the same in the help file as it is in the online documentation found here: http://www.autoitscript.com/autoit3/docs/functions/GUISetIcon.htm

Reproduced here in full:

#include <GUIConstantsEx.au3>

Example()

Func Example()
Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\icons\filetype1.ico"
Local $msg

GUICreate("My GUI new icon") ; will create a dialog box that when displayed is centered

GUISetIcon($sFile) ; will change icon

GUISetState(); will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
EndFunc   ;==>Example
 
 
 

The line that sets the path:

Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\icons\filetype1.ico"

...Specifies "iconsfiletype1.ico" as the file to use as a sample. This file does not exist in my install. The folder does exist and contains 4 files: au3.ico, au3script_v9.ico, au3script_v10.ico and filetype-blank.ico. 

Thus, this example does not work w/o modification. When I changed the line above to:

Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\icons\au3.ico"

The icon was set and worked properly as expected. Is this file missing from the install? Has it been replaced? Is my install incorrect somehow and missing this file or does the example need to be updated? 

Thanks.

p.s. I apologize if this is in the wrong forum. It seemed the best place a the time.

Link to comment
Share on other sites

  • Solution

Seems to be a bug (not updated version) in the help file.

Use this line instead:

Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\icons\filetype-blank.ico"

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

sorry to jump onto this topic however i believe its relevant..

I have a dashboard used by many users on the network however i want to set the icon file, using the example it uses regread however am i correct in saying i could just like $sFile to my ico, whatever its location e.g networkdrivedocumentsimages and set it that way?

Link to comment
Share on other sites

The regread is only getting the installation directory for where you installed AutoIt, it has nothing to do with the GUISetIcon function itself, you only need a path and filename to assign the icon to the control or GUI.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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