Hi,
I need to simulate the "Save As" dialog box. How can I do this ?
// C:\FWH\SAMPLES\SAVEAS.PRG
#include "FiveWin.ch"
static oWnd
//----------------------------------------------------------------//
FUNCTION Main()
local oBar
DEFINE WINDOW oWnd TITLE "SALVAR COMO" // save as
DEFINE BUTTONBAR oBar _3D OF oWnd
DEFINE BUTTON OF oBar ACTION SALVAR_COMO()
SET MESSAGE OF oWnd TO "SALVAR COMO" NOINSET CLOCK DATE KEYBOARD
ACTIVATE WINDOW oWnd
RETURN NIL
FUNCTION SALVAR_COMO()
LOCAL cFile
/*
cFile := cGetFile32( , FWString("Save as"), 0, ;
hb_CurDrive() + ":\" + CurDir(), .T., .T. )
*/
cGetFile32( '*.TXT| *.TXT', "Save as", 0, 'c:\temp' , .T., .T. )
RETURN NIL
// FIN / END
Natter wrote:And here is cGetFile32, I need to select a folder ?
#define BIF_NONEWFOLDERBUTTON 0x0200
#define BIF_RETURNONLYFSDIRS 0x0001
#define BIF_DONTGOBELOWDOMAIN 0x0002
#define BIF_STATUSTEXT 0x0004
#define BIF_RETURNFSANCESTORS 0x0008
#define BIF_EDITBOX 0x0010
#define BIF_VALIDATE 0x0020
#define BIF_NEWDIALOGSTYLE 0x0040
#define BIF_USENEWUI (BIF_NEWDIALOGSTYLE|BIF_EDITBOX)
#define BIF_BROWSEINCLUDEURLS 0x0080
#define BIF_BROWSEFORCOMPUTER 0x1000
#define BIF_BROWSEFORPRINTER 0x2000
#define BIF_BROWSEINCLUDEFILES 0x4000
#define BIF_SHAREABLE 0x8000
itm:=cGetDir( OemToAnsi("Select folder or file"),,,, ;
BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_USENEWUI + ;
BIF_BROWSEINCLUDEFILES, .T. )
cDir := cGetDir( cTitle, [cInitDir] )
#include "FiveWin.Ch"
#include "Directry.ch"
#define CLR_LGREEN nRGB( 190, 215, 190 )
#define CLR_LGRAY nRGB( 230, 230, 230 )
#define CLR_VERMELHO nRGB( 255, 000, 000 )
#define CLR_AMARELO nRGB( 255, 255, 000 )
REQUEST OrdKeyNo, OrdKeyCount, OrdCreate, OrdKeyGoto
STATIC nBytes, nDisks
STATIC lnKeyEscape := .F.
FUNCTION Main()
LOCAL oSetupDlg, nDriveTo := 1, cDriveTo, nDriveCap := 4
LOCAL lGoOn, aFiles[ 1 ], aFileList, x, iDcor, oFont, oBackup
LOCAL oDlg, oBrw, n := 1
LOCAL oAceitar, oCancelar, nKey := VK_RETURN
LOCAL aDbfs := Directory( "*.DBF" )
// LOCAL aDbfs := DirectoryRecurse( "C:\FWH1701\*.*" )
// LOCAL aDbfs := DirectoryRecurse( "*.DBF" )
SET CENTURY ON
SET DATE BRITISH
SET TIME FORMAT TO "HH:MM:SS"
SET EPOCH TO Year( Date() ) - 30
SET SOFTSEEK OFF
SET WRAP ON
SetCancel( .F. )
SET CONFIRM OFF
SET DELETED ON
SET _3DLOOK ON
SET UNIQUE OFF
SET ESCAPE OFF
SET EXACT ON // CONTROLA O :=, = e ==
SET EXCLUSIVE OFF
SET MULTIPLE OFF
IF Len( aDbfs ) < 1
RETURN NIL
ENDIF
// aSort( aDbfs, , , { |x, y | x[1] < y[1] } )
ASort( aDbfs )
DEFINE FONT oFont NAME "Arial" SIZE 0, 16 BOLD
DEFINE DIALOG oDlg FROM 6, 20 TO 25, 90 ;
TITLE "Browse dos Arquivos DBFs em: " + ;
CurDir() + " Para Visualizar" ;
STYLE nOR( WS_BORDER, WS_THICKFRAME ) ;
COLORS CLR_BLACK, nRGB( 193, 205, 205 )
@ 1, 2 LISTBOX oBrw FIELDS aDbfs[ n ][ 1 ], ;
Str( aDbfs[ n ][ 2 ], 10, 0 ), ;
DToC( aDbfs[ n ][ 3 ] ), ;
aDbfs[ n ][ 4 ] ;
Headers "Nome do Arquivo", ;
"Tamanho", "Data", "Hora" ;
FieldSizes 270, 80, 80, 60 ;
COLOR CLR_HBLUE, CLR_AMARELO ;
FONT oFont ;
Of oDlg Size 260, 100
oBrw:bGotop := {|| N := 1 }
oBrw:bGoBottom := {|| N := Eval( oBrw:bLogicLen ) }
oBrw:bSkip := {| nWant, nOld | nOld := N, N += nWant, ;
N := Max( 1, Min( N, Eval( oBrw:bLogicLen ) ) ), ;
N - nOld }
oBrw:bLogicLen := {|| Len( aDbfs ) }
oBrw:cAlias := "Array"
oBrw:nClrBackHead := CLR_LGREEN
oBrw:nClrBackFocus := CLR_HRED
oBrw:nClrForeFocus := CLR_AMARELO
oBrw:nClrForeHead := CLR_HRED
oBrw:nColAct := 1
oBrw:nLineStyle := 3
oBrw:lCellStyle := .T.
oBrw:aJustify := { .F., .F., .F., .F. }
oBrw:lMChange := .F.
oBrw:SetFocus()
oBrw:Refresh()
@ 6.6, 20 Button oBackup PROMPT "&Exit" Of oDlg ;
ACTION( oDlg:End() ) SIZE 40, 12 CANCEL
ACTIVATE DIALOG oDlg CENTERED
oFont:End()
RETURN NIL
// FIN / END
#include "fivewin.ch"
function Main()
? "start"
? shbrwfolders( "c:\fwh" )
? "done"
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <shlobj.h>
#include <stdio.h>
#include <hbapi.h>
#include <fwh.h>
HB_FUNC( SHBRWFOLDERS ) // ( cInitDir ) --> cSelectedFolder
{
LPITEMIDLIST pidl;
PIDLIST_ABSOLUTE pDir;
// Set up BROWSEINFO structure
BROWSEINFO bi = { 0 };
bi.hwndOwner = NULL; // Set to your application's main window if available
bi.pidlRoot = NULL; // Set to a specific folder to start from, if desired
bi.pszDisplayName = NULL;
bi.lpszTitle = "Select a Folder";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_BROWSEINCLUDEFILES ; // Flags for dialog options
// Initialize COM library
CoInitialize(NULL);
if ( HB_ISCHAR( 1 ) ) {
if ( SHParseDisplayName( fw_parWide( 1 ), NULL, &pDir, 0, NULL) == S_OK ) {
bi.pidlRoot = pDir;
}
}
// Display the Browse for Folder dialog
pidl = SHBrowseForFolder(&bi);
// Check if a folder was selected
if (pidl != NULL) {
// Get the path of the selected folder
char path[MAX_PATH];
if (SHGetPathFromIDList(pidl, path)) {
hb_retc( path );
} else {
hb_retc( "" );
}
// Free the ITEMIDLIST
CoTaskMemFree(pidl);
} else {
hb_retc( "" );
}
// Uninitialize COM library
CoUninitialize();
}
nageswaragunupudi wrote:The problem still remains. User can select a normal File also, even though the flag BIF_RETURNONLYFSDIRS is set when the flag BIF_BROWSEINCLUDEFILES is added.
you can test if it is a File or Folder which are select
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 37 guests