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 


Obtain icon for a file (to use with a BITLIST or TABLE)

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Aug 09, 2003 3:51 pm    Post subject: Obtain icon for a file (to use with a BITLIST or TABLE) Reply with quote

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! Smile

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" Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1543

PostPosted: Sat Aug 09, 2003 4:07 pm    Post subject: Reply with quote

Really nice work, worked great
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Aug 09, 2003 8:43 pm    Post subject: Reply with quote

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! Smile

Thanks FreezingFire! Smile

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
http://www.freewarehome.com <-- Freeware listings since 1996
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Aug 09, 2003 10:14 pm    Post subject: Reply with quote

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 Smile

Thanks for all your guys support. Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Aug 10, 2003 12:18 am    Post subject: Reply with quote

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.)
Necroprogramming FTW! - "Wait.. Is necroprogramming legal?"
http://www.freewarehome.com <-- Freeware listings since 1996
Back to top
View user's profile Send private message
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 174
Location: FRANCE

PostPosted: Sat Jul 30, 2005 10:04 am    Post subject: Reply with quote

hello everyone...
Great codes...Worship

I realized that the icons of files LNK were not listed...

Is it possible to do it ?

Thanks a lot Wink
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Jul 30, 2005 6:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 174
Location: FRANCE

PostPosted: Sun Jul 31, 2005 1:08 am    Post subject: Reply with quote

Shocked
Easy... very easy... Embarassed
Thanks Garrett
Back to top
View user's profile Send private message Visit poster's website
uvedese
Contributor
Contributor


Joined: 21 Jan 2006
Posts: 159
Location: Spain

PostPosted: Sun Mar 19, 2006 8:00 pm    Post subject: Reply with quote

Creo que con este cdigo basado en el cdigo de FreezingFire soluciona todos los problemas Smile

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



Obtain icon for a file.dsc
 Description:

Download
 Filename:  Obtain icon for a file.dsc
 Filesize:  920 Bytes
 Downloaded:  1026 Time(s)

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


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Tue Apr 11, 2006 2:42 pm    Post subject: Reply with quote

Interesting changes there, uvedese. Specifically the use of the icon from the default program that opens the file.


Interesando cambios all, uvedese. Especficamente el uso del icono del programa del defecto que abre el archivo.

_________________
cheers

Dave
Back to top
View user's profile Send private message Visit poster's website
GregLand
Contributor
Contributor


Joined: 15 Jun 2004
Posts: 174
Location: FRANCE

PostPosted: Tue Apr 11, 2006 3:52 pm    Post subject: Reply with quote

Thanks a lot for this code... Very Happy
Very good !!!
Back to top
View user's profile Send private message Visit poster's website
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Tue Apr 11, 2006 3:54 pm    Post subject: Reply with quote

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 Very Happy

Nice work tho Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code All times are GMT
Page 1 of 1

 
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 can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group