Jump to content

[SOLVED AFTER LONGG LAST]GUICtrlSetImage doubt


Recommended Posts

it works great if i know the index of the file, viz.,

GUICtrlSetImage(-1,@systemdir & "\setup.exe" ,0)

but i have one exe file which has an icon and i wont be able to get the icon index using res hacker or something

what is the best way to use the application's default icon ??

i tried

GUICtrlSetImage(-1,c:\Program files\12voip.com\12voip.exe, 0) 
GUICtrlSetImage(-1,c:\Program files\12voip.com\12voip.exe, 1)
GUICtrlSetImage(-1,c:\Program files\12voip.com\12voip.exe)
nothing works.

i can check it up from the res hacker but i am just wondering if there is another way i could do it?

actually i am not gonna be using i saw this seems to be possible with a GUIImageList but is it possible with setimage?

Edited by rajeshontheweb
Link to comment
Share on other sites

probably because you forgot to quote the file path.

GUICtrlSetImage(-1,"c:\Program files\12voip.com\12voip.exe")

EDIT: better yet

GUICtrlSetImage(-1,@ProgramFilesDir & "\12voip.com\12voip.exe")
Edited by GEOSoft

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 did think of that but i didnt try it.

actually it is like

$path = xxxx

$index = 0

GUICtrlSetImage(-1, $path, $index)

lemme try adding quotes and get back here.

If you sent it as a string then it should have been fine.

Check it with MsgBox(0, "", $Path) Also try it by setting the icon index to -1

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

here's an example file, can u help me get to do this? http://www.4shared.com/file/110344319/91c3c048/IZArc.html -<edit> no this works with -1 0 & 1 i will post another file ...

<edit>sorry guys, it works, i have to dig deep into where the error is.

my situation is. :

this code works.

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $msg, $i, $btn, $list, $item
    
    GUICreate("My GUI")  ; will create a dialog box that when displayed is centered
    $list = GUICtrlCreateListView("1000000000",10,10,250)
        
    GUISetState()
    
    For $i = -50 to 50
        GUICtrlSetData($item, $i)
        GUICtrlCreateListViewItem($i& "-",$list)
        GUICtrlSetImage(-1 , "C:\Program Files\Izarc\IZarc.exe", $i) = 1        
    Next 

    While 1
        $msg = GUIGetMsg()      
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
EndFunc   ;==>ExampleoÝ÷ Û^MúÊ'¥«aÕÊ'µ¨§°-=Øú趦)^³Ov!+sOv!+qì^jëh×6for $j = -1  to   1 
                ConsoleWrite( @TAB & " | " & $j & " : " & GUICtrlSetImage(-1,Chr(34) & $iconPath[1] & chr(34),$j))
Next

gives an output like this in console

C:\Program Files\IZArc\IZArc.exe,1 | -1 : 0 | 0 : 0 | 1 : 0 | 0

In case of C:\Program Files\Adobe\Acrobat.com\Acrobat.com.exe it works fine value returned is 1 , i can see the icon. where am i possibly wrong???

IT DOES LOOK DUMB TO ME, THERE MUST BE SOMETHING I AM MISSING IF THE ABOVE CODE DOESN HAVE ANY ERRORS IN IT, (WHICH IS LIKELY !) I WILL FINISH MY PROJECT AND POST THE FINAL CODE AS A PACKAGE AND THEN I CAN GET THE ICONS SORTED OUT . thanks a lot for the time taken...

Edited by rajeshontheweb
Link to comment
Share on other sites

Anything that is not a negative number is considered to be an Icon name. When using positive numbers it's looking for an ico by that name, not an icon with that ordinal value.

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

then, considering that i dont have the ordinal number handy is there an easier way of doing it?

but the trouble is

in this piece of code

For $i = -50 to 50
        GUICtrlSetData($item, $i)
        GUICtrlCreateListViewItem($i& "-",$list)
        GUICtrlSetImage(-1 , "C:\Program Files\Izarc\IZarc.exe", $i) = 1       
    Next

i can see -1 , 0 , 1 - these three are working, but the same thing doesnt work in the loop. donno why..

Posted Image

Edited by rajeshontheweb
Link to comment
Share on other sites

then, considering that i dont have the ordinal number handy is there an easier way of doing it?

but the trouble is

in this piece of code

For $i = -50 to 50
        GUICtrlSetData($item, $i)
        GUICtrlCreateListViewItem($i& "-",$list)
        GUICtrlSetImage(-1 , "C:\Program Files\Izarc\IZarc.exe", $i) = 1       
    Next

i can see -1 , 0 , 1 - these three are working, but the same thing doesnt work in the loop. donno why..

First off can you explain why you used GUICtrlSetImage(-1 , "C:\Program Files\Izarc\IZarc.exe", $i) = 1? The = 1 means nothing there.

-50 to 50 will only work if there are 50 icons and there are icons NAMED 0 to 50, Set them by name or by index but NOT by both.

If you just want the default icon then you just need the -1 which is also the default so you don't need to set anything.

GUICtrlSetImage(-1 , "C:\Program Files\Izarc\IZarc.exe")

will do that.

If there are more than one icon then you will have to look at the resources for the file and get the indeces of the icons or at least the count.

If I build an icon library of 50 icons, the indeces will be -1 to -50. If I named those icons they would probably be named 1 to 50 or 0 to 49

If you look in Example scripts I seem to remember someone building a UDF that returned the number of icons in a file.

Edited by GEOSoft

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 was in the process of detecting the icon through a loop in case its not -1 or 0

viz., i would start off at -500 and stop at the first found icon!

using the value GUICtrlSetImage = 1 was to exit the loop if there was any success in creating the icon.

and using -50 to 50 was to check if the icon is elsewhere if not at position -1.

this might be clarified by the screenshot posted above.

Of course, just using GUICtrlSetImage(-1,IZarc.exepath ) does the job seperately but as i mentioned its not working in my loop

there must be something stupid i am doing there, then. but anyways. situation is clear then, there seems no coding error here. but it should be the way i have handled the variable, but its a fact that the above code is just what i have used, there is something catching....

i dont want to wastemore of your time but i would come back to this point when i post the code soon enough....

i am very happy u were able to spend some time on this, and pls help me out when i come back with the full code, thanks mate.

PS: i will check to find that udf!

Edited by rajeshontheweb
Link to comment
Share on other sites

  • 2 weeks later...

BROKE MY HEAD WITH ALL KIND OF STUFF,TRIED TO WRITE VALUES TO CONSOLEWRITE ON ALL POSSIBLE VALUES AND EVERYTIME,

if i use c:\program files\izarc\izarc.exe it would work but if it is returned by the variable it wont work for some reason

just had a second thought and used string compare, it too didnt help , finally i used fileget shortname and it worked wonder!!!!! still donno the reason but the solution was simple to avoid whatever might have been the error . thanks a lot guys. its implemented in my latest uninstall pro package...

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