驴Es posible con cGetFile32() o cualquier otra funci贸n permitir una selecci贸n m煤ltiple de archivos?
Quique
驴Es posible con cGetFile32() o cualquier otra funci贸n permitir una selecci贸n m煤ltiple de archivos?
aFiles := selectfiles()
for i := 1 to len( aFiles )
? aFiles[ i ]
next* -------------------------------------------------------------
* 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
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
..\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
Quique,
Renombra las funciones que comienzan por IS... a HB_IS...
Renombra PCOUNT a hb_pcount()
* -------------------------------------------------------------
* 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
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
Peron Quique,
se me olvido decirte que la funcion es para xhb.
usas harbour?
saludos-
Para el programa en el que lo necesito s铆, de hecho, es un programa que originalmente estaba en xHarbour y ahora est谩 en harbour.
#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 ENDDUMPCon unas ligeras modificaciones en la funci贸n SelectFiles() para poder adaptarlo a mi programa, ya qued贸 listo y trabajando ![]()
Solo dos detalles que vale la pena comentar, porque sin ellos no me funcion贸:
Cambi茅 la funci贸n CurDrive() por hb_CurDrive()
Modifiqu茅 la l铆nea aadd( aFile, cFile1 ) por aadd( aFile, left( cFile1, at( chr( 0 ), cFile1 ) - 1 ) ), porque si no, ten铆a problemas cuando solo seleccionaban un archivo.
Muchas gracias, esto ahorrara mucho trabajo, ya me toco meter uno por uno mas de 70 archivos.
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 ) )
...Un Saludo
Carlos G.
FiveWin 25.12 + Harbour 3.2.0dev (r2502110321), BCC 7.7 Windows 11 Home
Bueno se帽ores, quedo mas que genial ...
Slds