Jump to content

Buttons with icons from .ico files


 Share

Recommended Posts

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:

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!"

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

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