Page 1 of 1

Associated Application ICONS

Posted: Fri Oct 28, 2022 4:03 pm
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.

Re: Associated Application ICONS

Posted: Sat Oct 29, 2022 7:32 am
by Antonio Linares
Dear Rao,

Great work, many thanks!

Re: Associated Application ICONS

Posted: Tue Nov 01, 2022 2:50 am
by hua
Nice Rao.
I'm not clear on which command to use to get the icon

Re: Associated Application ICONS

Posted: Tue Nov 01, 2022 11:06 pm
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 )

Re: Associated Application ICONS

Posted: Thu Nov 03, 2022 10:21 am
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 )

Re: Associated Application ICONS

Posted: Thu Nov 03, 2022 12:44 pm
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() )

Re: Associated Application ICONS

Posted: Thu Nov 03, 2022 10:51 pm
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.

Re: Associated Application ICONS

Posted: Fri Nov 04, 2022 4:48 am
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

Re: Associated Application ICONS

Posted: Fri Nov 04, 2022 6:44 am
by hua
Cool! I didn't realize it's already available.
Thanks Rao!

Re: Associated Application ICONS

Posted: Fri Nov 04, 2022 6:45 am
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.