"Save As" dialog box

"Save As" dialog box

Postby Natter » Thu Jan 25, 2024 2:50 pm

Hi,

I need to simulate the "Save As" dialog box. How can I do this ?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: "Save As" dialog box

Postby karinha » Thu Jan 25, 2024 3:20 pm

I didn't quite understand what you meant. See if this example helps, or explain better, Please.

No entendí muy bien lo que querías decir. Vea si este ejemplo ayuda o explica mejor, por favor.


https://forums.fivetechsupport.com/viewtopic.php?f=3&t=15004&start=0

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: "Save As" dialog box

Postby Antonio Linares » Thu Jan 25, 2024 4:03 pm

Dear Yuri,

cFile := cGetFile32( "Prg Source (.prg) |.prg|", FWString( "Save as" ), 0, cPath, .T., .T. )

thanks to Cristobal
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: "Save As" dialog box

Postby Natter » Fri Jan 26, 2024 1:53 pm

Thanks !
Is it possible to create a folder selection dialog with the condition that files are visible (files themselves cannot be selected) ?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: "Save As" dialog box

Postby karinha » Fri Jan 26, 2024 3:29 pm

Explique mejor, PLS.

https://forums.fivetechsupport.com/viewtopic.php?f=3&t=36234&p=219403&hilit=saveas&sid=64bccd615f6d75bea96b4771a7079cec&sid=168e08ae3c54fd96991dd2d7d8af141f#p219403

Code: Select all  Expand view  RUN

// 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
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: "Save As" dialog box

Postby Natter » Fri Jan 26, 2024 4:34 pm

And here is cGetFile32, I need to select a folder ? :?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: "Save As" dialog box

Postby karinha » Fri Jan 26, 2024 5:09 pm

Natter wrote:And here is cGetFile32, I need to select a folder ? :?


maybe:

https://forums.fivetechsupport.com/viewtopic.php?f=3&t=15004&start=0

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: "Save As" dialog box

Postby Natter » Fri Jan 26, 2024 6:28 pm

This option allows you to select either a folder or a file.
Code: Select all  Expand view  RUN
#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. )

I need something similar, but without the option to select a file (folder files should be inactive)
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: "Save As" dialog box

Postby nageswaragunupudi » Fri Jan 26, 2024 10:00 pm

Is this not what you are looking for?
Code: Select all  Expand view  RUN
cDir := cGetDir( cTitle, [cInitDir] )
Regards

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

Re: "Save As" dialog box

Postby Natter » Sat Jan 27, 2024 7:28 am

cGetDir( cTitle, [cInitDir] ) shows only folders without files. I need the files of the folder to be visible, but without the possibility of selection
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: "Save As" dialog box

Postby karinha » Sat Jan 27, 2024 3:20 pm

If it's just to show the files, isn't it better to do it this way?

Si es solo para mostrar los archivos ¿no es mejor hacerlo así?

Code: Select all  Expand view  RUN

#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
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: "Save As" dialog box

Postby Natter » Sat Jan 27, 2024 5:20 pm

I can do that, but you're too lazy. :wink: I looked at everything BIF flags - except for BIF_BROWSEINCLUDEFILES there is nothing. I decided to stop there
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: "Save As" dialog box

Postby nageswaragunupudi » Sun Jan 28, 2024 5:06 pm

First attempt, using ShellAPI function SHBrowseForFolder()

Needs improvement with the guidance of masters.

Code: Select all  Expand view  RUN
#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();
}


Image

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.
Expecting experts to guide.
Regards

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

Re: "Save As" dialog box

Postby Jimmy » Sun Jan 28, 2024 9:19 pm

hi,
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
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: "Save As" dialog box

Postby nageswaragunupudi » Sun Jan 28, 2024 10:36 pm

you can test if it is a File or Folder which are select

Yes, this is only a workaround.
Mr. Natter expects that the user should not be able to select a file. In other words, the OK button to be grayed out so that the user can not select if the cursor is on a file, but can select only when the cursor is on a folder.
For this we need to use VALID with a callback function.
I expect some experts can do that.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 26 guests