Associated Application ICONS

Associated Application ICONS

Postby nageswaragunupudi » Fri Oct 28, 2022 4:03 pm

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 view
XIMAGE( "some.pptx(256x256)")


Image

Sample-2
Code: Select all  Expand view
  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 view
  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 view
#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
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Associated Application ICONS

Postby Antonio Linares » Sat Oct 29, 2022 7:32 am

Dear Rao,

Great work, many thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Associated Application ICONS

Postby hua » Tue Nov 01, 2022 2:50 am

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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: Associated Application ICONS

Postby Jimmy » Tue Nov 01, 2022 11:06 pm

hi,

try this

c:\fwh\source\winapi\icons.c
Code: Select all  Expand view
HB_FUNC( ICON_READ )


c:\fwh\source\winapi\gdipfwh.cpp
Code: Select all  Expand view
HB_FUNC( ICON_READEX )
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Associated Application ICONS

Postby hua » Thu Nov 03, 2022 10:21 am

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 view
HB_FUNC( ICON_READ )


c:\fwh\source\winapi\gdipfwh.cpp
Code: Select all  Expand view
HB_FUNC( ICON_READEX )
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

Postby Jimmy » Thu Nov 03, 2022 12:44 pm

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
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Associated Application ICONS

Postby TimStone » Thu Nov 03, 2022 10:51 pm

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
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Associated Application ICONS

Postby nageswaragunupudi » Fri Nov 04, 2022 4:48 am

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 view
  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
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Associated Application ICONS

Postby hua » Fri Nov 04, 2022 6:44 am

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

Postby hua » Fri Nov 04, 2022 6:45 am

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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 93 guests