Jump to content

Resolved - Resource Icons


Recommended Posts

I have added icons as resources. The issue I am having is after the EXE is created the icons are all smaller. They are correct size prior to being compiled. Is there something I am missing? I am only showing snippets below. 

 

 

#AutoIt3Wrapper_Res_Icon_Add=C:\Users\xxxxxx\Documents\AutoIt\images\microsoft_access.ico

If @Compiled Then
    $accessICO = @ScriptFullPath
    $accessICO_id = 201
Else
    $accessICO = @ScriptDir & "\images\microsoft_access.ico"
    $accessICO_id = 1
EndIf

$accessButton = GUICtrlCreateButton("Access", $col1, $row1, $iconH, $iconW, $BS_ICON)
GUICtrlSetImage(-1, $accessICO, $accessICO_id)
GUICtrlSetTip(-1, "Build the Access DB", "Button Description", 1, 1)

Edited by vagabond719
Link to comment
Share on other sites

Hi,

It's hard to see what's wrong if you dont post your entire GUI and the icon file!

We can't test anything with only the snippet you posted.

Edited by Neutro
Link to comment
Share on other sites

Link to comment
Share on other sites

No it's not working properly Trong ;)

The icon size in ressource hacker is 64x64, the icon size in the compiled exe shown in your screenshot is 32x32. If it was working properly the image in each buttons of the software should have the full button size and not just show in the middle as 32x32.

I think it's a bug from the GUICtrlSetImage function. Try it out with this code:

#Region    ;************ Includes ************
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#EndRegion    ;************ Includes ************

$test = GUICreate("test", 600, 300)

Global $hIcon1 = GUICtrlCreateIcon("", Default, 20, 20, 240, 240)

Global $button1 = GUICtrlCreateButton("", 300, 20, 240, 240, $BS_ICON )

GUICtrlSetImage($hIcon1, "shell32.dll", 22)

GUICtrlSetImage($button1, "shell32.dll", 22)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

When GuiCtrlSetImage is used on an icon it uses the biggest size possible whereas when used on a button it uses 32x32 or 16x16 only.

Edited by Neutro
Link to comment
Share on other sites

this is a known issue and will not be fixed. see Trac ticket.

workaround: use only 32x32 icons.

and in this case, it will make the GUI look a lot nicer. just make the buttons slightly smaller. and in general, try to use a more consistent icon design for grouped buttons of similar functionality.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

As explained here you can solve this problem using ResourcesEX.au3

Changes made to your script were using this AutoIt3Wrapper to add icon files:

#AutoIt3Wrapper_Res_File_Add=images\unix_vvw_icon.ico, RT_ICON, UNIX, 0

and this function to set the icon in the button when using compiled script:

_Resource_SetToCtrlID(-1, 'UNIX', $RT_ICON)

You need to put the attached file ResourcesEx.au3 in your AutoIT\include folder for this to work.

A working version can be found in the EOR.zip filed joined as well.

Enjoy ;)

Edited by Neutro
Link to comment
Share on other sites

6 minutes ago, Neutro said:

As explained here you can solve this problem using ResourcesEX.au3

Changes made to your script were using this AutoIt3Wrapper to add icon files:

#AutoIt3Wrapper_Res_File_Add=images\unix_vvw_icon.ico, RT_ICON, UNIX, 0

and this function to set the icon in the button when using compiled script:

_Resource_SetToCtrlID(-1, 'UNIX', $RT_ICON)

You need to put the attached file ResourcesEx.au3 in your AutoIT\include folder for this to work.

A working version can be found in the EOR.zip filed joined as well.

Enjoy ;)

Thanks, for the assist. Neutro I will look at the ResourcesEx.au3 more. 

Link to comment
Share on other sites

You're welcome but dont bother with ResourcesEx for your script, i already fixed it ;)

Just download the EOR.zip file joined in my previous reply, put ResourcesEx.au3 in your AutoIT include folder, compile EOR2.au3 and it works ;)

Edited by Neutro
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...