FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Associated Application ICONS
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Associated Application ICONS
Posted: Fri Oct 28, 2022 04: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 (fw): Select all Collapse
XIMAGE( "some.pptx(256x256)")


Sample-2
Code (fw): Select all Collapse
   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} ) )


Sample-3:
From next version
Code (fw): Select all Collapse
   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.



Sample-4
Code (fw): Select all Collapse
#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

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



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Associated Application ICONS
Posted: Sat Oct 29, 2022 07:32 AM

Dear Rao,

Great work, many thanks!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Associated Application ICONS
Posted: Tue Nov 01, 2022 02: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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Associated Application ICONS
Posted: Tue Nov 01, 2022 11:06 PM
hi,

try this

c:\fwh\source\winapi\icons.c
Code (fw): Select all Collapse
HB_FUNC( ICON_READ )
c:\fwh\source\winapi\gdipfwh.cpp
Code (fw): Select all Collapse
HB_FUNC( ICON_READEX )
greeting,

Jimmy
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Associated Application ICONS
Posted: 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 (fw): Select all Collapse
HB_FUNC( ICON_READ )
c:\fwh\source\winapi\gdipfwh.cpp
Code (fw): Select all Collapse
HB_FUNC( ICON_READEX )
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Associated Application ICONS
Posted: 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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Associated Application ICONS
Posted: 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Associated Application ICONS
Posted: Fri Nov 04, 2022 04: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 (fw): Select all Collapse
   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



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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Associated Application ICONS
Posted: Fri Nov 04, 2022 06: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
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: Associated Application ICONS
Posted: Fri Nov 04, 2022 06: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

Continue the discussion