FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour cGetFile()
Posts: 2707
Joined: Fri Oct 07, 2005 01:50 PM

cGetFile()

Posted: Fri Sep 15, 2023 04:56 PM
To All
Code (fw): Select all Collapse
// samples\bmp.prg

#include "FiveWin.ch"

function Main()

   local cBmpFile := cGetFile( "*.bmp", "Please select a BMP file" )

   BmpPresenta( cBmpFile, "Test" )

return nil

//----------------------------------------------
function BmpPresenta( cBmp, cTitulo )

   local oWnd, oBmp

   DEFAULT cTitulo := "Showing image"

   cBmp := alltrim( cBmp )

 *  msginfo( "cBmp "+cBmp )

   if .not. "." $ cBmp
      cBmp += ".BMP"
   endif

   if file( cBmp )
      DEFINE BITMAP oBmp FILE cBmp

      DEFINE DIALOG oWnd TITLE cTitulo ;
         SIZE oBmp:nWidth(), oBmp:nHeight PIXEL

      ACTIVATE DIALOG oWnd CENTERED ;
         ON PAINT PalBmpDraw( hDC, 0, 0, oBmp:hBitmap )

      oBmp:End()
   else
      MsgAlert( "File not found!" )
   endif

return nil
I want to modify this code to show ONLY *.bmp in a specific directory ( folder ) ... I do not want to see every file in the directory ( folder ) I am looking at ... ONLY the selected filetype in this instance *.bmp

Thanks
Rick Lipkin
Posts: 9052
Joined: Thu Oct 06, 2005 08:17 PM

Re: cGetFile()

Posted: Fri Sep 15, 2023 05:47 PM
Example:
Code (fw): Select all Collapse
cXls = CGETFILE( "File Excel (*.xls;*.xlsx)|*.xls;*.xlsx", "Import from", , CURDRIVE() + "\" + CURDIR() )
Posts: 2707
Joined: Fri Oct 07, 2005 01:50 PM

Re: cGetFile()

Posted: Fri Sep 15, 2023 08:51 PM

Enrico .. thank you for the code ... I did notice that the folders are still visable if you are just looking for a specific file .. but in my case I see the .xlsx Excel file(s) only and that works for me ..

Thanks a lot!

Rick Lipkin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: cGetFile()

Posted: Sat Sep 16, 2023 12:53 AM
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local cBmpFile

   do while !Empty( cBmpFile := cGetFile( "*.bmp|*.bmp|", "Please select a BMP file",,"..\bitmaps\" ) )
      XImage( cBmpFile )
   enddo

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: cGetFile()

Posted: Sat Sep 16, 2023 01:27 AM
OFT.
Just a casual discussion.
...
Another simpler alternative appears to be:
Code (fw): Select all Collapse
TrueName( "." ) // --> c:\fwh\samples
TrueName( ".\") // --> c:\fwh\samples\
Regards



G. N. Rao.

Hyderabad, India
Posts: 9052
Joined: Thu Oct 06, 2005 08:17 PM

Re: cGetFile()

Posted: Sat Sep 16, 2023 06:37 AM
nageswaragunupudi wrote:OFT.
Just a casual discussion.
I think it should be CURDRIVE() + ":\" + CURDIR() but not CURDRIVE() + "\" + CURDIR().
Yes, sorry.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: cGetFile()

Posted: Sat Sep 16, 2023 10:19 AM
Enrico Maria Giordano wrote:
OFT.
Just a casual discussion.
I think it should be CURDRIVE() + ":\" + CURDIR() but not CURDRIVE() + "\" + CURDIR().
Yes, sorry.
My sincere apologies.
My intention was only to consider the merits of using the alternative function TrueName(".\")
Regards



G. N. Rao.

Hyderabad, India
Posts: 9052
Joined: Thu Oct 06, 2005 08:17 PM

Re: cGetFile()

Posted: Sat Sep 16, 2023 10:36 AM

You don't have to apologies. On the contrary, thanks for the correction.

Posts: 8716
Joined: Tue Dec 20, 2005 07:36 PM

Re: cGetFile()

Posted: Sat Sep 16, 2023 09:20 PM
Code (fw): Select all Collapse
// C:\FWH..\SAMPLES\CGETFIL.PRG

#Include "FiveWin.ch"

MEMVAR cDirImg

FUNCTION Main()

   LOCAL cFile, cPathImg

   cDirImg := GETCURDIR()

   // Unidade C:\
   IF SUBS( cDirImg, LEN( ALLTRIM(cDirImg ) ) , 1 ) = "\"
      cDirImg := SUBS( cDirImg, 1 , LEN( ALLTRIM(cDirImg ) ) - 1 )
   ENDIF

   LCHDIR( cDirImg )

   cPathImg := cDirImg + "\"+ "*.BMP"

   cFile := cGetFile( "*.bmp|*.bmp|", "Please select a BMP file",,"cPathImg" )

   IF .NOT. Empty( cFile )

      XImage( cFile )

   ENDIF

RETURN NIL

// fin / end
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 2707
Joined: Fri Oct 07, 2005 01:50 PM

Re: cGetFile()

Posted: Thu Sep 21, 2023 01:33 PM

To All

What I was origionally trying to do is to drill down to any folder and find only *.xlsx files .. for example I have downloaded an Excel file and programatically I wanted to be able to use cGetFile to be able to drill down to the desktop and see only *.xlsx files and return the path and file name of the Excel file that I choose and I do not want to see other files and folders on the desktop .. only *.xlsx ..

Thanks

Rick Lipkin

Posts: 8716
Joined: Tue Dec 20, 2005 07:36 PM

Continue the discussion