cGetFile()

cGetFile()

Postby Rick Lipkin » Fri Sep 15, 2023 4:56 pm

To All

Code: Select all  Expand view

// 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
User avatar
Rick Lipkin
 
Posts: 2616
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: cGetFile()

Postby Enrico Maria Giordano » Fri Sep 15, 2023 5:47 pm

Example:

Code: Select all  Expand view
cXls = CGETFILE( "File Excel (*.xls;*.xlsx)|*.xls;*.xlsx", "Import from", , CURDRIVE() + "\" + CURDIR() )
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: cGetFile()

Postby Rick Lipkin » Fri Sep 15, 2023 8: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
User avatar
Rick Lipkin
 
Posts: 2616
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: cGetFile()

Postby nageswaragunupudi » Sat Sep 16, 2023 12:53 am

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

Re: cGetFile()

Postby nageswaragunupudi » Sat Sep 16, 2023 1:27 am

OFT.
Just a casual discussion.
...
Another simpler alternative appears to be:
Code: Select all  Expand view
TrueName( "." ) // --> c:\fwh\samples
TrueName( ".\") // --> c:\fwh\samples\
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: cGetFile()

Postby Enrico Maria Giordano » Sat Sep 16, 2023 6:37 am

nageswaragunupudi wrote:OFT.
Just a casual discussion.
I think it should be CURDRIVE() + ":\" + CURDIR() but not CURDRIVE() + "\" + CURDIR().


Yes, sorry.
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: cGetFile()

Postby nageswaragunupudi » Sat Sep 16, 2023 10:19 am

Enrico Maria Giordano wrote:
nageswaragunupudi 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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: cGetFile()

Postby Enrico Maria Giordano » Sat Sep 16, 2023 10:36 am

You don't have to apologies. On the contrary, thanks for the correction.
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: cGetFile()

Postby karinha » Sat Sep 16, 2023 9:20 pm

Code: Select all  Expand view

// 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
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: cGetFile()

Postby Rick Lipkin » Thu Sep 21, 2023 1: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
User avatar
Rick Lipkin
 
Posts: 2616
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA



Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 101 guests