Selección múltiple de archivos
Posted: Wed Mar 13, 2013 10:44 pm
¿Es posible con cGetFile32() o cualquier otra función permitir una selección múltiple de archivos?
www.FiveTechSoft.com
http://forums.fivetechsoft.com/
Code: Select all
aFiles := selectfiles()
for i := 1 to len( aFiles )
? aFiles[ i ]
next
Code: Select all
* -------------------------------------------------------------
* funciona cGetFile Modificada para seleccionar varios archivos
* -------------------------------------------------------------
FUNCTION SelectFiles()
LOCAL cCurDir := CurDrive() + ":\" + CurDir() //willy
LOCAL cFile := CGETFILE( "*.xml", "Selecciona uno o varios archivos ...", , , , , NOR( OFN_ALLOWMULTISELECT, OFN_EXPLORER, OFN_HIDEREADONLY ) )
LOCAL aFile := {}
LOCAL cPath
local cFile1 := cFile
IF !EMPTY( cFile )
cPath = LEFT( cFile, AT( CHR( 0 ), cFile ) - 1 )
IF RIGHT( cPath, 1 ) != "\"; cPath += "\"; ENDIF
WHILE .T.
cFile = SUBSTR( cFile, AT( CHR( 0 ), cFile ) + 1 )
IF LEFT( cFile, 1 ) = CHR( 0 ); EXIT; ENDIF
AADD( aFile, cPath + LEFT( cFile, AT( CHR( 0 ), cFile ) - 1 ) )
ENDDO
IF LEN( aFile ) = 1
aFile[ 1 ] = LEFT( aFile[ 1 ], LEN( aFile[ 1 ] ) - 1 )
ENDIF
ENDIF
&& WQOUT( aFile ) && muestra un arreglo en un dialogo.
DirChange( cCurDir ) //wiliam morales
* Si solo selecciona un elemento.
if len( aFile ) = 0 .and. !empty( cFile1 )
aadd( aFile, cFile1 )
endif
RETURN ( aFile )
#pragma BEGINDUMP
#include <Windows.h>
#include <CommDlg.h>
#include <ClipApi.h>
#include <HbApi.h>
static far WORD wIndex;
static far char Title[] = "Selecciona uno o varios archivos";
HB_FUNC( CGETFILE ) // ( cFileMask, cTitle, nDefaultMask, ;
// cInitDir, lSave, lLongNames, nFlags, ;
// cIniFile ) --> cFileName
{
OPENFILENAME ofn;
LPSTR pFile, pFilter, pDir, pTitle;
WORD w = 0, wLen;
BYTE bIndex = ( BYTE ) hb_parni( 3 );
BOOL bSave = IF( PCOUNT() > 4 && ISLOGICAL( 5 ), hb_parl( 5 ), FALSE );
BOOL bLongNames = hb_parl( 6 );
DWORD dwFlags = IF( PCOUNT() > 6 && ISNUM( 7 ), hb_parnl( 7 ), 2060 );
if( PCOUNT() < 1 )
{
hb_retc( "" );
return;
}
// alloc for title
pTitle = ( LPSTR ) hb_xgrab( 128 );
if ( PCOUNT() > 1 && ISCHAR( 2 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 2 ) );
memcpy( pTitle, hb_parc( 2 ), wLen );
* ( pTitle + wLen ) = 0;
}
else
{
pTitle = Title;
}
// alloc for initial dir
pDir = ( LPSTR ) hb_xgrab( 128 );
if ( PCOUNT() > 3 && ISCHAR( 4 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 4 ) );
memcpy( pDir, hb_parc( 4 ), wLen );
* ( pDir + wLen ) = 0;
}
else
{
* ( pDir ) = 0;
}
// alloc for file
if ( dwFlags & OFN_ALLOWMULTISELECT )
pFile = ( LPSTR ) hb_xgrab( 32768 );
else
pFile = ( LPSTR ) hb_xgrab( 128 );
if ( PCOUNT() > 7 && ISCHAR( 8 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 8 ) );
memcpy( pFile, hb_parc( 8 ), wLen );
}
else
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 1 ) );
memcpy( pFile, hb_parc( 1 ), wLen );
}
* ( pFile + wLen ) = 0;
// alloc for mask
pFilter = ( LPSTR ) hb_xgrab( 400 );
wLen = ( WORD ) min( ( unsigned long ) 398, hb_parclen( 1 ) );
memcpy( pFilter, hb_parc( 1 ), wLen );
* ( pFilter + wLen ) = 0;
while( * ( pFilter + w ) )
{
if( * ( pFilter + w ) == '|' )
{
* ( pFilter + w ) = 0;
if ( PCOUNT() < 8 )
* (pFile) = 0;
}
w++;
}
* ( pFilter + wLen ) = 0;
* ( pFilter + wLen + 1 ) = 0;
memset( ( char * ) &ofn, 0, sizeof( OPENFILENAME ) );
ofn.lStructSize = sizeof( OPENFILENAME );
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFilter = pFilter;
ofn.lpstrFile = pFile;
ofn.lpstrInitialDir = pDir;
ofn.lpstrTitle = pTitle;
ofn.lpstrCustomFilter = 0; // NIL;
ofn.nFilterIndex = bIndex ? bIndex: 1;
ofn.nMaxFile = dwFlags & OFN_ALLOWMULTISELECT ? 32768 : 128;
ofn.lpstrFileTitle = 0; // NIL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR |
IF( bSave, OFN_HIDEREADONLY, 0 ) |
IF( bLongNames, OFN_LONGNAMES, 0 );
if( dwFlags )
ofn.Flags = dwFlags;
wIndex = 0;
if( bSave )
{
if( GetSaveFileName( &ofn ) )
hb_retc( pFile );
else
hb_retc( "" );
}
else
{
if( GetOpenFileName( &ofn ) )
if ( dwFlags & OFN_ALLOWMULTISELECT )
hb_retclen( pFile, 32768 );
else
hb_retc( pFile );
else
hb_retc( "" );
}
wIndex = ( WORD ) ofn.nFilterIndex;
hb_xfree( pFilter );
hb_xfree( pFile );
hb_xfree( pDir );
hb_xfree( pTitle );
}
#pragma ENDDUMP
Se me hizo fácil quitar la lína
Error E2238 d:\lenguaje\harbour\include\clipdefs.h 84: Multiple declaration for
'WORD'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2344 \lenguaje\bcc55\Include\windef.h 145: Earlier declaration of 'WORD'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2238 d:\lenguaje\harbour\include\clipdefs.h 86: Multiple declaration for
'PWORD'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2344 \lenguaje\bcc55\Include\windef.h 154: Earlier declaration of 'PWORD'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2238 d:\lenguaje\harbour\include\clipdefs.h 106: Multiple declaration for
'BOOL'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2344 \lenguaje\bcc55\Include\windef.h 143: Earlier declaration of 'BOOL'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2238 d:\lenguaje\harbour\include\clipdefs.h 109: Multiple declaration for
'PBOOL'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2344 \lenguaje\bcc55\Include\windef.h 148: Earlier declaration of 'PBOOL'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2238 d:\lenguaje\harbour\include\clipdefs.h 118: Multiple declaration for
'HANDLE'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2344 \lenguaje\bcc55\Include\winnt.h 283: Earlier declaration of 'HANDLE'
+ Full parser context
+ ..\\fuentes\\main.prg, line 381: #include \lenguaje\fwh\include\ClipApi.h
+ \lenguaje\fwh\include\ClipApi.h, line 22: #include \lenguaje\fwh\include\fwH
arb.h
+ \lenguaje\fwh\include\fwHarb.h, line 20: #include d:\lenguaje\harbour\includ
e\extend.h
+ d:\lenguaje\harbour\include\extend.h, line 65: #include d:\lenguaje\harbour\
include\extend.api
+ d:\lenguaje\harbour\include\extend.api, line 58: #include d:\lenguaje\harbou
r\include\clipdefs.h
Error E2293 ..\\fuentes\\main.prg 384: ) expected
Warning W8019 ..\\fuentes\\main.prg 394: Code has no effect in function HB_FUN_C
GETFILE
Error E2379 ..\\fuentes\\main.prg 394: Statement missing ; in function HB_FUN_CG
ETFILE
Error E2140 ..\\fuentes\\main.prg 395: Declaration is not allowed here in functi
on HB_FUN_CGETFILE
Error E2140 ..\\fuentes\\main.prg 396: Declaration is not allowed here in functi
on HB_FUN_CGETFILE
Error E2140 ..\\fuentes\\main.prg 397: Declaration is not allowed here in functi
on HB_FUN_CGETFILE
Error E2140 ..\\fuentes\\main.prg 398: Declaration is not allowed here in functi
on HB_FUN_CGETFILE
Error E2451 ..\\fuentes\\main.prg 412: Undefined symbol 'wLen' in function HB_FU
N_CGETFILE
Error E2314 ..\\fuentes\\main.prg 412: Call of nonfunction in function HB_FUN_CG
ETFILE
Error E2314 ..\\fuentes\\main.prg 428: Call of nonfunction in function HB_FUN_CG
ETFILE
Error E2314 ..\\fuentes\\main.prg 446: Call of nonfunction in function HB_FUN_CG
ETFILE
Error E2314 ..\\fuentes\\main.prg 451: Call of nonfunction in function HB_FUN_CG
ETFILE
Error E2314 ..\\fuentes\\main.prg 459: Call of nonfunction in function HB_FUN_CG
ETFILE
Error E2451 ..\\fuentes\\main.prg 463: Undefined symbol 'w' in function HB_FUN_C
GETFILE
Error E2451 ..\\fuentes\\main.prg 496: Undefined symbol 'wIndex' in function HB_
FUN_CGETFILE
Error E2379 ..\\fuentes\\main.prg 516: Statement missing ; in function HB_FUN_CG
ETFILE
Error E2228 ..\\fuentes\\main.prg 516: Too many error or warning messages in fun
ction HB_FUN_CGETFILE
*** 26 errors in Compile ***
hbmk2: Error: Running C/C++ compiler. 1
bcc32.exe -c -q -CP437 -d -O2 -OS -Ov -Oc -Oi -6 -tW -tWM -w -Q -w-sig- -n..\.h
bmk\win\bcc -I\lenguaje\bcc55\Include -Id:\lenguaje\harbour\include -I\lenguaje\
fwh\include -I\lenguaje\harbour\contrib\xhb -I\quiquesoft\lib ..\.hbmk\win\bcc\m
ain.c
Pero al menos pasó la compilación, falló porque faltan funciones ¿esas donde las consigo? si es que es correcto que solo quite la línea que quité..\fuentes\main.prg(57) Warning W0001 Ambiguous reference 'OFN_ALLOWMULTISELECT
'
..\fuentes\main.prg(57) Warning W0001 Ambiguous reference 'OFN_EXPLORER'
..\fuentes\main.prg(57) Warning W0001 Ambiguous reference 'OFN_HIDEREADONLY'
..\fuentes\main.prg(341) Warning W0001 Ambiguous reference 'OFN_ALLOWMULTISELEC
T'
..\fuentes\main.prg(341) Warning W0001 Ambiguous reference 'OFN_EXPLORER'
..\fuentes\main.prg(341) Warning W0001 Ambiguous reference 'OFN_HIDEREADONLY'
Lines 5364, Functions/Procedures 14
Generating C source output to '..\.hbmk\win\bcc\main.c'... Done.
hbmk2: Compiling...
..\.hbmk\win\bcc\main.c:
Warning W8065 ..\\fuentes\\main.prg 396: Call to function 'PCOUNT' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 396: Call to function 'ISLOGICAL' with no pr
ototype in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 396: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 398: Call to function 'PCOUNT' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 398: Call to function 'ISNUM' with no protot
ype in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 398: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 400: Call to function 'PCOUNT' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 410: Call to function 'PCOUNT' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 410: Call to function 'ISCHAR' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 426: Call to function 'PCOUNT' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 426: Call to function 'ISCHAR' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 444: Call to function 'PCOUNT' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 444: Call to function 'ISCHAR' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 468: Call to function 'PCOUNT' with no proto
type in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 490: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 491: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
hbmk2: Linking... ..\qs-ide.exe
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_ISLOGICAL' referenced from D:\QUIQUESOFT\IDE\.HBMK\
WIN\BCC\MAIN.OBJ
Error: Unresolved external '_ISNUM' referenced from D:\QUIQUESOFT\IDE\.HBMK\WIN\
BCC\MAIN.OBJ
Error: Unresolved external '_ISCHAR' referenced from D:\QUIQUESOFT\IDE\.HBMK\WIN
\BCC\MAIN.OBJ
Error: Unresolved external '_PCOUNT' referenced from D:\QUIQUESOFT\IDE\.HBMK\WIN
\BCC\MAIN.OBJ
Error: Unresolved external '_IF' referenced from D:\QUIQUESOFT\IDE\.HBMK\WIN\BCC
\MAIN.OBJ
Error: Unresolved external '_HB_FUN_CURDRIVE' referenced from D:\QUIQUESOFT\IDE\
.HBMK\WIN\BCC\MAIN.OBJ
Code: Select all
* -------------------------------------------------------------
* funciona cGetFile Modificada para seleccionar varios archivos
* -------------------------------------------------------------
FUNCTION SelectFiles()
LOCAL cCurDir := CurDrive() + ":\" + CurDir() //willy
LOCAL cFile := CGETFILE( "*.xml", "Selecciona uno o varios archivos ...", , , , , NOR( OFN_ALLOWMULTISELECT, OFN_EXPLORER, OFN_HIDEREADONLY ) )
LOCAL aFile := {}
LOCAL cPath
local cFile1 := cFile
IF !EMPTY( cFile )
cPath = LEFT( cFile, AT( CHR( 0 ), cFile ) - 1 )
IF RIGHT( cPath, 1 ) != "\"; cPath += "\"; ENDIF
WHILE .T.
cFile = SUBSTR( cFile, AT( CHR( 0 ), cFile ) + 1 )
IF LEFT( cFile, 1 ) = CHR( 0 ); EXIT; ENDIF
AADD( aFile, cPath + LEFT( cFile, AT( CHR( 0 ), cFile ) - 1 ) )
ENDDO
IF LEN( aFile ) = 1
aFile[ 1 ] = LEFT( aFile[ 1 ], LEN( aFile[ 1 ] ) - 1 )
ENDIF
ENDIF
&& WQOUT( aFile ) && muestra un arreglo en un dialogo.
DirChange( cCurDir ) //wiliam morales
* Si solo selecciona un elemento.
if len( aFile ) = 0 .and. !empty( cFile1 )
aadd( aFile, cFile1 )
endif
RETURN ( aFile )
#pragma BEGINDUMP
#include <Windows.h>
#include <CommDlg.h>
//#include <ClipApi.h>
#include <HbApi.h>
static far WORD wIndex;
static far char Title[] = "Selecciona uno o varios archivos";
HB_FUNC( CGETFILE ) // ( cFileMask, cTitle, nDefaultMask, ;
// cInitDir, lSave, lLongNames, nFlags, ;
// cIniFile ) --> cFileName
{
OPENFILENAME ofn;
LPSTR pFile, pFilter, pDir, pTitle;
WORD w = 0, wLen;
BYTE bIndex = ( BYTE ) hb_parni( 3 );
BOOL bSave = IF( hb_pcount() > 4 && HB_ISLOGICAL( 5 ), hb_parl( 5 ), FALSE );
BOOL bLongNames = hb_parl( 6 );
DWORD dwFlags = IF( hb_pcount() > 6 && HB_ISNUM( 7 ), hb_parnl( 7 ), 2060 );
if( hb_pcount() < 1 )
{
hb_retc( "" );
return;
}
// alloc for title
pTitle = ( LPSTR ) hb_xgrab( 128 );
if ( hb_pcount() > 1 && HB_ISCHAR( 2 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 2 ) );
memcpy( pTitle, hb_parc( 2 ), wLen );
* ( pTitle + wLen ) = 0;
}
else
{
pTitle = Title;
}
// alloc for initial dir
pDir = ( LPSTR ) hb_xgrab( 128 );
if ( hb_pcount() > 3 && HB_ISCHAR( 4 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 4 ) );
memcpy( pDir, hb_parc( 4 ), wLen );
* ( pDir + wLen ) = 0;
}
else
{
* ( pDir ) = 0;
}
// alloc for file
if ( dwFlags & OFN_ALLOWMULTISELECT )
pFile = ( LPSTR ) hb_xgrab( 32768 );
else
pFile = ( LPSTR ) hb_xgrab( 128 );
if ( hb_pcount() > 7 && HB_ISCHAR( 8 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 8 ) );
memcpy( pFile, hb_parc( 8 ), wLen );
}
else
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 1 ) );
memcpy( pFile, hb_parc( 1 ), wLen );
}
* ( pFile + wLen ) = 0;
// alloc for mask
pFilter = ( LPSTR ) hb_xgrab( 400 );
wLen = ( WORD ) min( ( unsigned long ) 398, hb_parclen( 1 ) );
memcpy( pFilter, hb_parc( 1 ), wLen );
* ( pFilter + wLen ) = 0;
while( * ( pFilter + w ) )
{
if( * ( pFilter + w ) == '|' )
{
* ( pFilter + w ) = 0;
if ( hb_pcount() < 8 )
* (pFile) = 0;
}
w++;
}
* ( pFilter + wLen ) = 0;
* ( pFilter + wLen + 1 ) = 0;
memset( ( char * ) &ofn, 0, sizeof( OPENFILENAME ) );
ofn.lStructSize = sizeof( OPENFILENAME );
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFilter = pFilter;
ofn.lpstrFile = pFile;
ofn.lpstrInitialDir = pDir;
ofn.lpstrTitle = pTitle;
ofn.lpstrCustomFilter = 0; // NIL;
ofn.nFilterIndex = bIndex ? bIndex: 1;
ofn.nMaxFile = dwFlags & OFN_ALLOWMULTISELECT ? 32768 : 128;
ofn.lpstrFileTitle = 0; // NIL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR |
IF( bSave, OFN_HIDEREADONLY, 0 ) |
IF( bLongNames, OFN_LONGNAMES, 0 );
if( dwFlags )
ofn.Flags = dwFlags;
wIndex = 0;
if( bSave )
{
if( GetSaveFileName( &ofn ) )
hb_retc( pFile );
else
hb_retc( "" );
}
else
{
if( GetOpenFileName( &ofn ) )
if ( dwFlags & OFN_ALLOWMULTISELECT )
hb_retclen( pFile, 32768 );
else
hb_retc( pFile );
else
hb_retc( "" );
}
wIndex = ( WORD ) ofn.nFilterIndex;
hb_xfree( pFilter );
hb_xfree( pFile );
hb_xfree( pDir );
hb_xfree( pTitle );
}
#pragma ENDDUMP
¿Puedes ayudarme por favor?Warning W8065 ..\\fuentes\\main.prg 427: Call to function 'HB_ISLOGICAL' with no
prototype in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 427: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 429: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 521: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
Warning W8065 ..\\fuentes\\main.prg 522: Call to function 'IF' with no prototype
in function HB_FUN_CGETFILE
hbmk2: Linking... ..\qs-ide.exe
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_HB_ISLOGICAL' referenced from D:\QUIQUESOFT\IDE\.HB
MK\WIN\BCC\MAIN.OBJ
Error: Unresolved external '_IF' referenced from D:\QUIQUESOFT\IDE\.HBMK\WIN\BCC
\MAIN.OBJ
Error: Unresolved external '_HB_FUN_CURDRIVE' referenced from D:\QUIQUESOFT\IDE\
.HBMK\WIN\BCC\MAIN.OBJ
Code: Select all
#include "fivewin.ch"
#define OFN_HIDEREADONLY 0x4
#define OFN_ALLOWMULTISELECT 0x200
#define OFN_EXPLORER 0x80000
* -------------------------------------------------------------
* funciona cGetFile Modificada para seleccionar varios archivos
* -------------------------------------------------------------
FUNCTION SelectFiles()
LOCAL cCurDir := CurDrive() + ":\" + CurDir() //willy
LOCAL cFile := CGETFILE( "*.xml", "Selecciona uno o varios archivos ...", , , , , NOR( OFN_ALLOWMULTISELECT, OFN_EXPLORER, OFN_HIDEREADONLY ) )
LOCAL aFile := {}
LOCAL cPath
local cFile1 := cFile
IF !EMPTY( cFile )
cPath = LEFT( cFile, AT( CHR( 0 ), cFile ) - 1 )
IF RIGHT( cPath, 1 ) != "\"; cPath += "\"; ENDIF
WHILE .T.
cFile = SUBSTR( cFile, AT( CHR( 0 ), cFile ) + 1 )
IF LEFT( cFile, 1 ) = CHR( 0 ); EXIT; ENDIF
AADD( aFile, cPath + LEFT( cFile, AT( CHR( 0 ), cFile ) - 1 ) )
ENDDO
IF LEN( aFile ) = 1
aFile[ 1 ] = LEFT( aFile[ 1 ], LEN( aFile[ 1 ] ) - 1 )
ENDIF
ENDIF
&& WQOUT( aFile ) && muestra un arreglo en un dialogo.
DirChange( cCurDir ) //wiliam morales
* Si solo selecciona un elemento.
if len( aFile ) = 0 .and. !empty( cFile1 )
aadd( aFile, cFile1 )
endif
RETURN ( aFile )
#pragma BEGINDUMP
#include <Windows.h>
#include <CommDlg.h>
//#include <ClipApi.h>
#include <HbApi.h>
static far WORD wIndex;
static far char Title[] = "Selecciona uno o varios archivos";
HB_FUNC( CGETFILE ) // ( cFileMask, cTitle, nDefaultMask, ;
// cInitDir, lSave, lLongNames, nFlags, ;
// cIniFile ) --> cFileName
{
OPENFILENAME ofn;
LPSTR pFile, pFilter, pDir, pTitle;
WORD w = 0, wLen;
BYTE bIndex = ( BYTE ) hb_parni( 3 );
#ifndef __XHARBOUR__
BOOL bSave = hb_pcount() > 4 && HB_ISLOG( 5 ) ? hb_parl( 5 ) : FALSE ;
#else
BOOL bSave = hb_pcount() > 4 && ISLOG( 5 ) ? hb_parl( 5 ) : FALSE ;
#endif
BOOL bLongNames = hb_parl( 6 );
#ifndef __XHARBOUR__
DWORD dwFlags = hb_pcount() > 6 && HB_ISNUM( 7 ) ? hb_parnl( 7 ) : 2060 ;
#else
DWORD dwFlags = hb_pcount() > 6 && ISNUM( 7 ) ? hb_parnl( 7 ) : 2060 ;
#endif
if( hb_pcount() < 1 )
{
hb_retc( "" );
return;
}
// alloc for title
pTitle = ( LPSTR ) hb_xgrab( 128 );
#ifndef __XHARBOUR__
if ( hb_pcount() > 1 && HB_ISCHAR( 2 ) )
#else
if ( hb_pcount() > 1 && ISCHAR( 2 ) )
#endif
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 2 ) );
memcpy( pTitle, hb_parc( 2 ), wLen );
* ( pTitle + wLen ) = 0;
}
else
{
pTitle = Title;
}
// alloc for initial dir
pDir = ( LPSTR ) hb_xgrab( 128 );
if ( hb_pcount() > 3 && HB_ISCHAR( 4 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 4 ) );
memcpy( pDir, hb_parc( 4 ), wLen );
* ( pDir + wLen ) = 0;
}
else
{
* ( pDir ) = 0;
}
// alloc for file
if ( dwFlags & OFN_ALLOWMULTISELECT )
pFile = ( LPSTR ) hb_xgrab( 32768 );
else
pFile = ( LPSTR ) hb_xgrab( 128 );
if ( hb_pcount() > 7 && HB_ISCHAR( 8 ) )
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 8 ) );
memcpy( pFile, hb_parc( 8 ), wLen );
}
else
{
wLen = ( WORD ) min( ( unsigned long ) 127, hb_parclen( 1 ) );
memcpy( pFile, hb_parc( 1 ), wLen );
}
* ( pFile + wLen ) = 0;
// alloc for mask
pFilter = ( LPSTR ) hb_xgrab( 400 );
wLen = ( WORD ) min( ( unsigned long ) 398, hb_parclen( 1 ) );
memcpy( pFilter, hb_parc( 1 ), wLen );
* ( pFilter + wLen ) = 0;
while( * ( pFilter + w ) )
{
if( * ( pFilter + w ) == '|' )
{
* ( pFilter + w ) = 0;
if ( hb_pcount() < 8 )
* (pFile) = 0;
}
w++;
}
* ( pFilter + wLen ) = 0;
* ( pFilter + wLen + 1 ) = 0;
memset( ( char * ) &ofn, 0, sizeof( OPENFILENAME ) );
ofn.lStructSize = sizeof( OPENFILENAME );
ofn.hwndOwner = GetActiveWindow();
ofn.lpstrFilter = pFilter;
ofn.lpstrFile = pFile;
ofn.lpstrInitialDir = pDir;
ofn.lpstrTitle = pTitle;
ofn.lpstrCustomFilter = 0; // NIL;
ofn.nFilterIndex = bIndex ? bIndex: 1;
ofn.nMaxFile = dwFlags & OFN_ALLOWMULTISELECT ? 32768 : 128;
ofn.lpstrFileTitle = 0; // NIL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR |
bSave ? OFN_HIDEREADONLY : 0 |
bLongNames ? OFN_LONGNAMES : 0 ;
if( dwFlags )
ofn.Flags = dwFlags;
wIndex = 0;
if( bSave )
{
if( GetSaveFileName( &ofn ) )
hb_retc( pFile );
else
hb_retc( "" );
}
else
{
if( GetOpenFileName( &ofn ) )
if ( dwFlags & OFN_ALLOWMULTISELECT )
hb_retclen( pFile, 32768 );
else
hb_retc( pFile );
else
hb_retc( "" );
}
wIndex = ( WORD ) ofn.nFilterIndex;
hb_xfree( pFilter );
hb_xfree( pFile );
hb_xfree( pDir );
hb_xfree( pTitle );
}
#pragma ENDDUMP
Code: Select all
FUNCTION SelectFiles( cDirSelect, cMascara )
LOCAL cCurDir := HB_CurDrive() + ":\" + CurDir() //willy
/* LOCAL cFile := CGETFILE( "*.xml", "Selecciona uno o varios archivos ...", , , , , NOR( OFN_ALLOWMULTISELECT, OFN_EXPLORER, OFN_HIDEREADONLY ) )*/
LOCAL cFile := CGETFILE( cMascara, "Selecciona uno o varios archivos ...", "*.*", cDirSelect, , , NOR( OFN_ALLOWMULTISELECT, OFN_EXPLORER, OFN_HIDEREADONLY ) )
...