View previous topic :: View next topic |
Author |
Message |
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sat Aug 09, 2003 3:51 pm Post subject: Obtain icon for a file (to use with a BITLIST or TABLE) |
|
|
Here's some code I worked on for a while... I thought I would share it with
everyone else. Basically what it does is look in the HKEY_CLASSES_ROOT
key and find the subkey pertaining to the extension of the selected file.
It finds the file type from there and looks in the right subkey again and
finds the DefaultIcon subkey. Then it does a little processing to add the
icon to the list. It also has support for if there is not a valid icon, you just
need to have the OTHER.BMP ... you can download the one I used here.
Enjoy!
Code: | Title File Icons
#RESOURCE ADD,BITMAP,other.bmp
DIALOG CREATE,File Icons,-1,0,265,160
DIALOG ADD,BITLIST,BITLIST1,7,8,180,144
DIALOG ADD,BUTTON,Add,7,194,,,Add
DIALOG ADD,BUTTON,Exit,36,194,64,24,Exit
DIALOG SHOW
:Evloop
wait event
goto @event()
:AddBUTTON
%F = @filedlg("All Files (*.*)|*.*")
if @both(@ok(),@file(%F))
%%ext = @ext(%F)
if @unequal(%%ext,"exe")
%%type = @regread(ROOT,"."%%ext,,FILE_TYPE_DOES_NOT_EXIST)
if @unequal(%%type,FILE_TYPE_DOES_NOT_EXIST)
%%icon = @regread(ROOT,%%type\DefaultIcon,,FILE_ICON_DOES_NOT_EXIST)
else
%%icon = #other.bmp
end
else
%%icon = %F
end
if @not(@path(%%icon))@equal(%%icon,FILE_ICON_DOES_NOT_EXIST)
list add,bitlist1,@name(%F)|#other.bmp
else
list add,bitlist1,@name(%F)|%%icon
end
end
%%icon = ""
goto evloop
:ExitBUTTON
:Close
exit |
EDIT: Changed DEFAULT.BMP to OTHER.BMP because if you clicked on a
DSC file it used the icon "default.ico" and that must internally conflict with
"default.bmp"
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1562
|
Posted: Sat Aug 09, 2003 4:07 pm Post subject: |
|
|
Really nice work, worked great
|
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat Aug 09, 2003 8:43 pm Post subject: |
|
|
Worked here on ME with the exception that one icon did not show up
at all. I didn't bother checking to see why it didn't show up. I'll
eventually take a closer look.
I want to thank you for coming up with this, as I didn't know this was
possible in VDS 5, and I was using a set of icons for such things as
this. Now I can dump all the extra icons!
Thanks FreezingFire!
-Garrett
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sat Aug 09, 2003 10:14 pm Post subject: |
|
|
There's a few problems that I plan to get fixed, such as the one with the
bug report I posted.
I was using the code you had in your GT-FileSearch example, and I was
saying to myself, "There has to be a better way"... so I did a little thinking
and came up with this
Thanks for all your guys support.
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sun Aug 10, 2003 12:18 am Post subject: |
|
|
Yeah, the file search uses the icons I was talking about. I'm glad
someone's noggin was working around here, as I sure didn't think
to even check into this idea you came up with.
-Garrett
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Sat Jul 30, 2005 10:04 am Post subject: |
|
|
hello everyone...
Great codes...
I realized that the icons of files LNK were not listed...
Is it possible to do it ?
Thanks a lot
|
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat Jul 30, 2005 6:12 pm Post subject: |
|
|
I believe so.
Use @file(<path and shortcut here>,L) to get the path and file that the
shortcut points to. It probably shows up in the shortname form, but that
won't hamper what you need to do.
-Garrett
|
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Sun Jul 31, 2005 1:08 am Post subject: |
|
|
Easy... very easy...
Thanks Garrett
|
|
Back to top |
|
|
uvedese Contributor
Joined: 21 Jan 2006 Posts: 169 Location: Spain
|
Posted: Sun Mar 19, 2006 8:00 pm Post subject: |
|
|
Creo que con este código basado en el código de FreezingFire soluciona todos los problemas
Code: |
Title File Icons
#RESOURCE ADD,BITMAP,otro.bmp
DIALOG CREATE,File Icons,-1,0,265,160
DIALOG ADD,BITLIST,BITLIST1,7,8,180,144
DIALOG ADD,BUTTON,Add,7,194,,,Add
DIALOG ADD,BUTTON,Exit,36,194,64,24,Exit
DIALOG SHOW
:Evloop
wait event
goto @event()
:AddBUTTON
%F = @filedlg("All Files (*.*)|*.*")
if @both(@ok(),@file(%F))
%%ext = @ext(%F)
if @equal(%%ext,"exe")
%%icon = %F
else
%a = @regread(HCR,.%%ext)
if %a
%b = @regread(HCR,%a\DefaultIcon)
if @null(%b)
%b = @regread(HCR,%a\shell\open\command,)
if %b
%%icon = %b
else
%%icon = #otro.bmp
end
else
%%icon = #%b
end
else
%%icon = #otro.bmp
end
end
end
list add,bitlist1,@name(%F)|%%icon
goto evloop
:ExitBUTTON
:Close
exit |
Description: |
|
Download |
Filename: |
Obtain icon for a file.dsc |
Filesize: |
920 Bytes |
Downloaded: |
1899 Time(s) |
|
|
Back to top |
|
|
DaveR Valued Contributor
Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Tue Apr 11, 2006 2:42 pm Post subject: |
|
|
Interesting changes there, uvedese. Specifically the use of the icon from the default program that opens the file.
Interesando cambios allí, uvedese. Específicamente el uso del icono del programa del defecto que abre el archivo.
_________________ cheers
Dave |
|
Back to top |
|
|
GregLand Valued Contributor
Joined: 15 Jun 2004 Posts: 212 Location: FRANCE
|
Posted: Tue Apr 11, 2006 3:52 pm Post subject: |
|
|
Thanks a lot for this code...
Very good !!!
|
|
Back to top |
|
|
marty Professional Member
Joined: 10 May 2001 Posts: 789
|
Posted: Tue Apr 11, 2006 3:54 pm Post subject: |
|
|
Would be nice to get the icon of the active window instead of just the EXE... Unless it could be possible to get the EXE from the an active window..
For example.. I click on my Internet Explorer window.. the I would get the ICOn in the bitlist..
Just a thought.. and even my see if I can get sometthing out of this thought
Nice work tho
|
|
Back to top |
|
|
|
|
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 can attach files in this forum You can download files in this forum
|
|