Associated Application ICONS

Post Reply
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Associated Application ICONS

Post by nageswaragunupudi »

We mostly produce serious business applications. I doubt if this topic be of much practical use. Nonetheless, it can be an interesting diversion.

The idea is given any existing file, read the icon of the associated application and display.
For example, if the file is "some.xlsx" display the icon of Excel application, for "some.docx", display icon of the Word Application, etc.

Here, we will demonstrate how simple and easy to do this, using FWH.

Please note, we have to use existing file names.
Sample-1

Code: Select all | Expand

XIMAGE( "some.pptx(256x256)")
Image

Sample-2

Code: Select all | Expand

   DEFINE DIALOG oDlg SIZE 510,500 PIXEL TRUEPIXEL
   ACTIVATE DIALOG oDlg CENTERED ON PAINT ( ;
      oDlg:DrawImage( "some.xlsx(16x16)", {,,,50} ), ;
      oDlg:DrawImage( "some.xlsx(32x32)", {,50,,100} ), ;
      oDlg:DrawImage( "some.xlsx(64x64)", {,100,,200} ), ;
      oDlg:DrawImage( "some.xlsx(256x256)", {,200,,500} ) )
 
Image

Sample-3:
From next version

Code: Select all | Expand

   DEFINE DIALOG oDlg SIZE 600,250 PIXEL TRUEPIXEL
   DEFINE BUTTONBAR oBar SIZE 80,80 2007

   for each c in { "DOCX", "XLSX", "PPTX", "PDF", "TXT" }
      DEFINE BUTTON OF oBar PROMPT c FILE "." + c,"." + c,"." + c, "." + c + "(16x16)"
   next

   ACTIVATE DIALOG oDlg CENTERED
 
Till FWH2206, we need to use existing file names.

Image

Sample-4

Code: Select all | Expand

#include "fivewin.ch"

function Main( cPath )

   DEFAULT cPath := "c:\aFiles\"   // your folder here

   XBROWSER DIRECTORY( cPath + "*.*" ) COLUMNS 1,2,3 ;
   TITLE "FILE ICONS" ;
   SETUP BrwSetup( oBrw, cPath )

return nil

static function BrwSetup( oBrw, cPath )

   WITH OBJECT oBrw
      :cHeaders := { "Name","Size","Date" }
      :nRowHeight := 34
      WITH OBJECT :aCols[ 1 ]
         :bBmpData := { || cPath + oBrw:aRow[ 1 ] }
         :bLDClickData  := { || ShellExecute( 0, "Open", cPath + oBrw:aRow[ 1 ],,, 1 ) }
      END
   END

return nil
Image
Note: Easy to write but not fully optimized for speed.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Antonio Linares
Site Admin
Posts: 42273
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Associated Application ICONS

Post by Antonio Linares »

Dear Rao,

Great work, many thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
hua
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Associated Application ICONS

Post by hua »

Nice Rao.
I'm not clear on which command to use to get the icon
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
Jimmy
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Associated Application ICONS

Post by Jimmy »

hi,

try this

c:\fwh\source\winapi\icons.c

Code: Select all | Expand

HB_FUNC( ICON_READ )
c:\fwh\source\winapi\gdipfwh.cpp

Code: Select all | Expand

HB_FUNC( ICON_READEX )
greeting,
Jimmy
hua
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Associated Application ICONS

Post by hua »

Thanks Jimmy.
Any idea how to assign them to a BTNBMP?
Jimmy wrote: try this
c:\fwh\source\winapi\icons.c

Code: Select all | Expand

HB_FUNC( ICON_READ )
c:\fwh\source\winapi\gdipfwh.cpp

Code: Select all | Expand

HB_FUNC( ICON_READEX )
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
User avatar
Jimmy
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Associated Application ICONS

Post by Jimmy »

hi,
hua wrote:Any idea how to assign them to a BTNBMP?
i have not work with CLASS TBtnBmp() yet

when look into Soure i found
//
// if user has directly assigned hBitmapX
//
i guess you can use "o:hBmp" to assign Result a hBitmap ... but i´m not sure about hIcon (from ICON_READ() )
greeting,
Jimmy
User avatar
TimStone
Posts: 2951
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Associated Application ICONS

Post by TimStone »

For many years, I have used Axialis for all my bitmaps. Now they have Icon Generator which is a free download. They also sell many libraries, but include a huge number of free Google icons. With the generator, you can easily colorize those Google icons. You can also add overlays to them to create new icons.

Instead of bitmaps, I now use all vector icons ( created by IG ) on all of my bitmap bars. They work very nicely and are clean. You can buy a wide variety of styles already made, or you can build your own. In a large application, with many options, we often need custom icons.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Associated Application ICONS

Post by nageswaragunupudi »

Any idea how to assign them to a BTNBMP?
Very simple.
See Sample-3 above

This is a very simple example you can try right now: This sample works with FWH1912

Code: Select all | Expand

   DEFINE DIALOG oDlg

   @ 10,10 BTNBMP PROMPT "MS-WORD"  FILE "T.DOCX(64X64)"    SIZE 50,60 PIXEL 2007 OF oDlg

   @ 10,70 BTNBMP PROMPT "MS-EXCEL" FILE "SOME.XLSX(64x64)" SIZE 50,60 PIXEL 2007 OF oDlg

   ACTIVATE DIALOG oDlg CENTERED
 
Image


Just specify the file name like any bitmap/image file. FWH will take care of all that is needed.
This feature was availabe for many years

Till FWH2206, we need to specify an existing file,
From FWH2210, it is enough if we specify dot ext , eg: ".DOCX", ".PDF", etc. , but limited to sizes 16x16 a,nd 32x32 only
Regards

G. N. Rao.
Hyderabad, India
hua
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Associated Application ICONS

Post by hua »

Cool! I didn't realize it's already available.
Thanks Rao!
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Associated Application ICONS

Post by hua »

Thanks for tip Tim.
TimStone wrote:For many years, I have used Axialis for all my bitmaps. Now they have Icon Generator which is a free download. They also sell many libraries, but include a huge number of free Google icons. With the generator, you can easily colorize those Google icons. You can also add overlays to them to create new icons.

Instead of bitmaps, I now use all vector icons ( created by IG ) on all of my bitmap bars. They work very nicely and are clean. You can buy a wide variety of styles already made, or you can build your own. In a large application, with many options, we often need custom icons.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
Post Reply