Jump to content

My Icon Won't Do What It's Told!


Recommended Posts

Here's the problem.

I have a GUI, and on it is a small graphic indicating that some condition is OK.

It's a preference dialog, and if the user changes the data, the function rechecks

to see it's still okay. So far so good.

When the control is first created, the function is called for an initial check:

$my_img = GUICtrlCreateIcon(@ScriptDir & "\my.dll", 1, 10, 10, 16, 16)
DoTheChange()

This works great, and the "OK" icon is displayed at 16x16. (I don't know how AutoIt knows I want to use the small icon, but I presume it realises that at 16x16, only the small one would fit.)

The trouble comes when I update later. Instead of the small icon being displayed, I get the large version (even if I use a dll with only a small version, it simply enlarges it!) so only the top-left corner is seen. pseudo-code:

func DoTheChange()
    $icon = 1
    if $somecondition then
        $icon = 2; icon index in dll
    endif
    GUICtrlSetImage($my_img, @ScriptDir & "\my.dll", $icon, 0)
endfunc

If I resize the window, or switch to another application and back, it displays perfectly (and at the correct size), but not when initially changed, i.e. when the user changes the data and wants to see the result. That's when I want to see it, too! It's like the gui needs to be "refreshed", but I can't find a function for that.

I've tried simply recreating the control, and that works fine, but because it's on a tab, it now shows through all the tabs, so I'm stuck using GUICtrlSetImage() which doesn't update correctly. I know that resizing the window and back quickly would work, but really, I'd rather not go there. :)

Is there a trick?

-mu

Edited by mr.underperson
Link to comment
Share on other sites

one thing is im not sure if you can actualy do that and use a .dll , as an icon image even though it may be inside it, is it a custom .dll image? or the default one set by the system, if its custom id advise checking out reshack which would allow you to get the icon out

Link to comment
Share on other sites

nonono thatsgreat2345! that part works fine. The function is, in fact, specifically for working with icon resources, hence the "iconID" parameter. :)

GUICtrlSetState! YES!That works!

A quick $GUI_SHOW after flipping the icon does the trick, thanks Valuater!

-mu

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