forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


bsGetIcon DSU ( Get any file's associated icon )
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 6 Units
View previous topic :: View next topic  
Author Message
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Sun Sep 19, 2010 12:45 am    Post subject: bsGetIcon DSU ( Get any file's associated icon ) Reply with quote


bsGetIcon DSU

    This unit contains a function @bsGetIcon() which retrieves the associated icon from any file.

Features:

    - Freeware
    - User-specific associations have priority over system default
    - The file doesn't have to exist
    - Index-number of an icon can be specified
    - Number of icons in a file can be returned
    - Tested on WinXP and Windows 7 Ultimate
    - Sample script included

Screenshot:



Usage:

For example:
Code:

  %%File = myFavoriteSong.mp3

  list add,List1,%%File|@bsGetIcon(%%File)

  ----------------------------------------

  info Icon for mp3-files is located:  @bsGetIcon(*.mp3)



    To see the Download, you must be logged in.

Have fun.

bornSoft


Last edited by bornsoft on Sat Sep 25, 2010 4:55 pm; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Sun Sep 19, 2010 5:35 am    Post subject: Reply with quote

Nice BS Thumbs Up
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Sun Sep 19, 2010 1:06 pm    Post subject: Reply with quote

Yes, very nice and very useful!
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Sun Sep 19, 2010 4:38 pm    Post subject: Reply with quote

Hi,

this was for the first time i posted with an attachment.

Now i have a question about that:

If i'm not logged in, the attachment doesn't appear. I've made download-link then and if i'm not logged in i get a message that i have no permission to download this file.

Maybe it is intended, that you are only permitted to download a file if you're logged in, but there are dozens of files around here i can download with no problems without to login.

Maybe i'm doing something wrong?

Thanks. bornSoft
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Sun Sep 19, 2010 11:20 pm    Post subject: Reply with quote

That's how it works in the forum.

You need to upload it to the files section.

Login, then look under the "Authors" section of the Site Navigation menu at the left hand column of the main page and click on "New File" and fill out the necessary info to upload your file.
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Mon Sep 20, 2010 12:26 am    Post subject: Reply with quote

BTW Bornsoft, have you considered adding an icon count function e.g "@bsGetIconCount()" which would return the number of icons in the resource Wink

This would be handy for someone to browse all the icons in a file containing multiple icons by looping through the file with "@bsGetIcon(<file>|<i>)" where <i> increments up until equal with "@bsGetIconCount(<file>)"

Here is the code if you want to add it.

Code:
#DEFINE FUNCTION,bsGetIconCount

:bsGetIconCount
REM %1 is the filename
      LOADLIB shell32.dll
      %X = @lib(shell32.dll,ExtractIconEx,INT:,STR:%1,INT:-1,NIL:,NIL:,INT:0)
      FREELIB shell32.dll
   exit %X


Just a thought Very Happy
Back to top
View user's profile Send private message Send e-mail
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Mon Sep 20, 2010 4:16 am    Post subject: Reply with quote

Hi Aslan,

I've added the wanted feature.

Now with %c = @bsGetIcon(<File>,count) you get the number of icons returned.

I already use the ExtractIconEx function in this unit to check if an icon is in the file but didn't utilize the result.

bornSoft
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Mon Sep 20, 2010 4:39 am    Post subject: Reply with quote

hmmm.... now it says your download doen't exist anymore No clue

Edit: Ah I see what you mean by needing to be logged in to download a file....
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Mon Sep 20, 2010 4:57 am    Post subject: Reply with quote

Here is a modified version of your example to show the multiple icons in a single resource and why I recommended the "Count" option.
Code:
#                                                                                         
#       Function @bsGetIcon() by bornSoft (c)2010                                         
#       -----------------------------------------                                         
#                                                                                         
#       Usage:   %i = @bsGetIcon( <FILE> [ , <INDEX> ] )                                 
#                                                                                         
#                LIST ADD,BITLIST1 , <FILE> @FSEP() @bsGetIcon( <FILE> [ , <INDEX> ] )   
#                                                                                         
#                info @bsGetIcon( <FILE> , COUNT )                                       
#                                                                                         
#       This function returns the file that contains the associated icon to <FILE>.       
#       The icon index or offset returned is separated by the current fieldseparator.     
#                                                                                         
#       If <FILE> is an executable or other file that contains icon(s) itself, this       
#       one is used instead - otherwise the associated executable is obtained.           
#       The user-specific associations have priority over system default icons.           
#                                                                                         
#       For unknown filetypes cabview.dll index 1 is returned.                           
#                                                                                         
#       If <FILE> contains more than one icon, the index-number of the icon can be       
#       specified in the optional second parameter.                                       
#                                                                                         
#       if <FILE> is a directory, shell32.dll|3 is returned.                             
#                                                                                         
#       The specified files or directories for <FILE> do not have to exist, they may     
#       be only an extension with a wildcard character. (*.doc) or (Any).                 
#                                                                                         
#       To obtain the number of icons within the file, provide COUNT as second           
#       argument to the function. Note: In this case <FILE> must be an existing file.     
#                                                                                         
#       You require VDS 6 or higher ;-)                                                   
#                                                                                         
#       Modified by Aslan to show to show multiple icons in a single resource                                                                             

#INCLUDE bsGetIcon.dsu

option decimalsep,.

  %%Mask = "*"
  %%FolderIcon = @bsGetIcon(x)

  DIALOG CREATE,bsGetIcon.dsu - Example  -  bornSoft ©2010,-1,0,633,579
  DIALOG ADD,STYLE,Center,,,C,,
  DIALOG ADD,TEXT,T1,10,10,,,Path to list files from
  DIALOG ADD,BITCOMBO,E1,28,8,404,24,,,SORTED,CLICK
  DIALOG ADD,BUTTON,select,27,421,24,24,<
  DIALOG ADD,TEXT,T2,34,475,,,Filter extensions
  DIALOG ADD,EDIT,E2,31,572,36,20,%%Mask
  DIALOG ADD,TEXT,T3,65,432,,,List Directories
  DIALOG ADD,CHECK,DirCheck,64,410,16,18
  DIALOG ADD,TABLE,Table1,94,8,616,228,File|Icons,,DBLCLICK
  DIALOG ADD,BUTTON,List,62,8,90,24,List now,,DEFAULT
  DIALOG ADD,BUTTON,Ext,61,128,90,24,Check extension,Get icon for an extension
  DIALOG ADD,TEXT,FileExt,64,232,92,18,*.*,,Center
  DIALOG ADD,LINE,Line1,372,548,64,64
  DIALOG ADD,SHAPE,Shape1,374,550,60,60,WHITE,WHITE
  DIALOG ADD,BITMAP,Icon,388,564,32,32,,,STRETCH
  DIALOG ADD,BUTTON,Exit,525,534,90,24,Exit
  DIALOG ADD,STATUS,Stat
  DIALOG ADD,TABLE,TABLE2,362,8,508,139,,,CLICK
  DIALOG ADD,LINE,LINE2,514,9,612,2
  DIALOG ADD,TEXT,icoInFile,337,17,,,Icons in File with Index (Click to select)
  DIALOG SHOW

  list add,E1,@windir(s)|%%FolderIcon
  list seek,E1,0

  #    Set Listview style to "ICON" (3)                   
#  %x = @sendmsg(@winexists(~Table1),@SUM($1000,142),3,0)
  %x = @sendmsg(@winexists(~Table2),@SUM($1000,142),3,0)

:Evloop
  wait event
  goto @event()

:E1Click
  list clear,Table1
  goto ListButton

:ExtButton
  %x = @input("File extension (e.g. txt) or empty for directory")
  if %x
    dialog set,Icon,
    %i = @bsGetIcon(*.%x)
    dialog set,stat,%i
    dialog set,FileExt,@upper(%x)
    dialog set,Icon,%i
   else
    dialog set,Icon,
    %i = @bsGetIcon(folder)
    dialog set,stat,%i
    dialog set,FileExt,FOLDER
    dialog set,Icon,%i
  end
  goto EvLoop

:Table1DblClick
  %x = @item(Table1)
  option fieldsep,@tab()
  parse "%x", %x
  option fieldsep,"|"
  if %x
    %i = @bsGeticon(@item(Table1))
    dialog set,FileExt,@upper(@ext(%x))
    %n = @bsGetIcon(%x,Count)
    list clear,table2
   %i = 0
   If @greater(%n,0)
     Repeat
      List add,Table2,%i|@bsGetIcon(%x,%i)
      %i = @succ(%i)
     Until @equal(%i,%n)
   End
   dialog set,icon,@bsGetIcon(@item(Table1))
   %E = @event()
  end
  goto EvLoop
 
:Table2Click
  %F = @item(Table1)
  %i = @index(Table2)
  dialog set,Icon,@bsGetIcon(%x,%i)
  goto evloop
 
:SelectButton
  if @not(%D)
    %D = @item(E1)
  end
  Directory change,%D
  %D = @dirdlg(,%D)
  if %D
    list clear,Table1
      gosub AddFolder
    goto ListButton
  end
  goto EvLoop

:ListBUTTON
  dialog cursor,wait
  %%Time = @datetime()
  list clear,Table1
  dialog clear,icon
  directory change,@item(E1)
  #    Get all files (and subdirs) from the desired path 
  %L = @new(list)
  if @dlgtext(DirCheck)
    list filelist,%L,@dlgtext(E2),dahrsv
  end
  list filelist,%L,@dlgtext(E2),ahrsv
  #    Now add all files with their icon 
  %c = @count(%L)
  repeat
    %F = @item(%L,0)
    %E = @ext(%F)
    if %F
      Dialog set,stat," "%c files:  %F
      #    Avoid a period behind no-extension files and folders 
      if %E
        list add,Table1,@name(%F).%E@tab()@bsGetIcon(%F,count)|@bsGetIcon(%F)
       else
        list add,Table1,@name(%F)@tab()@bsGetIcon(%F,count)|@bsGetIcon(%F)
      end
      list delete,%L
    end
  until @not(%F)
  list close,%L
  dialog set,stat,Finished. @count(Table1) Files (%c)@tab()Duration:  @datetime("hh:nn:ss",@fsub(@datetime(),%%Time))
  dialog cursor
  goto evloop
 
:ExitBUTTON
:Close
  exit

:AddFolder
  #    Add new folder to bitcombo and remove duplicates   
  list add,E1,%D
  %x = @new(list,sorted)
  list assign,%x,E1
  list clear,E1
  repeat
    %i = @item(%x)
    if %i
      list add,E1,%i|%%FolderIcon
      list delete,%x
    end
  until @not(%i)
  list close,%x
  list seek,E1,0
  %x = @match(E1,%D,exact)
  %x = @index(E1)
  list seek,E1,%x
  exit
Back to top
View user's profile Send private message Send e-mail
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Mon Sep 20, 2010 5:35 am    Post subject: Reply with quote

Pretty cool!

I could add an argument "DESC" to get filedescriptions for extensions.
And "SELF" for files that are associated but have own icons.
Also "BMP" would be possible to show miniatures from bitmaps.

... but not today ...
Back to top
View user's profile Send private message Visit poster's website
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Sat Sep 25, 2010 4:51 pm    Post subject: Reply with quote

@Aslan

Hi, I'm trying to improve the dsu. So i have a question to you as the author of extTable.dsu:

As you surely noticed, in the example there is an ugly black border on the right side of every icon. Do you have an idea to avoid this?
I guess, it has something to do with the imagelist of the table, but may be i can do something within the dsu itself.

Thanks in advance.

bornSoft

btw: After one week I still have no response to my request for an author-account from VDSworld.
.
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Sun Sep 26, 2010 1:59 am    Post subject: Reply with quote

I think you are getting this from older icons or the effect of reducing a 32x32 icon to 16x16. You might want to add a "small|large" option to your DSU. At first I though it was a masking issue but after examining those icons, the black is supposed to be the shadow.

May I suggest that you use shell32.dll|0 for unknown file types and if you can control the icon for an .exe that doesn't have its own icon try taskmgr.exe|1

As for an author account, I didn't know you needed one. But I could be wrong.

After you logon to VDSWORLD, do you see the link highlighted in the attached image?
Back to top
View user's profile Send private message Send e-mail
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Sun Sep 26, 2010 2:31 am    Post subject: Reply with quote

How can I direct to use small icons and not to scale large ones?

I agree to use shell32.dll|0 for unknown filetype.
Taskmgr.exe|1 and shell32.dll|2 are the same icons, at least on WinXP. Correct me, if i'm wrong, can't test on Win7 at the moment.

Currently I'm completely rewritng the dsu, among others there will be a command to set custom icons for special files or filetypes only for the program that uses the unit.

Edit: Thanks for the screenshot, but these subitems don't show up if i'm logged in.
There is only one point: "Activate Author Account" and if i click it, the following message is displayed (since last monday):

Quote:
Your activation request is still pending, please be patient.
If you have tried to activate your author account more then 48 hours ago, and you still don't have received any response, please contact us

On thursday i wrote a message, but still no response.
.
Back to top
View user's profile Send private message Visit poster's website
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Sun Sep 26, 2010 3:08 am    Post subject: Reply with quote

Quote:
How can I direct to use small icons and not to scale large ones?


Here is a snippet from extTable.DSU that may help you.

Icon Extraction from "IMAGELIST ICONFROMFILE,< ImgList >,<image>,<iIndex>,[<type>]"
Note: <type> can be Small or Large {Default is Small}

Code:
If @equal(%5,Large)
       %X = @lib(shell32.dll,ExtractIconEx,INT:,INT:@addr("%3"),INT:%4,INT:@addr("%I"),NIL:,INT:1)
      else
       %X = @lib(shell32.dll,ExtractIconEx,INT:,INT:@addr("%3"),INT:%4,NIL:,INT:@addr("%I"),INT:1)
      end


Well it looks like on Vista/Win7 Taskmgr.exe|1 is newer...sorry

BTW - I noticed in your Readme that it requires VDS 6 or higher. I see your example needs VDS 6 because you're using @new(). Is there VDS 6 specific code in the DSU itself? If not, this would be a nice DSU for VDS 5.x users also Wink
Back to top
View user's profile Send private message Send e-mail
bornsoft
Contributor
Contributor


Joined: 19 Feb 2009
Posts: 113
Location: Germany

PostPosted: Sun Sep 26, 2010 9:31 am    Post subject: Reply with quote

First thank you, Aslan.

I tried your code as following:
Code:

  %3 = @windir(s)\shell32.dll
  %4 = 0
  %5 = Large
  %I = @binary(DWORD,0)
  loadlib Shell32.dll
      If @equal(%5,Large)
          %X = @lib(shell32.dll,ExtractIconEx,INT:,INT:@addr("%3"),INT:%4,INT:@addr("%I"),NIL:,INT:1)
        else
          %X = @lib(shell32.dll,ExtractIconEx,INT:,INT:@addr("%3"),INT:%4,NIL:,INT:@addr("%I"),INT:1)
      end
  freelib shell32.dll

  info x = %X@cr()@cr()I = @val(%I)
  exit


Now I've got a handle, but what to do with it?
The return of my dsu should be like "c:\windows\system32\shell32.dll|0".

I use string-functions of VDS6 (@strslice , @strrep) and the new version takes also advanage of the @new(list) function, which in my opinion is the best thing in vds6 at all.
It should be possible, to do it with VDS5 also, but this would require some extrafunctions within the dsu, which also would be a speed-issue. And a static list would be nessesary. All in all I think why workaround things, if they can be done simply, for that VDS6 was made. And do you think, there are really potential users of my dsu still on VDS5?

Btw: Is there a way to prevent line-wrapping within code-tags here in the forum?

Greetings and have nice sunday.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 6 Units All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group