Sign in to follow this  
Followers 0
momar33

Icon not showing up if created after GuiSetState()

5 posts in this topic

If try to create an icon after GuiSetState() it doesn't show up.

Here is some code: (you may have to change the exe being used)

#include <GUIConstants.au3>

Global $button[6]
Global $icon[6]

$GUI = GUICreate("My GUI")
$icon1 = GUICtrlCreateIcon("shell32.dll" , 4,4,4,16,16)
;GUICtrlSetImage (-1, "C:\Program Files\Mozilla Firefox\firefox.exe")


GUISetState()

$icon2 = GUICtrlCreateIcon("",Default,32,4,16,16)
GUICtrlSetImage (-1, "C:\Program Files\CCleaner\ccleaner.exe")
GUICtrlSetState(-1,$GUI_SHOW)


While 1
    $m = GUIGetMsg()
  
    If $m = -3 then Exit
WEnd

I did discover that if I set the file name to "shell32.dll" first then change the image it works fine, but i would prefer to not have to set the filename first.

Share this post


Link to post
Share on other sites



Weird...you shall post it in Bugs forum...


I can do signature me.

Share this post


Link to post
Share on other sites

I discovered that with an app I made to draw a graphic. If you use GUICtrlSetGraphic($ControlID,"blah","blah") after GuiSetState then it won't work...

Examples:

Won't show the graphic:

#include <GUIConstants.au3>
GUICreate("Form1", 288, 299, 241, 122)
$Graphic = GUICtrlCreateGraphic(0, 0, 281, 297)
GUISetState(@SW_SHOW)
GUICtrlSetGraphic($Graphic,$GUI_GR_LINE,281,297)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Will show the graphic:

#include <GUIConstants.au3>
GUICreate("Form1", 288, 299, 241, 122)
$Graphic = GUICtrlCreateGraphic(0, 0, 281, 297)
GUICtrlSetGraphic($Graphic,$GUI_GR_LINE,281,297)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Now this will only show the graphic that was underneath the splashtext

#include <GUIConstants.au3>
GUICreate("Form1", 288, 299, 241, 122)
$Graphic = GUICtrlCreateGraphic(0, 0, 281, 297)
GUISetState(@SW_SHOW)

SplashTextOn("","splash text",200,200,-1,-1,1)
Sleep(700)
GUICtrlSetGraphic($Graphic,$GUI_GR_LINE,281,297)
SplashOff()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

:)

Share this post


Link to post
Share on other sites

If try to create an icon after GuiSetState() it doesn't show up.

May I ask why you want to do it this way?

Anyways, can you do this instead?

$icon1 = GUICtrlCreateIcon("shell32.dll" , 4,4,4,16,16)
;GUICtrlSetImage (-1, "C:\Program Files\Mozilla Firefox\firefox.exe")
$icon2 = GUICtrlCreateIcon("",Default,32,4,16,16)
$icon3 = GUICtrlCreateIcon("",Default,60,4,16,16)

GUISetState()

GUICtrlSetImage ($icon2, "notepad.exe")
GUICtrlSetState($icon2, $GUI_SHOW)

GUICtrlSetImage ($icon3, "calc.exe")
GUICtrlSetState($icon3, $GUI_SHOW)

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites

From the AutoIt manual page for GUICtrlCreateIcon ..

"To update the icon after the dialog box is displayed use GUICtrlSetImage"

;o)

(or


nothing is foolproof to the sufficiently talented fool..

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  
Followers 0