Jump to content
Sign in to follow this  
shEiD

Buttons with icons from .ico files

Recommended Posts

shEiD

Is it possible to make buttons with icons from simple .ico files? I've tried it, and it does not work? The example in "Help" uses shell32.dll and it works, but why it does not work with .ico, or .icl files? I've tried with a single image .ico files, multi image .ico files, .icl and I even tried making a .dll file with GConvert5 soft, it didn't work either. wth? :)

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
    Local $msg
    GUICreate("My GUI")  ; will create a dialog box that when displayed is centered
    GUICtrlCreateButton("my picture button", 10, 20, 40, 40, $BS_ICON)
    
    ; GUICtrlSetImage(-1, "shell32.dll", 22) ; <- WORKS
    
    ; GUICtrlSetImage(-1, @ScriptDir & '\feed.ico') ; <- DOES NOT WORK !?!?!
    
    ; GUICtrlSetImage(-1, @ScriptDir & '\feed.ico', 1) ; <- DOES NOT WORK !?!?!
    
    GUISetState()
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>Example

Does GUICtrlSetImage supports only shell32.dll? :idea:

Share this post


Link to post
Share on other sites
Yashied
Makaule

It may sound strange, but where you got your *.ico file? I hope you didnt rename simple image to icon, for example from Test.bmp to Test.ico. I have tested and all works fine, just you should declare image width and height, in case it would be bigger then buttom, it could be resized.

Edited by Makaule

Share this post


Link to post
Share on other sites
shEiD

Works fine for me. Maybe a problem with the icon?

Huh... :idea:

What can be wrong with the icon? Like I said, I've tried numerous (probably > 50) icons in various formats. The only thing that works is shell32.dll. I'm baffled.

Could you, please, provide me with a working sample, icon?

Share this post


Link to post
Share on other sites
shEiD

It may sound strange, but where you got your *.ico file? I hope you didnt rename simple image to icon, for example from *.bmp to *.ico.

Off course not :idea: Some are extracted from exe, etc, some are from the internet. "Proper" .ico files, if I could say so.

e.g. this icon: link I tried this one as it comes, with 5 sizes inside, and even edited the icon with IcoFX, deleted 4 sizes, left only 48x48 - didn't work either way.

Edited by shEiD

Share this post


Link to post
Share on other sites
Makaule

Just for test, could you try download any *.ico from http://www.iconarchive.com/ ? I would also check is your *.au3 file in corect place (same folder with *.ico). Which version of AutoIt are you using? Maybe its some kind of "glitch" of older version?

Share this post


Link to post
Share on other sites
Yashied
enaiman

Works for me too.

Here is an icon if that's what you want:

Save.ico


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
shEiD

Just for test, could you try download any *.ico from http://www.iconarchive.com/ ? I would also check is your *.au3 file in corect place (same folder with *.ico). Which version of AutoIt are you using? Maybe its some kind of "glitch" of older version?

Tried an icon fro your link - no go. Tried putting icons in the same folder - no go. Tried providing full path to file, partial, either way - no go. I'm actually out of ideas what else to try, by this time.

Runing autoit 3.3.6.0 ( not beta)

Windows 7 Ultimate.

Share this post


Link to post
Share on other sites
shEiD

GUICtrlSetImage(-1, "C:\Program Files\AutoIt3\Icons\au3.ico")

Works?

:idea: WORKS! whatthehell? How that "C:\Program Files\AutoIt3\Icons\au3.ico" is different from any other .ico files?

Share this post


Link to post
Share on other sites
shEiD

Works for me too.

Here is an icon if that's what you want:

Save.ico

And this icon does not work.

/me bangs his head onto the wall...

Honestly, I'm going crazy here. How come, one single icon ("C:\Program Files\AutoIt3\Icons\au3.ico") works, and ANYTHING else doesn't? This is a really bad joke :idea:

Edited by shEiD

Share this post


Link to post
Share on other sites
Makaule

Well i will atach Test.au3 with *.ico, test it. It would use 2 ways of adding ico to buttom. Test it.

TestButton.rar

Share this post


Link to post
Share on other sites
shEiD

Well i will atach Test.au3 with *.ico, test it. It would use 2 ways of adding ico to buttom. Test it.

First of all, Thank You.

I am going slightly crazy... I tried your example and it worked. Further more, my scripts started showing icons on buttons too. I have no f***in idea whats happening...(apologies). I was trying to do this for 2 hours probably before posting here. Then what, an hour till your post with an example. I just went through all my peaces of code, where I did tests, and, as it seems, the paths to the files are/were correct, (well, that's the only logical explanation, why would it not work before, and it does now...), so - I am out of ideas and words, what just happened.

I will go thoroughly through all the code peaces again, after some 2-3 cigarettes, just to make sure, I'm not going mental... :idea:

Anyway, thank you again.

Share this post


Link to post
Share on other sites
GEOSoft

I used to have the odd script fail for no apparent reason and after a system restart they would be fine. I just put it down to the Windows File Cache and ignored it after that.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites
shEiD

I used to have the odd script fail for no apparent reason and after a system restart they would be fine. I just put it down to the Windows File Cache and ignored it after that.

I just reinstalled my windows, twice, actually.

But, take a a look at this:

GUICtrlCreateIcon(@ScriptDir & "\feed-icon-orange.ico", -3, 100, 0, 48, 48)

I repeatedly ran same script from scite 20 times in a row:

Posted Image Posted Image

13 times from 20, icon was displayed properly (with transparency), 7 times from 20, it was without transparency.

A simple copy of the same script and icon: 20 times from 20 it displays icon incorrectly - without transparency.

Now this, sucks... I would go crazy for hours and hours, scouring help file and forums, how to enable transparency. Does this kind of stuff can be Windows File Cache fault as well?

Edit.

Well, I tried to change up the styles, and it seems the culprit was $WS_VISIBLE in gui styles. But anyway, how come, sometimes it was displaying icons properly and sometimes - no?

Edited by shEiD

Share this post


Link to post
Share on other sites
trancexx

Are you familiar with Occam's razor?

What's your system (emphasizing bitness)?


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
shEiD

Are you familiar with Occam's razor?

What's your system (emphasizing bitness)?

Specs:

OS:     MS Windows 7 Ultimate 32-bit
CPU:    Intel Core i7 860  @ 2.80GHz    27 °C
        Lynnfield 45nm Technology
MB:     Gigabyte GA-P55M-UD2
RAM:    G-Skill 4.0GB Dual-Channel DDR3 @ 666MHz  9-9-9-24
GPU:    Westinghouse LVM-37w3se @ 1920x1080
        BFG 640MB GeForce 8800 GTS (nVidia) 55 °C
HDD:    80GB INTEL SSDSA2M080G2GC
        500GB SAMSUNG SAMSUNG HD501LJ   28 °C
        1500GB Seagate ST31500341AS 35 °C
        2000GB Western Digital WDC WD20EADS-00R6B0  33 °C
Opt:    No optical disk drives detected
Audio:  Realtek High Definition Audio

Share this post


Link to post
Share on other sites
trancexx

Make a new folder. Add exact same script you run (that fails) and icon file to it. Compress and upload. Attach.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
shEiD

Make a new folder. Add exact same script you run (that fails) and icon file to it. Compress and upload. Attach.

Here is the script and icons. Now at start, icons always displayed without transparency. Only after you click mail icon, the toolbar repaints the icons properly, with transparency.

gui.rar

Share this post


Link to post
Share on other sites
trancexx

Remove $WS_VISIBLE style from the GUI.


♡♡♡

.

eMyvnE

Share this post


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
Sign in to follow this  

×