AutoHotkey Community

It is currently May 27th, 2012, 12:45 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: March 21st, 2010, 1:38 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
Hi.

I'm working on a script that displays an icon based on a path to a file specified by the user. In most cases the specified files are .exe files and contains an .ico file which is then used as a picture. But sometimes the specified file does not have a useable image file, and it just looks stupid without any picture. That is why i am trying to figure out a way to check whether a file contains a useable image file or not, so that if the specified file does not contain an image file i could just use some other predetermined icon.

Any ideas on how to check if a given path contains a useable picture for Gui, add, picture?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2010, 2:27 pm 
check for the width and if 0 use default ico ?


Code:
Gui, Add, Picture, Icon hwndpic vmypic, C:\my.exe
ControlGetPos, ,,width,height,,ahk_id%pic%
if width=0
GuiControl,,mypic,  c:\icos\default.ico


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2010, 5:18 pm 
Offline

Joined: July 22nd, 2008, 1:49 pm
Posts: 151
A nice idea, but that does not quite work, since i use the following code:

Code:
Gui, 1:Add, Picture, x%iconx% y%icony% w25 h25 icon1 AltSubmit BackgroundTrans hwndpic vmypic, %whichicon%
ControlGetPos,,, iconwidth,,,ahk_id%pic%
msgbox %iconwidth%
if iconwidth = 0
Guicontrol,, mypic, key21.ico


The h25 is preset to make sure its the right size, so its width is still 25 even if there is no picture displayed. Also it seems to display the start of the path that was used... Thanks for your idea though :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: chaosad, jrav, MSN [Bot] and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group