PFILEDLG fileDlg(HWND hwnd, PSZ pszFile, PSZ pszext, PSZ pszTitle, PSZ pszBtn,
                 ULONG fl) {
   PFILEDLG pfdlg = NULL;
   PSZ pszret = NULL;
   ULONG afl[] = {FDS_OPEN_DIALOG,
                  FDS_OPEN_DIALOG | FDS_MULTIPLESEL,
                  FDS_SAVEAS_DIALOG | FDS_ENABLEFILELB};
   if (!(pfdlg = (PFILEDLG)malloc(sizeof(FILEDLG)))) {
      Wprint(hwnd, SZERR_ALLOC, 0);
      return NULL;
   } /* endif */
   memset((PVOID)pfdlg, 0, sizeof(FILEDLG));
   pfdlg->pszTitle = pszTitle;
   pfdlg->pszOKButton = pszBtn;
   pfdlg->cbSize = sizeof(FILEDLG);
   pfdlg->pfnDlgProc = fl == 2? saveFileProc: NULL;
   pfdlg->fl = FDS_CENTER | afl[fl];
   strcpy(pfdlg->szFullFile, pszFile);
   strcpy(ioFNameFromPath(pfdlg->szFullFile), pszext);
   if (WinFileDlg(HWND_DESKTOP, hwnd, pfdlg) &&
       pfdlg->lReturn == DID_OK) {
      strcpy(pszFile, pfdlg->szFullFile);
      if (fl != 1) {   // se non Š file dialog multiplo libera allocazione ora
         free(pfdlg);
         return (PFILEDLG)1;
      } /* endif */
      return pfdlg;
   } // end if
   free(pfdlg);
   return NULL;
}
PSZ OFileDialog::saveAs(PSZ title,
                        PSZ initialPath,
                        PSZ initialFileName,
                        OFileDialog::styles style)
{
 if (lastPath)
   strcpy(fileDialog.szFullFile, lastPath);

 if (initialPath)
   strcpy(fileDialog.szFullFile, initialPath);

 strcat(fileDialog.szFullFile, "\\");
 if (initialFileName)
   strcat(fileDialog.szFullFile, initialFileName);

 fileDialog.fl          = FDS_SAVEAS_DIALOG | style;
 fileDialog.pszTitle    = title;

 if (!WinFileDlg(parent, owner, (PFILEDLG)&fileDialog))
   throw OPMException(OCL::error(OCL_OFILEDLG_SHOW), 0);

 if (fileDialog.lReturn == DID_OK)
  {
   lastFile << fileDialog.szFullFile;
   lastPath << fileDialog.szFullFile;
   lastPath.rightCut('\\');
   return(lastFile);
  }
 else
  return(NULL);
}
//----------------------------------
// Event EV_BN_CLICKED for ID_BROWSE
//----------------------------------
void SetTool::Browse(int id, int idname, char *toolnum)
{
    /*****************************************************************/
    /* Initially set all fields to 0                                 */
    /*****************************************************************/
    FILEDLG fild;                                     // File dialog info structure
    char pszFullFile[CCHMAXPATH] = "*.EXE;*.CMD;*.BAT;*.COM";     // File filter string
    memset(&fild, 0, sizeof(FILEDLG));

    /*****************************************************************/
    /* Initialize those fields in the FILEDLG structure that are     */
    /* used by the application                                       */
    /*****************************************************************/
    fild.cbSize = sizeof(FILEDLG);            // Size of structure
    fild.fl = FDS_CENTER | FDS_OPEN_DIALOG;

    char name[80+1];
    GetDlgItemText(idname,name,80);
    char title[128+1];
    sprintf(title,"Tool #%s -- %s",toolnum,name);
                                                    // FDS_* flags
    fild.pszTitle = title;                          // Dialog title string
    strcpy(fild.szFullFile, pszFullFile);           // Initial path,
                                                    // file name, or
                                                    // file filter

    /*****************************************************************/
    /* Display the dialog and get the file                           */
    /*****************************************************************/
    HWND  hwndDlg = WinFileDlg(HWND_DESKTOP, HWindow, &fild);
    if (hwndDlg && (fild.lReturn == DID_OK))
    {
        SetDlgItemText(id,fild.szFullFile);
    }
}
PSZ OFileDialog::open(PSZ title,
                      PSZ initialPath,
                      PSZ fileMask,
                      OFileDialog::styles style)
{
 if (lastPath)
   strcpy(fileDialog.szFullFile, lastPath);

 if (initialPath)
   strcpy(fileDialog.szFullFile, initialPath);

 if (fileMask) {
   strcat(fileDialog.szFullFile, "\\");
   strcat(fileDialog.szFullFile, fileMask); }

 fileDialog.fl          = FDS_OPEN_DIALOG | style;
 fileDialog.pszTitle    = title;
 fileDialog.pszOKButton = "~OK";

 if (!WinFileDlg(parent, owner, (PFILEDLG)&fileDialog))
   throw OPMException(OCL::error(OCL_OFILEDLG_SHOW), 0);

 if (fileDialog.lReturn == DID_OK)
  {
   lastFile << fileDialog.szFullFile;
   lastPath << fileDialog.szFullFile;
   lastPath.rightCut('\\');
   return(lastFile);
  }
 else
  return(NULL);
}
Exemple #5
0
ULONG HEImport( HWND hwnd )
{
FILEDLG FDialog;
char    szTitle[100];
char    *buf;
ULONG   size;
ULONG   hanType = (ULONG)WinSendMsg(hwndHMLE,HMLM_QUERYHANTYPE,0L,0L);

    if( WinSendMsg( hwndHMLE, HMLM_QUERYREADONLY, 0, 0 ))
        return 0L;

    strcpy(szTitle,"Import");

    strcpy(FDialog.szFullFile,"*.*");

    FDialog.cbSize = sizeof(FILEDLG);
    FDialog.pszTitle = szTitle;
    FDialog.pszOKButton = szTitle;
    FDialog.ulUser = 0;
    FDialog.fl = FDS_CENTER | FDS_OPEN_DIALOG; //| FDS_ENABLEFILELB;
    FDialog.pfnDlgProc = (PFNWP) NULL;
    FDialog.lReturn = 0;
    FDialog.lSRC = 0;
    FDialog.hMod = (HMODULE) 0;
    FDialog.usDlgId = IDD_FILEOPEN;
    FDialog.x   = 0;
    FDialog.y   = 0;
    FDialog.pszIType    = NULL;
    FDialog.papszITypeList  = NULL;
    FDialog.pszIDrive   = NULL;
    FDialog.papszIDriveList = NULL;
    FDialog.sEAType         = 0;
    FDialog.papszFQFilename = NULL;
    FDialog.ulFQFCount  = 0;

    if (!WinFileDlg(HWND_DESKTOP,hwnd,(PFILEDLG)&FDialog))
        return 1;
    if (FDialog.lReturn != DID_OK)
        return 1;

    size = fileRead2Buf( FDialog.szFullFile, &buf );
    if( buf == NULL )
        return 1;

    WinSendMsg(hwndHMLE,HMLM_SETHANTYPE,MPFROMLONG( queryHanTypeBuf( buf )),0L);
    WinSendMsg(hwndHMLE,HMLM_SETIMPORTEXPORT,buf,MPFROMLONG(size+1));
    WinSendMsg(hwndHMLE,HMLM_IMPORT,0,0);
    WinSendMsg(hwndHMLE,HMLM_SETHANTYPE,MPFROMLONG( hanType ),0L);

    WinPostMsg(hwndStatbar,STATBAR_USERM_SETMODIFIED, MPFROMLONG( TRUE ),0L);
    WinPostMsg(hwndHMLE,HMLM_SETCHANGED, MPFROMLONG( TRUE ),0);
    WinPostMsg(hwndHMLE,HMLM_REFRESH,0,0);

    free( buf );

    return 0L;
}
BOOL FileSettingsSelection(HWND hwnd, PSZ pDefaultFile, PSZ pTitle, PSZ pFilter)
{

 FILEDLG FileDlg;                       /* File dialog info structure   */
 HWND hwndDlg;                          /* File dialog window           */
 BOOL rc = FALSE;
 CHAR Temp[CCHMAXPATH] = "", *p;

 /*****************************************************************/
 /* Initially set all fields to 0                                 */
 /*****************************************************************/

 memset(&FileDlg, 0, sizeof(FILEDLG));

 /*****************************************************************/
 /* Initialize those fields in the FILEDLG structure that are     */
 /* used by the application                                       */
 /*****************************************************************/

 FileDlg.cbSize = sizeof(FILEDLG);           /* Size of structure    */
 FileDlg.fl =  FDS_CENTER | FDS_OPEN_DIALOG;
                                             /* FDS_* flags          */
 FileDlg.pszTitle = pTitle;                  /* Dialog title string  */
 strcpy(FileDlg.szFullFile, pFilter);        /* Initial path,        */
                                             /* file name, or        */
                                             /* file filter          */

 if ((0 == strcmp(PathBuffer, "")) &&
     (0 != strcmp(pDefaultFile, "")) &&
     (NULL != pDefaultFile)
    )
  strcpy(PathBuffer, pDefaultFile);

 if (0 != strcmp(PathBuffer, ""))
 {
   strcpy(Temp, PathBuffer);
   p = strrchr(PathBuffer, '\\');
   if (NULL != p)
    *p = '\0';
   FileDlg.pszIDrive = PathBuffer;
 }

 hwndDlg = WinFileDlg(HWND_DESKTOP, hwnd, &FileDlg);

 if (hwndDlg && (FileDlg.lReturn == DID_OK))
 {
  strcpy(pDefaultFile, strupr(FileDlg.szFullFile));
  strcpy(PathBuffer, pDefaultFile);
  rc = TRUE;
 }
 else
 {
  strcpy(PathBuffer, Temp);
 }

 return rc;
}
Exemple #7
0
void ViceFileDialog(HWND hwnd, ULONG action, ULONG fl)
{
    FILEDLG filedlg; // File dialog info structure
    const char *dat = filedlg.szFullFile + 2;
    static char drive[3] = "f:";
    static char path[CCHMAXPATH - 2] = "\\c64\\images";
    char wdir[CCHMAXPATH];            // working directory
    char odir[CCHMAXPATH];            // original directory

    ULONG rc;
    //
    // check for existance of directory
    //
    _getcwd(odir, CCHMAXPATH);         // store working dir

    strcat(strcpy(wdir, drive),path);
    if (chdir(wdir)) {
        drive[0] = odir[0];
        drive[1] = ':';
        strcpy(path, odir + 2);
    }
    chdir(odir);                       // change back to working dir

    //
    // Setup 'MUST' values
    //
    memset(&filedlg, 0, sizeof(FILEDLG)); // Initially set all fields to 0
    filedlg.cbSize = sizeof(FILEDLG);
    filedlg.fl = FDS_CENTER | FDS_CUSTOM | fl;
    filedlg.usDlgId = DLG_FILEIO;
    filedlg.pfnDlgProc = ViceFileDlgProc;
    filedlg.pszTitle = fl & FDS_OPEN_DIALOG ? "Open File" : "Save as";
    filedlg.pszOKButton = fl & FDS_OPEN_DIALOG ? "Apply" : "Save";
    filedlg.pszIDrive = drive;
    filedlg.ulUser = action;

    strcat(strcpy(filedlg.szFullFile, path), "\\");

    //
    // let the file dialog do it's work
    //
    rc = WinFileDlg(HWND_DESKTOP, hwnd, &filedlg);

    //
    // if error or not 'Attach' button
    //
    if (!rc || filedlg.lReturn != DID_OK) {
        return;
    }

    //
    // if the result was ok store the path
    //
    drive[0] = filedlg.szFullFile[0];
    strcpy(path, dat);
}
/**************************************************************************
 *
 *  Name       : GetFileName()
 *
 *  Description: gets the name of the save file
 *
 *  Concepts:    called when the user needs to supply a name for
 *               the file to be saved
 *
 *                calls the standard file open dialog to get the
 *               file name.
 *
 *  API's      : WinLoadString
 *               WinFileDlg
 *
 *  Parameters : [none]
 *
 *  Return     :  TRUE if successful in getting a file name
 *                FALSE if not successful in getting a file name
 *
 *************************************************************************/
BOOL GetFileName(VOID)
{
   FILEDLG fdg;
   CHAR szTitle[MESSAGELEN], szButton[MESSAGELEN];

   fdg.cbSize = sizeof(FILEDLG);

   if(!WinLoadString(hab, 0, IDS_SAVE, MESSAGELEN, szTitle))
   {
       MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, TRUE);
       return FALSE;
   }

   if(!WinLoadString(hab, 0, IDS_SAVE, MESSAGELEN, szButton))
   {
       MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, TRUE);
       return FALSE;
   }

   fdg.pszTitle = szTitle;
   fdg.pszOKButton = szButton;

   fdg.ulUser = 0L;
   fdg.fl = FDS_HELPBUTTON | FDS_CENTER | FDS_SAVEAS_DIALOG;
   fdg.pfnDlgProc = (PFNWP)TemplateSaveFilterProc;
   fdg.lReturn = 0L;
   fdg.lSRC = 0L;
   fdg.hMod = (HMODULE)NULL;
   fdg.usDlgId = FILESAVE;
   fdg.x = 0;
   fdg.y = 0;
   fdg.pszIType = (PSZ)NULL;
   fdg.papszITypeList = (PAPSZ)NULL;
   fdg.pszIDrive = (PSZ)NULL;
   fdg.papszIDriveList = (PAPSZ)NULL;
   fdg.sEAType = (SHORT)0;
   fdg.papszFQFilename = (PAPSZ)NULL;
   fdg.ulFQFCount = 0L;

   strcpy(fdg.szFullFile, szFullPath);

   /* get the file */
   if(!WinFileDlg(HWND_DESKTOP, hwndMain, &fdg))
       return FALSE;

   if(fdg.lReturn != ID_OK)
       return FALSE;

   /* copy file name and path returned into buffers */
   strcpy(szFullPath, fdg.szFullFile);

   return TRUE;
}   /* End of GetFileName   */
void NextBarDlg::loadProgram()
{
 FILEDLG     fdFileDlg;
 HWND        hwndFileDlg;

 memset(&fdFileDlg, 0, sizeof(FILEDLG));
 fdFileDlg.cbSize=sizeof(FILEDLG);
 fdFileDlg.fl=FDS_CENTER | FDS_OPEN_DIALOG;
 fdFileDlg.pszTitle="NextHand 1.5 - Configuration";
 strcpy(fdFileDlg.szFullFile, "C:\\*");
 hwndFileDlg=WinFileDlg(HWND_DESKTOP, hwnd, &fdFileDlg);
 if (hwndFileDlg && (fdFileDlg.lReturn==DID_OK))
    install2Dialog(fdFileDlg.szFullFile, FALSE);
}
//=============================================================================
// GetFileName - подпрограмма вызова диалога Save As ...
//=============================================================================
BOOL GetFileName(char *path)
{
   static HWND hwndMLE;
   FILEDLG fileDialog;
   CHAR szButton[] = "Ok";
   char title[] = "Set name for saving LanScan results as TEXT file";

   fileDialog.cbSize = sizeof(FILEDLG);       // Size of FILEDLG structure
   fileDialog.fl = FDS_SAVEAS_DIALOG | FDS_ENABLEFILELB; // FDS_ flags.
   fileDialog.ulUser = 0UL;           // User defined field
   fileDialog.lReturn = 0L;           // Result code from dialog dismissal
   fileDialog.lSRC = 0L;              // System return code
   fileDialog.pszTitle = title;     // String to display in title bar
   fileDialog.pszOKButton = szButton; // String to display in OK button
   fileDialog.pfnDlgProc = NULL;      // Entry point to custom dialog proc.
   fileDialog.pszIType = NULL;        // Pointer to string containing initial
                                      // EA type filter. Type does not have
                                      // to exist in list.
   fileDialog.papszITypeList = NULL;  // Pointer to table of pointers that
                                      // point to null terminated Type strings.
                                      // End of table is marked by a NULL ptr.
   fileDialog.pszIDrive = NULL;  // Pointer to string containing initial drive.
                                 // Drive does not have to exist in drive list.
   fileDialog.papszIDriveList = NULL; // Pointer to table of pointers that
                                      // point to null terminated Drive strings
                                      // End of table is marked by a NULL ptr.
   fileDialog.hMod = (HMODULE)0;              // Custom File Dialog template
   strcpy(fileDialog.szFullFile, path);       // Initial or selected fully
                                              // qualified path and file.
   fileDialog.papszFQFilename = NULL; // Pointer to table of pointers that
                                      // point to null terminated FQFname
                                      // strings. End of table is marked
                                      // by a NULL pointer.
   fileDialog.ulFQFCount = 0UL;               // Number of files selected
   fileDialog.usDlgId = IDD_FILESAVE;         // Custom dialog id.
   fileDialog.x = 0;                          // X coordinate of the dialog
   fileDialog.y = 0;                          // Y coordinate of the dialog
   fileDialog.sEAType = 0;                    // Selected file's EA Type.
//-----------------------------------------------------------------------------
// Get the file name
//-----------------------------------------------------------------------------
   if (!WinFileDlg(HWND_DESKTOP, hwndMLE, (PFILEDLG)&fileDialog)) return FALSE;
   if (fileDialog.lReturn != DID_OK) return FALSE;
//-----------------------------------------------------------------------------
// Copy file name and path returned into buffers
//-----------------------------------------------------------------------------
   strcpy(path, fileDialog.szFullFile);
   return TRUE;
}
BOOL GetAttachedFiles(HWND hwndOwner, char *pchSubject, char *pchDefaultDir)
{
   FILEDLG FileDlg;
   BOOL rc=FALSE;

   memset(&FileDlg, 0, sizeof(FileDlg));

   FileDlg.cbSize = sizeof(FileDlg);
   FileDlg.fl = FDS_CENTER | FDS_HELPBUTTON | FDS_MULTIPLESEL | FDS_OPEN_DIALOG;
   FileDlg.pszTitle = calloc(1, 200);
   LoadString(IDST_TITLE_ATTACHFILES, 200, FileDlg.pszTitle);

   if (pchDefaultDir[0])
   {
      strcpy(FileDlg.szFullFile, pchDefaultDir);
      strcat(FileDlg.szFullFile, "\\*");
   }

   if (WinFileDlg(HWND_DESKTOP, hwndOwner, &FileDlg) &&
       FileDlg.lReturn == DID_OK)
   {
      if (FileDlg.ulFQFCount && FileDlg.papszFQFilename)
      {
         int iFile=0;

         while (iFile < FileDlg.ulFQFCount)
         {
            if (strlen(pchSubject) +
                strlen(*FileDlg.papszFQFilename[iFile]) +
                (*pchSubject ? 1:0) <= LEN_SUBJECT)  /* noch genug Platz */
            {
               /* Name anhaengen */
               if (*pchSubject)
                  strcat(pchSubject, " ");
               strcat(pchSubject, *FileDlg.papszFQFilename[iFile]);
               iFile++;
            }
            else
               break; /* kein Platz, sofort beenden */
         }

         WinFreeFileDlgList(FileDlg.papszFQFilename);
         rc= TRUE;
      }
   }

   free(FileDlg.pszTitle);
   return rc;
}
/*---------------------------------------------------------------------------
                                 CmdSaveAs
---------------------------------------------------------------------------*/
void CmdSaveAs( WNDATTR *wndattr )
{
 char *filename;

   FileDlg.cbSize = sizeof( FILEDLG );
   FileDlg.fl = FDS_CENTER | FDS_SAVEAS_DIALOG | FDS_ENABLEFILELB;

   WinFileDlg( HWND_DESKTOP, wndattr->Client, &FileDlg );

   filename = &( FileDlg.szFullFile );
   if (*filename == '\0' || FileDlg.lReturn != DID_OK)
      return;

   SaveList( filename, wndattr->list, FALSE, TRUE );

   return;
}
Exemple #13
0
ULONG HEOpen(HWND hwnd)
{
FILEDLG FDialog;
char    szTitle[100];

    if (WinSendMsg(hwndHMLE,HMLM_QUERYCHANGED,0L,0L))
        {
        if (WinMessageBox(
                HWND_DESKTOP,hwnd,
                "Document changed. Discard it?","Caution",
                0,MB_YESNO|MB_DEFBUTTON2|MB_WARNING|MB_MOVEABLE)==MBID_NO)
            return 0L;
        }
    strcpy(szTitle,"Open");

    strcpy(FDialog.szFullFile,"*.*");

    FDialog.cbSize = sizeof(FILEDLG);
    FDialog.pszTitle = szTitle;
    FDialog.pszOKButton = szTitle;
    FDialog.ulUser = 0;
    FDialog.fl = FDS_CENTER | FDS_OPEN_DIALOG; //| FDS_ENABLEFILELB;
    FDialog.pfnDlgProc = (PFNWP) NULL;
    FDialog.lReturn = 0;
    FDialog.lSRC = 0;
    FDialog.hMod = (HMODULE) 0;
    FDialog.usDlgId = IDD_FILEOPEN;
    FDialog.x   = 0;
    FDialog.y   = 0;
    FDialog.pszIType    = NULL;
    FDialog.papszITypeList  = NULL;
    FDialog.pszIDrive   = NULL;
    FDialog.papszIDriveList = NULL;
    FDialog.sEAType         = 0;
    FDialog.papszFQFilename = NULL;
    FDialog.ulFQFCount  = 0;

    if (!WinFileDlg(HWND_DESKTOP,hwnd,(PFILEDLG)&FDialog))
        return 1;
    if (FDialog.lReturn != DID_OK)
        return 1;

    HEFileOpenWithAutoHanCode(hwnd,FDialog.szFullFile,TRUE);

    return 0L;
}
Exemple #14
0
/*
 * getSaveFName - Get the name of the file to be saved.
 */
static bool getSaveFName( char *fname, int imgtype )
{
    FILEDLG             filedlg;
    char                ext[ _MAX_EXT ];
    char                drive[ _MAX_DRIVE ];
    char                path[ _MAX_PATH ];
    HWND                hdlg;
    char                fullfile[ CCHMAXPATH ];

    fname[ 0 ] = 0;
    memset( &filedlg, 0, sizeof( FILEDLG ) );
    strcpy( fullfile, initialDir );
    if( fullfile[strlen( fullfile ) - 1] != '\\' ) {
        strcat( fullfile, "\\" );
    }
    if( imgtype == BITMAP_IMG ) {
        strcat( fullfile, "*.bmp" );
    } else if( imgtype == ICON_IMG ) {
        strcat( fullfile, "*.ico" );
    } else {
        strcat( fullfile, "*.ptr" );
    }

    /*
     * set the values of the filedlg structure ...
     */
    filedlg.cbSize = sizeof( FILEDLG );
    filedlg.fl = FDS_SAVEAS_DIALOG | FDS_CENTER;
    filedlg.pszTitle = "Save Image File";
    filedlg.pszOKButton = "Save";
    strcpy( filedlg.szFullFile, fullfile );

    hdlg = WinFileDlg( HWND_DESKTOP, HMainWindow, &filedlg );

    if( ( hdlg == NULLHANDLE ) || ( filedlg.lReturn != DID_OK ) ) {
        return( false );
    }

    strcpy( fname, filedlg.szFullFile );
    _splitpath( fname, drive, path, NULL, ext );
    strcpy( initialDir, drive );
    strcat( initialDir, path );
    initialDir[strlen( initialDir ) - 1] = '\0';
    return( true );
} /* getSaveFName */
/*---------------------------------------------------------------------------
                               CmdAppendFile
---------------------------------------------------------------------------*/
void CmdAppendFile( WNDATTR *wndattr )
{
 char *filename;


   FileDlg.cbSize = sizeof( FILEDLG );
   FileDlg.fl = FDS_CENTER | FDS_OPEN_DIALOG;

   WinFileDlg( HWND_DESKTOP, wndattr->Client, &FileDlg );

   filename = FileDlg.szFullFile;
   if (FileDlg.lReturn == DID_OK) {
      if (*filename != '\0') {
         AppendFile( wndattr, filename, TRUE, NULLHANDLE );
      }
   }

   return;
}
Exemple #16
0
/*
 * _SaveAllLines - save all lines to a file
 */
void _SaveAllLines( LPWDATA w )
{
    char                fname[CCHMAXPATH + 1];
    FILEDLG             fdlg;
    HWND                hwmenu;
    FILE                *f;
    LPLDATA             ld;

    /*
     * go get file name
     */
    fname[0] = 0;
    memset( &fdlg, 0, sizeof( FILEDLG ) );
    fdlg.cbSize = sizeof( FILEDLG );
    fdlg.fl = FDS_SAVEAS_DIALOG | FDS_CENTER | FDS_PRELOAD_VOLINFO | FDS_ENABLEFILELB;
    fdlg.pszTitle = "Save File Name Selection";
    fdlg.pszOKButton = "~Save";
    strcpy( fdlg.szFullFile, "*.*" );

    hwmenu = WinWindowFromID( _MainFrameWindow, FID_MENU );
    if( WinFileDlg( HWND_DESKTOP, hwmenu, &fdlg ) ) {
        /*
         * save lines
         */
        if( fdlg.lReturn != DID_OK ) {
            return;
        }
        f = fopen( fdlg.szFullFile, "w" );
        if( f == NULL ) {
            _Error( hwmenu, fdlg.szFullFile, "Error opening file" );
            return;
        }
        for( ld = w->LineHead; ld != NULL; ld = ld->next ) {
            fprintf( f,"%s\n", ld->data );
        }
        fclose( f );
        _Error( hwmenu, fdlg.szFullFile, "Data saved to file" );
    } else {
        _Error( hwmenu, "Error", "Could not create dialog box" );
    }

} /* _SaveAllLines */
//----------------------------------
//  'User Function' private: FileOpen
//----------------------------------
PAPSZ ProjWin::FileOpen(void)
{
    static char Directory[MAXPATHSIZE];
    /*****************************************************************/
    /* Initially set all fields to 0                                 */
    /*****************************************************************/
    static FILEDLG fild;                                    // File dialog info structure
    char pszFullFile[CCHMAXPATH];
    strcpy(pszFullFile,Directory);
    strcat(pszFullFile,"*.c*;*.h*;*.rc;*.inc");             // File filter string
    memset(&fild, 0, sizeof(FILEDLG));

    /*****************************************************************/
    /* Initialize those fields in the FILEDLG structure that are     */
    /* used by the application                                       */
    /*****************************************************************/
    fild.cbSize = sizeof(FILEDLG);            // Size of structure
    fild.fl = FDS_CENTER | FDS_OPEN_DIALOG |FDS_MULTIPLESEL;

                                                    // FDS_* flags
    fild.pszTitle = "Add Path/File To Project List";// Dialog title string
    strcpy(fild.szFullFile, pszFullFile);           // Initial path,
                                                    // file name, or
                                                    // file filter

    /*****************************************************************/
    /* Display the dialog and get the file                           */
    /*****************************************************************/
    HWND  hwndDlg = WinFileDlg(HWND_DESKTOP, HWindow, &fild);
    if (hwndDlg && (fild.lReturn == DID_OK))
    {
        char dummy[MAXPATHSIZE];
        PathSplit(Directory,dummy,fild.szFullFile);   // remember directory
        return( fild.papszFQFilename );
    }
    return(NULL);
}
Exemple #18
0
char *ViceFileSelect(HWND hwnd, int save)
{
    FILEDLG filedlg;
    ULONG rc;

    //
    // Setup 'MUST' values
    //
    memset(&filedlg, 0, sizeof(FILEDLG)); // Initially set all fields to 0
    filedlg.cbSize = sizeof(FILEDLG);

    filedlg.fl = FDS_CENTER | FDS_CUSTOM | (save == 1) ? FDS_SAVEAS_DIALOG : FDS_OPEN_DIALOG;
    filedlg.usDlgId = 0;
    filedlg.pfnDlgProc = (PFNWP)NULL;
    filedlg.pszTitle = (save == 1) ? "Save as" : "Open File";
    filedlg.pszOKButton = (save == 1) ? "Save" : "Apply";
    filedlg.pszIDrive = "c:";
    filedlg.ulUser = 0L;

    //
    // let the file dialog do it's work
    //
    rc = WinFileDlg(HWND_DESKTOP, hwnd, &filedlg);

    //
    // if error or not 'Attach' button
    //
    if (!rc || filedlg.lReturn != DID_OK) {
        return NULL;
    }

    //
    // if the result was ok return the path
    //
    return lib_stralloc(filedlg.szFullFile[0]);
}
Exemple #19
0
//-------------------------------------------------------------------------
//
// Show - Display the file dialog
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval)
{
  NS_ENSURE_ARG_POINTER(retval);

  PRBool result = PR_FALSE;
  nsCAutoString fileBuffer;
  char *converted = ConvertToFileSystemCharset(mDefault);
  if (nsnull == converted) {
    LossyCopyUTF16toASCII(mDefault, fileBuffer);
  }
  else {
    fileBuffer.Assign(converted);
    nsMemory::Free( converted );
  }

  char *title = ConvertToFileSystemCharset(mTitle);
  if (nsnull == title)
    title = ToNewCString(mTitle);
  nsCAutoString initialDir;
  if (mDisplayDirectory)
    mDisplayDirectory->GetNativePath(initialDir);
  // If no display directory, re-use the last one.
  if(initialDir.IsEmpty())
    initialDir = mLastUsedDirectory;

  mFile.Truncate();

  FILEDLG filedlg;
  memset(&filedlg, 0, sizeof(FILEDLG));
  filedlg.cbSize = sizeof(FILEDLG);
  filedlg.pszTitle = title;

  if (mMode == modeGetFolder) {
    PL_strncat(filedlg.szFullFile, initialDir.get(), MAX_PATH);
    PL_strncat(filedlg.szFullFile, "\\", 1);
    PL_strncat(filedlg.szFullFile, "^", 1);
    filedlg.fl = FDS_OPEN_DIALOG | FDS_CENTER;
    filedlg.pfnDlgProc = DirDialogProc;
    DosError(FERR_DISABLEHARDERR);
    WinFileDlg(HWND_DESKTOP, mWnd, &filedlg);
    DosError(FERR_ENABLEHARDERR);
    char* tempptr = strstr(filedlg.szFullFile, "^");
    if (tempptr)
      *tempptr = '\0';
    if (filedlg.lReturn == DID_OK) {
      result = PR_TRUE;
      if (!mDisplayDirectory)
        mDisplayDirectory = do_CreateInstance("@mozilla.org/file/local;1");
      if (mDisplayDirectory)
        mDisplayDirectory->InitWithNativePath(nsDependentCString(filedlg.szFullFile));
      mFile.Assign(filedlg.szFullFile);
    }
  }
  else {
    PL_strncpy(filedlg.szFullFile, initialDir.get(), MAX_PATH);
    PL_strncat(filedlg.szFullFile, "\\", 1);
    PL_strncat(filedlg.szFullFile, fileBuffer.get(), MAX_PATH);
    filedlg.fl = FDS_CENTER;
    if (mMode == modeSave) {
       filedlg.fl |= FDS_SAVEAS_DIALOG | FDS_ENABLEFILELB;
    } else if (mMode == modeOpenMultiple) {
       filedlg.fl |= FDS_MULTIPLESEL | FDS_OPEN_DIALOG;
    } else {
       filedlg.fl |= FDS_OPEN_DIALOG;
    }
    PMYDATA pmydata;
    pmydata = (PMYDATA)calloc(1, sizeof(MYDATA));
    filedlg.ulUser = (ULONG)pmydata;
    filedlg.pfnDlgProc = FileDialogProc;

    PRUint32 i;

    PSZ *apszTypeList;
    apszTypeList = (PSZ *)malloc(mTitles.Length()*sizeof(PSZ)+1);
    for (i = 0; i < mTitles.Length(); i++)
    {
      const nsString& typeWide = mTitles[i];
      nsAutoCharBuffer buffer;
      PRInt32 bufLength;
      WideCharToMultiByte(0, typeWide.get(), typeWide.Length(),
                          buffer, bufLength);
      apszTypeList[i] = ToNewCString(nsDependentCString(buffer.Elements()));
    }
    apszTypeList[i] = 0;
    filedlg.papszITypeList = (PAPSZ)apszTypeList;

    PSZ *apszFilterList;
    apszFilterList = (PSZ *)malloc(mFilters.Length()*sizeof(PSZ)+1);
    for (i = 0; i < mFilters.Length(); i++)
    {
      const nsString& filterWide = mFilters[i];
      apszFilterList[i] = ToNewCString(filterWide);
    }
    apszFilterList[i] = 0;
    pmydata->papszIFilterList = (PAPSZ)apszFilterList;

    pmydata->ulCurExt = mSelectedType;

    PRBool fileExists;
    do {
      DosError(FERR_DISABLEHARDERR);
      WinFileDlg(HWND_DESKTOP, mWnd, &filedlg);
      DosError(FERR_ENABLEHARDERR);
      if ((filedlg.lReturn == DID_OK) && (mMode == modeSave)) {
         PRFileInfo64 fileinfo64;
         PRStatus status = PR_GetFileInfo64(filedlg.szFullFile, &fileinfo64);
         if (status == PR_SUCCESS) {
            fileExists = PR_TRUE;
         } else {
            fileExists = PR_FALSE;
         }
         if (fileExists) {
            if (!gpszFDSaveCaption) {
              HMODULE hmod;
              char LoadError[CCHMAXPATH];
              char loadedString[256];
              int length;
              DosLoadModule(LoadError, CCHMAXPATH, "PMSDMRI", &hmod);
              length = WinLoadString((HAB)0, hmod, 1110, 256, loadedString);
              gpszFDSaveCaption = (char*)malloc(length+1);
              strcpy(gpszFDSaveCaption, loadedString);
              length = WinLoadString((HAB)0, hmod, 1135, 256, loadedString);
              gpszFDFileExists = (char*)malloc(length+1);
              strcpy(gpszFDFileExists, loadedString);
              length = WinLoadString((HAB)0, hmod, 1136, 256, loadedString);
              gpszFDFileReadOnly = (char*)malloc(length+1);
              strcpy(gpszFDFileReadOnly, loadedString);
              int i;
              for (i=0;i<256 && gpszFDFileExists[i];i++ ) {
                if (gpszFDFileExists[i] == '%') {
                  gpszFDFileExists[i+1] = 's';
                  break;
                }
              }
              for (i=0;i<256 && gpszFDFileReadOnly[i];i++ ) {
                if (gpszFDFileReadOnly[i] == '%') {
                  gpszFDFileReadOnly[i+1] = 's';
                  break;
                }
              }
              DosFreeModule(hmod);

            }
            char pszFullText[256+CCHMAXPATH];
            FILESTATUS3 fsts3;
            ULONG ulResponse;
            DosQueryPathInfo( filedlg.szFullFile, FIL_STANDARD, &fsts3, sizeof(FILESTATUS3));
            if (fsts3.attrFile & FILE_READONLY) {
              sprintf(pszFullText, gpszFDFileReadOnly, filedlg.szFullFile);
              ulResponse = WinMessageBox(HWND_DESKTOP, mWnd, pszFullText,
                                               gpszFDSaveCaption, 0,
                                               MB_OK | MB_MOVEABLE | MB_WARNING);
            } else {
              sprintf(pszFullText, gpszFDFileExists, filedlg.szFullFile);
              ulResponse = WinMessageBox(HWND_DESKTOP, mWnd, pszFullText,
                                               gpszFDSaveCaption, 0,
                                               MB_YESNO | MB_MOVEABLE | MB_WARNING);
            }

            if (ulResponse == MBID_YES) {
               fileExists = PR_FALSE;
            }
         }
      }
    } while (mMode == modeSave && fileExists && filedlg.lReturn == DID_OK);

    if (filedlg.lReturn == DID_OK) {
      result = PR_TRUE;
      if (mMode == modeOpenMultiple) {
        nsresult rv;

        if (filedlg.papszFQFilename) {
          for (ULONG i=0;i<filedlg.ulFQFCount;i++) {
            nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1", &rv);
            NS_ENSURE_SUCCESS(rv,rv);

            rv = file->InitWithNativePath(nsDependentCString(*(filedlg.papszFQFilename)[i]));
            NS_ENSURE_SUCCESS(rv,rv);

            rv = mFiles.AppendObject(file);
            NS_ENSURE_SUCCESS(rv,rv);
          }
          WinFreeFileDlgList(filedlg.papszFQFilename);
        } else {
          nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1", &rv);
          NS_ENSURE_SUCCESS(rv,rv);

          rv = file->InitWithNativePath(nsDependentCString(filedlg.szFullFile));
          NS_ENSURE_SUCCESS(rv,rv);

          rv = mFiles.AppendObject(file);
          NS_ENSURE_SUCCESS(rv,rv);
        }
      } else {
        mFile.Assign(filedlg.szFullFile);
      }
      mSelectedType = (PRInt16)pmydata->ulCurExt;
    }

    for (i = 0; i < mTitles.Length(); i++)
    {
      nsMemory::Free(*(filedlg.papszITypeList[i]));
    }
    free(filedlg.papszITypeList);

    for (i = 0; i < mFilters.Length(); i++)
    {
      nsMemory::Free(*(pmydata->papszIFilterList[i]));
    }
    free(pmydata->papszIFilterList);
    free(pmydata);
  }

  if (title)
    nsMemory::Free( title );

  if (result) {
    PRInt16 returnOKorReplace = returnOK;

    nsresult rv;
    // Remember last used directory.
    nsCOMPtr<nsILocalFile> file(do_CreateInstance("@mozilla.org/file/local;1", &rv));
    NS_ENSURE_SUCCESS(rv, rv);

    file->InitWithNativePath(mFile);
    nsCOMPtr<nsIFile> dir;
    if (NS_SUCCEEDED(file->GetParent(getter_AddRefs(dir)))) {
      nsCOMPtr<nsILocalFile> localDir(do_QueryInterface(dir));
      if (localDir) {
        nsCAutoString newDir;
        localDir->GetNativePath(newDir);
        if(!newDir.IsEmpty())
          PL_strncpyz(mLastUsedDirectory, newDir.get(), MAX_PATH+1);
        // Update mDisplayDirectory with this directory, also.
        // Some callers rely on this.
        if (!mDisplayDirectory)
           mDisplayDirectory = do_CreateInstance("@mozilla.org/file/local;1");
        if (mDisplayDirectory)
           mDisplayDirectory->InitWithNativePath( nsDependentCString(mLastUsedDirectory) );
      }
    }

    if (mMode == modeSave) {
      // Windows does not return resultReplace,
      //   we must check if file already exists
      PRBool exists = PR_FALSE;
      file->Exists(&exists);
      if (exists)
        returnOKorReplace = returnReplace;
    }
    *retval = returnOKorReplace;
  }
  else {
    *retval = returnCancel;
  }
  return NS_OK;
}
/**************************************************************************
 *
 *  Name       : FileOpen(mp2)
 *
 *  Description: Processes the File menu's Open item
 *
 *  Concepts:  Called whenever OPEN from the FILE menu is selected
 *
 *             Calls the standard file open dialog to get the
 *             file name.  The file name is passed onto DosOpen
 *             which returns the handle to the file.  The file
 *             input procedure is called and then the file handle
 *             is closed.
 *
 *  API's      : WinLoadString
 *               WinFileDlg
 *               DosOpen
 *               DosClose
 *
 *  Parameters :  mp2      = second message parameter
 *
 *  Return     :  [none]
 *
 *************************************************************************/
VOID FileOpen(MPARAM mp2)
{
   FILEDLG fdg;
   HFILE hfIn;
   ULONG ulAction;
   CHAR szTitle[MESSAGELEN], szButton[MESSAGELEN];

   fdg.cbSize = sizeof(FILEDLG);

   if(!WinLoadString(hab, (HMODULE)0, IDS_OPEN, MESSAGELEN, szTitle))
   {
      MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, TRUE);
      return;
   }

   if(!WinLoadString(hab, (HMODULE)0, IDS_OPEN, MESSAGELEN, szButton))
   {
      MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, TRUE);
      return;
   }

   fdg.pszTitle = szTitle;
   fdg.pszOKButton = szButton;
   fdg.ulUser = 0L;
   fdg.fl = FDS_HELPBUTTON | FDS_CENTER | FDS_OPEN_DIALOG;
   fdg.pfnDlgProc = (PFNWP)TemplateOpenFilterProc;
   fdg.lReturn = 0L;
   fdg.lSRC = 0L;
   fdg.hMod = 0;
   fdg.usDlgId = FILEOPEN;
   fdg.x = 0;
   fdg.y = 0;

   if(!WinLoadString(hab, (HMODULE)0, IDS_FILEOPENEXT, CCHMAXPATH,
                     fdg.szFullFile))
   {
      MessageBox(hwndMain, IDMSG_CANNOTLOADSTRING, MB_OK | MB_ERROR, TRUE);
      return;
   }

   fdg.pszIType       = (PSZ)NULL;
   fdg.papszITypeList = (PAPSZ)NULL;
   fdg.pszIDrive      = (PSZ)NULL;
   fdg.papszIDriveList= (PAPSZ)NULL;
   fdg.sEAType        = (SHORT)0;
   fdg.papszFQFilename= (PAPSZ)NULL;
   fdg.ulFQFCount     = 0L;

   /* get the file */
   if(!WinFileDlg(HWND_DESKTOP, hwndMain, &fdg))
      return;

   /*
    *  Upon sucessful return of a file, open it for reading
    */

   if(fdg.lReturn == ID_OK)
   {
      if( DosOpen(fdg.szFullFile,     /* file name from Open dialog */
                  &hfIn,              /* file handle returned */
                  &ulAction,
                  0L,
                  FILE_NORMAL,
                  FILE_OPEN,
                  OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE,
                  (PEAOP2)NULL))
      {
         MessageBox(hwndMain,
                      IDMSG_CANNOTOPENINPUTFILE,
                      MB_OK | MB_ERROR,
                      FALSE);

           /*
            *  NOTE:  You now have several options on how to proceed
            *      from this point:
            *          - You can abort the File Open by returning from
            *            this procedure.
            *          - You can bring up the File Open dialog again
            *            and have the user pick another file.
            *          - You can check the error code from the DosOpen,
            *            determine why the open failed, and take an
            *            action appropriate to the specific failure.
            */

         return;
      }

       /* copy file name into file name buffer */
      strcpy(szFullPath, fdg.szFullFile);

       /*
        *  Place routine for reading the file here.
        */

      DosClose(hfIn);

      UpdateTitleText(hwndMainFrame);
   }

   /* This routine currently doesn't use the mp2 parameter but       *\
    *  it is referenced here to prevent an 'Unreferenced Parameter'
   \*  warning at compile time.                                      */
   mp2;
}   /* End of FileOpen   */
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY VIOWindows_SSH_Prompts_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.VIOWindows_SSH_prompts;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( VIOMenuManager.Settings.SSH_Commands ) Value = 1;
     WinSendDlgItemMsg( Window, VIOWindows_SSH_Prompts.Settings.SSH_Commands_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     WinEnableControl( Window, VIOWindows_SSH_Prompts.Settings.Use_AltTilde_button_ID, Value );

     WinEnableWindow( WinWindowFromID( WinWindowFromID( WinWindowFromID( Window, VIOWindows_SSH_Prompts.Settings.FileList_Container_ID ), VIOWindows_SSH_Prompts.Settings.SelectBox_ID ), VIOWindows_SSH_Prompts.Settings.File_list_ID ), Value );
     WinEnableWindow( WinWindowFromID( WinWindowFromID( WinWindowFromID( Window, VIOWindows_SSH_Prompts.Settings.FileList_Container_ID ), VIOWindows_SSH_Prompts.Settings.AddRemove_ID ), VIOWindows_SSH_Prompts.Settings.File_Add_ID ), Value );
     WinEnableWindow( WinWindowFromID( WinWindowFromID( WinWindowFromID( Window, VIOWindows_SSH_Prompts.Settings.FileList_Container_ID ), VIOWindows_SSH_Prompts.Settings.AddRemove_ID ), VIOWindows_SSH_Prompts.Settings.File_Remove_ID ), Value );

     Value = 0; if( VIOMenuManager.Settings.Use_AltTilde ) Value = 1;
     WinSendDlgItemMsg( Window, VIOWindows_SSH_Prompts.Settings.Use_AltTilde_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Распознаем настройки.
   case SM_UPDATE_LIST:
    {
     HWND List_window = WinWindowFromID( WinWindowFromID( WinWindowFromID( Window, VIOWindows_SSH_Prompts.Settings.FileList_Container_ID ), VIOWindows_SSH_Prompts.Settings.SelectBox_ID ), VIOWindows_SSH_Prompts.Settings.File_list_ID );

     WinSendMsg( List_window, LM_DELETEALL, 0, 0 );

     for( INT Count = 0; Count < MAX_VIO_MENU_FILES; Count ++ )
      if( VIOMenuManager.Settings.Files[ Count ][ 0 ] != 0 )
       WinSendMsg( List_window, LM_INSERTITEM, MPFROMSHORT( LIT_END ), MPFROMP( FindNameInPath( VIOMenuManager.Settings.Files[ Count ] ) ) );
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == VIOWindows_SSH_Prompts.Settings.SSH_Commands_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) VIOMenuManager.Settings.SSH_Commands = 0;
           else VIOMenuManager.Settings.SSH_Commands = 1;

           BroadcastMessage( SM_SHOW_SETTINGS );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == VIOWindows_SSH_Prompts.Settings.Use_AltTilde_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) VIOMenuManager.Settings.Use_AltTilde = 0;
           else VIOMenuManager.Settings.Use_AltTilde = 1;

           BroadcastMessage( SM_SHOW_SETTINGS );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == VIOWindows_SSH_Prompts.Settings.File_Add_ID )
      {
       BYTE List_is_full = 1;
       for( INT Count = 0; Count < MAX_VIO_MENU_FILES; Count ++ )
        if( VIOMenuManager.Settings.Files[ Count ][ 0 ] == 0 ) { List_is_full = 0; break; }

       if( List_is_full ) return 0;

       FILEDLG Parameters; HWND OpenFile_window;

       bzero( &Parameters, sizeof( FILEDLG ) );
       Parameters.cbSize = sizeof( FILEDLG );
       Parameters.fl = FDS_OPEN_DIALOG | FDS_CENTER;

       LONG Code_page = Enhancer.Code_page;

       if( Code_page == RUSSIAN ) Parameters.pszTitle = StrConst_RU_Pages_VIOWindows_SSH_prompts_Dialog;
       else Parameters.pszTitle = StrConst_EN_Pages_VIOWindows_SSH_prompts_Dialog;

       if( VIOWindows_SSH_Prompts.RTSettings.FileDlg_path[ 0 ] == 0 )
        {
         ULONG Current_drive = 0; ULONG Drive_map = 0;
         DosQueryCurrentDisk( &Current_drive, &Drive_map );
         Parameters.szFullFile[ 0 ] = (CHAR) Current_drive + 64;
         Parameters.szFullFile[ 1 ] = 0;
         strcat( Parameters.szFullFile, ":\\*.txt" );
        }
       else
        {
         strcpy( Parameters.szFullFile, VIOWindows_SSH_Prompts.RTSettings.FileDlg_path );
         strcat( Parameters.szFullFile, "\\*.txt" );
        }

       OpenFile_window = WinFileDlg( HWND_DESKTOP, Window, &Parameters );

       if( OpenFile_window != NULLHANDLE ) if( Parameters.lReturn == DID_OK )
        if( stristr( ".txt", Parameters.szFullFile ) )
         {
          BYTE Already_present = 0;
          for( INT Count = 0; Count < MAX_VIO_MENU_FILES; Count ++ )
           if( VIOMenuManager.Settings.Files[ Count ][ 0 ] != 0 )
            if( stric( VIOMenuManager.Settings.Files[ Count ], Parameters.szFullFile ) )
             {
              Already_present = 1;
              break;
             }

          if( !Already_present )
           {
            for( Count = 0; Count < MAX_VIO_MENU_FILES; Count ++ )
             if( VIOMenuManager.Settings.Files[ Count ][ 0 ] == 0 )
              {
               strncpy( VIOMenuManager.Settings.Files[ Count ], Parameters.szFullFile, SIZE_OF_PATH );
               break;
              }

            BroadcastRSMessages();
           }

          strncpy( VIOWindows_SSH_Prompts.RTSettings.FileDlg_path, Parameters.szFullFile, SIZE_OF_PATH );
          CutNameInPath( VIOWindows_SSH_Prompts.RTSettings.FileDlg_path );
         }
      }

     if( WM_Control_Button_ID == VIOWindows_SSH_Prompts.Settings.File_Remove_ID )
      {
       HWND List_window = WinWindowFromID( WinWindowFromID( WinWindowFromID( Window, VIOWindows_SSH_Prompts.Settings.FileList_Container_ID ), VIOWindows_SSH_Prompts.Settings.SelectBox_ID ), VIOWindows_SSH_Prompts.Settings.File_list_ID );

       INT Selected_string = (INT) WinSendMsg( List_window, LM_QUERYSELECTION, MPFROMLONG( LIT_FIRST ), MPFROMLONG( 0 ) );
       if( Selected_string == LIT_NONE ) return 0;

       WinSendMsg( List_window, LM_DELETEITEM, MPFROMLONG( Selected_string ), 0 );

       for( INT Count = Selected_string; Count < MAX_VIO_MENU_FILES - 1; Count ++ )
        memcpy( VIOMenuManager.Settings.Files[ Count ], VIOMenuManager.Settings.Files[ Count + 1 ], SIZE_OF_PATH );

       bzero( VIOMenuManager.Settings.Files[ MAX_VIO_MENU_FILES - 1 ], SIZE_OF_PATH );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "SSH Commands", &VIOMenuManager.Settings.SSH_Commands, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Use AltTilde", &VIOMenuManager.Settings.Use_AltTilde, sizeof( BYTE ) );

         PrfWriteProfileData( Ini_file, "SSH prompts", NULL, NULL, 0 );

         for( INT Count = 0; Count < MAX_VIO_MENU_FILES; Count ++ )
          {
           if( VIOMenuManager.Settings.Files[ Count ][ 0 ] != 0 )
            {
             CHAR Number[ 4 ] = ""; itoa( Count, Number, 10 );
             CHAR Ini_record_name[ SIZE_OF_NAME ] = "File "; strcat( Ini_record_name, Number );

             PrfWriteProfileData( Ini_file, "SSH prompts", Ini_record_name, VIOMenuManager.Settings.Files[ Count ], strlen( VIOMenuManager.Settings.Files[ Count ] ) + 1 );
            }
          }

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       BYTE Files_are_present = 0;

       for( INT Count = 0; Count < MAX_VIO_MENU_FILES; Count ++ )
        if( VIOMenuManager.Settings.Files[ Count ][ 0 ] != 0 )
         {
          Files_are_present = 1;
          break;
         }

       if( Files_are_present )
        {
         CHAR String[ 256 ] = ""; LONG Reply = 0;
         BYTE Clear_list = 0;

         LONG Code_page = Enhancer.Code_page;

         if( Code_page == RUSSIAN ) strcpy( String, StrConst_RU_Pages_VIOWindows_SSH_prompts_Question );
         else strcpy( String, StrConst_EN_Pages_VIOWindows_SSH_prompts_Question );

         {
          CHAR Title[ SIZE_OF_TITLE ] = ""; GetEnhancerWindowTitle( Title );
          Reply = WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, String, Title, 0, MB_YESNO );
         }

         if( Reply == MBID_YES ) Clear_list = 1;

         if( Clear_list )
          {
           CHAR Empty_path[ SIZE_OF_PATH ] = ""; bzero( Empty_path, SIZE_OF_PATH );

           for( Count = 0; Count < MAX_VIO_MENU_FILES; Count ++ )
            memcpy( VIOMenuManager.Settings.Files[ Count ], Empty_path, SIZE_OF_PATH );

           WinPostMsg( Window, SM_UPDATE_LIST, 0, 0 );
          }
        }

       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
MRESULT EXPENTRY CDSettingsDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  FILEDLG fd = { 0 };
  char profileName[20];
  static HINI hini;
  ULONG keyLength;
  static  char chrPath[CCHMAXPATH];
  static  char chrOptions[CCHMAXPATH];

  switch( msg )
    {
    case WM_INITDLG:
      {
	WinSendMsg(WinWindowFromID(hwnd,EFID_CDRECORDPATH),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0);
	WinSendMsg(WinWindowFromID(hwnd,EFID_CDRECORDOPTIONS),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0);
	WinSetWindowText( WinWindowFromID(hwnd,EFID_CDRECORDPATH),chrCDRecord);
	WinSetWindowText( WinWindowFromID(hwnd,EFID_CDRECORDOPTIONS),chrCDROptions);
	sprintf(chrPath,"%s",chrCDRecord);
	sprintf(chrOptions,"%s",chrCDROptions);
	sprintf(profileName,"cdrecord.ini");		
	hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),profileName);
	if(!hini) {
	  WinMessageBox(  HWND_DESKTOP,
			HWND_DESKTOP,
			"Warning! Cannot open Ini-file!",
			"",
			0UL,
			MB_OK | MB_ICONEXCLAMATION );
	  WinDismissDlg(hwnd,DID_ERROR);
	}/* end of if(!hini) */				
      }
      return (MRESULT) TRUE;
    case WM_DESTROY:
      if(hini)PrfCloseProfile(hini);
      hini=NULLHANDLE;
      break;
    case WM_CLOSE:
      WinDismissDlg(hwnd,DID_ERROR);
      break;
    case WM_COMMAND:
      {			
	switch( SHORT1FROMMP( mp1 ) )
	  {
	  case PBID_CDRECORDBROWSE:
	    fd.cbSize = sizeof( fd );
	    fd.fl = FDS_OPEN_DIALOG|FDS_CENTER;
	    fd.pszTitle = "Search CDRecord/2";
	    sprintf(fd.szFullFile,"%s","*.exe");
	    
	    if( WinFileDlg( HWND_DESKTOP, hwnd, &fd ) == NULLHANDLE )
	      {
		break;
	      }
	    if( fd.lReturn == DID_OK )
	      {
		WinSetWindowText( WinWindowFromID(hwnd,EFID_CDRECORDPATH), fd.szFullFile );
		sprintf(chrCDRecord,"%s",fd.szFullFile);
	      }
	    break;
	  case DID_OK:
	    WinQueryWindowText(WinWindowFromID(hwnd,EFID_CDRECORDOPTIONS),sizeof(chrCDROptions),chrCDROptions);
	    if(!PrfWriteProfileString(hini,"CDWriter","cdrecord",chrCDRecord)){
	      WinMessageBox(  HWND_DESKTOP,
			    HWND_DESKTOP,
			    "Warning! Cannot write to Ini-file!",
			    "",
			    0UL,
			    MB_OK | MB_ICONEXCLAMATION );
	      WinDismissDlg(hwnd,DID_ERROR);
	    }
	    
	    if(!PrfWriteProfileString(hini,"CDWriter","cdroptions",chrCDROptions)){
	      WinMessageBox(  HWND_DESKTOP,
			    HWND_DESKTOP,
			    "Warning! Cannot write to Ini-file!",
			    "",
			    0UL,
			    MB_OK | MB_ICONEXCLAMATION );
	      WinDismissDlg(hwnd,DID_ERROR);
	    };
	    WinDismissDlg(hwnd,0);
	    break;
	  case DID_CANCEL:
	    sprintf(chrCDRecord,"%s",chrPath);
	    sprintf(chrCDROptions,"%s",chrOptions);
	    WinDismissDlg(hwnd,1);
	    break;
	    
	  default:
	    break;
	  }
      }
      return (MRESULT) TRUE;      
    }	
  return( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );	
}
Exemple #23
0
VOID FileSave( MPARAM mp2)
{
FILEDLG fileDialog;
CHAR szTitle[MESSAGELEN],szButton[MESSAGELEN];


   fileDialog.cbSize = sizeof(FILEDLG);

   if (!WinLoadString(Main::hab, (HMODULE)0, IDS_SAVEDLGTITLE, MESSAGELEN, szTitle))
   {
	WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,(PCH) "Failed to Load String",
	(PCH)"Database",0,MB_NOICON|MB_OK);
      return;
   }

   if (!WinLoadString(Main::hab,(HMODULE)0, IDS_SAVEDLGBUTTON, MESSAGELEN, szButton))
   {
      WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,(PCH) "Failed to Load String",
	(PCH)"Database",0,MB_NOICON|MB_OK);      return;
   }

   fileDialog.pszTitle = szTitle;
   fileDialog.pszOKButton = szButton;
   fileDialog.ulUser = 0;
   fileDialog.fl = FDS_HELPBUTTON | FDS_CENTER | FDS_OPEN_DIALOG;
   fileDialog.pfnDlgProc = (PFNWP)OpenSaveFilterDlgProc;
   fileDialog.lReturn = 0;
   fileDialog.lSRC = 0;
   fileDialog.hMod = (HMODULE)0;
   fileDialog.usDlgId = IDD_FILEOPEN;
   fileDialog.x = 0;
   fileDialog.y = 0;

   if (!WinLoadString(Main::hab, (HMODULE)0, IDS_FILEOPENEXT, CCHMAXPATH,
		     fileDialog.szFullFile))
   {
      WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,(PCH) "Failed to Load String",
	(PCH)"Database",0,MB_NOICON|MB_OK);      return;
   }

   fileDialog.pszIType = NULL;
   fileDialog.papszITypeList = NULL;
   fileDialog.pszIDrive = NULL;
   fileDialog.papszIDriveList = NULL;
   fileDialog.sEAType = 0;
   fileDialog.papszFQFilename = NULL;
   fileDialog.ulFQFCount = 0;

   /*
    *Call the standard file dialog to get the file
    */
   if (!WinFileDlg(HWND_DESKTOP, HWND_DESKTOP, (PFILEDLG)&fileDialog))
       return;

   /*
    *  Upon sucessful return of a file, open it for reading
    */

   if (fileDialog.lReturn == ID_OK) {
      strcpy(szFullPath, fileDialog.szFullFile);
      if (odb.save_database(szFullPath)==0)
	WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,(PCH) "Could not Save databasefile",
		(PCH)"Database",0,MB_NOICON|MB_OK|MB_MOVEABLE);

      else
	WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,(PCH) "Database Saved",
		(PCH)"Database",0,MB_NOICON|MB_OK|MB_MOVEABLE);

	return;
      }
   }
Exemple #24
0
//A Dlg procedure if the plugin has selectable settings.
MRESULT EXPENTRY CBZPluginSetupDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  short sControlId;
    PLUGINSHARE *pPluginData;
    FILEDLG filedlg;
    HWND hwndDlg;

    switch (msg)
    {
        case WM_INITDLG:
        {
            if ((pPluginData = (PLUGINSHARE *) mp2) == NULL)
            {
                //Error msg..
                WinDismissDlg(hwnd, DID_ERROR);
                return (MRFROMLONG(FALSE));
            }
            WinSetWindowPtr(hwnd, QWL_USER, pPluginData);  // store window words

            WinSendMsg(WinWindowFromID(hwnd, EFID_IMAGE), EM_SETTEXTLIMIT, (MPARAM) CCHMAXPATH, (MPARAM) 0);

            WinSetWindowText(WinWindowFromID(hwnd, EFID_IMAGE), pPluginData->szImageFile);

            /* This is temprary. At the moment only all or no frame control may be drawn */
            WinCheckButton(hwnd, CBID_CLOSEENABLED, TRUE);
            WinCheckButton(hwnd, CBID_MINIMIZEENABLED, TRUE);
            WinCheckButton(hwnd, CBID_MAXIMIZEENABLED, TRUE);
            WinCheckButton(hwnd, CBID_RESTOREENABLED, TRUE);
            WinCheckButton(hwnd, CBID_HIDEENABLED, TRUE);

            WinEnableWindow(WinWindowFromID(hwnd,CBID_CLOSEENABLED ), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_MINIMIZEENABLED), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_MAXIMIZEENABLED), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_RESTOREENABLED), FALSE);
            WinEnableWindow(WinWindowFromID(hwnd, CBID_HIDEENABLED), FALSE);

        }
        break;

        case WM_COMMAND:
        {
            sControlId = COMMANDMSG(&msg)->cmd;

            switch (sControlId)
            {
                case PBID_IMAGE:
                {

                    //popup file change dialog!
                    memset(&filedlg, 0, sizeof(FILEDLG));  // init filedlg struct

                    filedlg.cbSize = sizeof(FILEDLG);
                    filedlg.fl = FDS_OPEN_DIALOG;
                    filedlg.pszTitle = "Choose an image";
                    strcpy(filedlg.szFullFile, "*.*");

                    if ((hwndDlg = WinFileDlg(HWND_DESKTOP, hwnd, &filedlg)) == NULLHANDLE)
                    {
                        return (FALSE);
                    }

                    if (filedlg.lReturn != DID_OK)  // selected one

                    {
                        break;
                    }

                    WinSetWindowText(WinWindowFromID(hwnd, EFID_IMAGE), filedlg.szFullFile);

                }
                break;


                case PBID_OK:
                {
                    if ((pPluginData = (PLUGINSHARE *) WinQueryWindowPtr(hwnd, QWL_USER)) == NULL)
                    {
                        //error message..
                        break;
                    }

                    WinQueryWindowText(WinWindowFromID(hwnd, EFID_IMAGE), CCHMAXPATH, pPluginData->szImageFile);

                    //update!
                    WinDismissDlg(hwnd, PBID_OK);
                }
                break;

                case PBID_CANCEL:
                {
                    //don't update shared Memory!
                    WinDismissDlg(hwnd, PBID_CANCEL);
                }
                break;
            }

            return ((MPARAM) 0);
        }
        break;

        case WM_CONTROL:
        {
            switch (SHORT1FROMMP(mp1))
            {

            }
            return ((MRESULT) 0);
        }
        break;

    }
    return (WinDefDlgProc(hwnd, msg, mp1, mp2));
}
static MRESULT EXPENTRY _bootCDOptionsDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  CWDataFolder* thisPtr;
  FILEDLG fd = { 0 };
  /* char text[CCHMAXPATH];*/
  char title[CCHMAXPATH];
  ULONG rc;
  THISPTR *tpPtr;

  switch(msg)
    {
    case WM_INITDLG :	
      tpPtr=(THISPTR*)PVOIDFROMMP(mp2);
      thisPtr=(CWDataFolder*)tpPtr->thisPtr;

      /*    sprintf(text,"tpPtr: %x thisPtr: %x",tpPtr,thisPtr);
            WinMessageBox(  HWND_DESKTOP, hwnd,
            text,"2", 0UL, MB_OK | MB_ERROR |MB_MOVEABLE); */

      WinSetWindowULong(WinWindowFromID(hwnd,IDPB_OK),
                        QWL_USER,(ULONG)thisPtr);//Save object ptr.
              
      if(somIsObj(thisPtr)) {        
        WinSetWindowText( WinWindowFromID(hwnd,IDEF_BOOTIMAGE), thisPtr->chrBootImage );
        WinSetWindowText( WinWindowFromID(hwnd,IDEF_BOOTCATALOG), thisPtr->chrBootCatalog );
      }
      break;
    case WM_CLOSE:
      WinDismissDlg(hwnd,0);
      return FALSE;
    case WM_COMMAND:
      switch(SHORT1FROMMP(mp1))
        {
        case IDPB_OK:
          /* User pressed the OK button */
          thisPtr=(CWDataFolder*)WinQueryWindowULong(WinWindowFromID(hwnd,IDPB_OK),QWL_USER);
          if(somIsObj(thisPtr)) {
            WinQueryWindowText(WinWindowFromID(hwnd,IDEF_BOOTIMAGE),sizeof(thisPtr->chrBootImage),thisPtr->chrBootImage);
            WinQueryWindowText(WinWindowFromID(hwnd,IDEF_BOOTCATALOG),sizeof(thisPtr->chrBootCatalog),thisPtr->chrBootCatalog);
          }
          WinDismissDlg(hwnd,DID_OK);
          return (MRESULT) FALSE;          
        case IDPB_CANCEL:
          WinDismissDlg(hwnd,0);
          return FALSE;
        case IDPB_BROWSE:
          /* User pressed the browse button */
          fd.cbSize = sizeof( fd );
          /* It's an centered 'Open'-dialog */
          fd.fl = FDS_OPEN_DIALOG|FDS_CENTER;
          /* Title: "Select boot image" */
          getMessage(title,IDSTR_FDLGSEARCHBOOTIMGTITLE,sizeof(title), hDataResource,hwnd);
          /* Set the title of the file dialog */
          fd.pszTitle = title;
          /* Show all files */
          sprintf(fd.szFullFile,"%s","*.*");
          if( WinFileDlg( HWND_DESKTOP, hwnd, &fd ) == NULLHANDLE )
            {
              /* WinFileDlg failed */
              break;
            }
          if( fd.lReturn == DID_OK )
            {
              WinSetWindowText( WinWindowFromID(hwnd,IDEF_BOOTIMAGE), fd.szFullFile );
            }
          break;
        default:
          break;
        }
      return (MRESULT) TRUE;
    default:
      break;
    }
  return WinDefDlgProc(hwnd, msg, mp1, mp2); 
}
Exemple #26
0
ULONG HESaveAs(HWND hwnd)
{
FILEDLG FDialog;
FILESTATUS3 fst3;
APIRET rc;
char    szTitle[1000];

    strcpy(szTitle,"Save as");

    if (szFullPath[0] == 0)
        strcpy(FDialog.szFullFile,"noname.txt");
        else
        strcpy(FDialog.szFullFile,szFullPath);
    FDialog.cbSize = sizeof(FILEDLG);
    FDialog.pszTitle = szTitle;
    FDialog.pszOKButton = szTitle;
    FDialog.ulUser = 0;
    FDialog.fl = FDS_CENTER | FDS_SAVEAS_DIALOG | FDS_ENABLEFILELB;
    FDialog.pfnDlgProc = (PFNWP) NULL;
    FDialog.lReturn = 0;
    FDialog.lSRC = 0;
    FDialog.hMod = (HMODULE) 0;
    FDialog.usDlgId = IDD_FILESAVEAS;
    FDialog.x   = 0;
    FDialog.y   = 0;
    FDialog.pszIType    = NULL;
    FDialog.papszITypeList  = NULL;
    FDialog.pszIDrive   = NULL;
    FDialog.papszIDriveList = NULL;
    FDialog.sEAType         = 0;
    FDialog.papszFQFilename = NULL;
    FDialog.ulFQFCount  = 0;

    if (!WinFileDlg(HWND_DESKTOP,hwnd,(PFILEDLG)&FDialog))
        return 1;
    if (FDialog.lReturn != DID_OK)
        return 1;

    rc = DosQueryPathInfo(FDialog.szFullFile,1,&fst3,sizeof(FILESTATUS3));
    if (!((rc==0) || (rc==3) || (rc==2)))
        {
        printf("DosQueryPathInfo rc = %d\t\t0x%x\n",rc,rc);
        printf("NOT SAVED.\n");
        return 1;
        }
    if (rc==0)
        {
        if (WinMessageBox(HWND_DESKTOP,hwnd,
                "File exists. Overwrite?","Caution",
                0,MB_YESNO|MB_DEFBUTTON2|MB_WARNING|MB_MOVEABLE)==MBID_NO)
            return 0L;
        }

    strcpy(szFullPath,FDialog.szFullFile);
    if (!HEFileSave(hwnd,szFullPath))
        {
        HESetTitlebarText(hwnd);
        WinPostMsg(hwndStatbar,STATBAR_USERM_SETMODIFIED,0L,0L);
        WinPostMsg(hwndHMLE,HMLM_SETCHANGED,0,0);
        DisableReloadButton(hwnd);
        } else return 1L;
    return 0L;
}
tFSelType SourceFileSelection(HWND hwnd, PSZ pSourceFile, PSZ pTitle)
{

 FILEDLG FileDlg;                       /* File dialog info structure   */
 HWND hwndDlg;                          /* File dialog window           */
 tFSelType rc = eNoSrc;
 PSZ p;

 /*****************************************************************/
 /* Initially set all fields to 0                                 */
 /*****************************************************************/

 memset(&FileDlg, 0, sizeof(FILEDLG));

 /*****************************************************************/
 /* Initialize those fields in the FILEDLG structure that are     */
 /* used by the application                                       */
 /*****************************************************************/

 FileDlg.cbSize = sizeof(FILEDLG);           /* Size of structure    */
 FileDlg.fl =  FDS_CENTER | FDS_OPEN_DIALOG | FDS_CUSTOM | FDS_APPLYBUTTON | FDS_HELPBUTTON;

 FileDlg.pszTitle = pTitle;                  /* Dialog title string  */
 FileDlg.pfnDlgProc = SrcSelDlgProc;
 FileDlg.hMod = hRessourceModule;
 FileDlg.usDlgId = DID_FILE_DIALOG;

 strcpy(FileDlg.szFullFile, "");
 if (0 != strcmp(PathBuffer2, ""))
 {
   p = strrchr(PathBuffer2, '\\');
   if (NULL != p)
    *p = '\0';
   strcat(PathBuffer2, "\\");
   strcat(FileDlg.szFullFile, PathBuffer2);
 }

 strcat(FileDlg.szFullFile, "*");            /* Initial path,        */
 hwndDlg = WinFileDlg(HWND_DESKTOP, hwnd, &FileDlg);

 if (hwndDlg)
 {
   switch(FileDlg.lReturn)
   {
    case DID_OK:
      strcpy(pSourceFile, FileDlg.szFullFile);
      strcpy(PathBuffer2, pSourceFile);
      rc = eFile;
     break;

    case DID_APPLY_PB:
      rc = eClipBoard;
      strcpy(pSourceFile, TempFile);
     break;

    case DID_CANCEL:
    default:
      rc = eNoSrc;
     break;

   }

 }

 return rc;
}
ULONG QueryTargetFile(HWND hwnd, PSZ pSourceFile, PSZ pTitle, BOOL ForVerify)
{

 ULONG rc;
 FILEDLG FileDlg;                       /* File dialog info structure   */
 HWND hwndDlg;                          /* File dialog window           */
 PSZ p1, p2;

 /*****************************************************************/
 /* Initially set all fields to 0                                 */
 /*****************************************************************/

 memset(&FileDlg, 0, sizeof(FILEDLG));

 /*****************************************************************/
 /* Initialize those fields in the FILEDLG structure that are     */
 /* used by the application                                       */
 /*****************************************************************/

 FileDlg.cbSize = sizeof(FILEDLG);           /* Size of structure    */
 FileDlg.pszTitle = pTitle;                  /* Dialog title string  */
 FileDlg.pfnDlgProc = TgtSelDlgProc;

  p1 = strrchr(pSourceFile, '\\');
  p2 = strrchr(pSourceFile, '.');
  if ((NULL != p1) && (NULL != p2))
   if (p2 > p1)
    *p2 = '\0';

 FileDlg.fl =  FDS_CENTER | FDS_HELPBUTTON;
 if (!ForVerify)
 {
  FileDlg.fl |= FDS_SAVEAS_DIALOG;
 }
 else
 {
  FileDlg.fl |= FDS_OPEN_DIALOG;
  if ((NULL != p1) && (NULL != p2))
   if (p2 > p1)
   {
      char *p = p1; // p points now to the character before the first filename character (usually '\\')

      // check if filename contains any lowercase letters
      while(*p)
      {
        if ((*p >= 'a') && (*p <= 'z'))
        {
           // yes, so append a lowercase default extension
           strcpy(p2, ".txt");
           break;
        }
        ++p;
      }

      if (*p == '\0')
        // no, append an uppercase default extension
        strcpy(p2, ".TXT");
   }
 }

 strcpy(FileDlg.szFullFile, pSourceFile);   /* Initial path */
 hwndDlg = WinFileDlg(HWND_DESKTOP, hwnd, &FileDlg);

 if (hwndDlg)
 {
   switch(FileDlg.lReturn)
   {
    case DID_OK:
      strcpy(pSourceFile, FileDlg.szFullFile);
      strcpy(PathBuffer2, pSourceFile);
      rc = NO_ERROR;
     break;

    case DID_CANCEL:
    default:
      rc = ERROR_OPEN_FAILED;
     break;

   }

 }

 return rc;
}
Exemple #29
0
int GUIGetFileName( gui_window *wnd, open_file_name *ofn )
{
  #ifdef _M_I86
    wnd = wnd;
    ofn = ofn;
  #else
    FILEDLG             fdlg;
    int                 str_index;
    int                 rc;
    ULONG               i;
    ULONG               slen, flen;
    unsigned            drive;
    unsigned            old_drive;
    unsigned            drives;
    char                initial_path[_MAX_PATH];
    char                old_path[_MAX_PATH];
    char                fname[_MAX_FNAME + _MAX_EXT];
    char                *cwd;

    old_path[0] = '\0';
    fname[0] = '\0';
    cwd = getcwd( initial_path, _MAX_PATH );
    if( cwd ) {
        _splitpath( cwd, NULL, old_path, NULL, NULL );
    }

    drive = 0;
    initial_path[0] = '\0';
    if( ofn->initial_dir != NULL && ofn->initial_dir[0] != '\0' ) {
        if( ofn->initial_dir[1] == ':' ) {
            drive = ofn->initial_dir[0];
        }
        _splitpath( ofn->initial_dir, NULL, initial_path, NULL, NULL );
    }

    memset( &fdlg, 0 , sizeof( fdlg ) );

    fdlg.cbSize = sizeof( fdlg );

    fdlg.fl = FDS_CENTER | FDS_ENABLEFILELB;
    if( ofn->flags & OFN_ISSAVE ) {
        fdlg.fl |= FDS_SAVEAS_DIALOG;
        fdlg.pszOKButton = (PSZ)LIT( FDlg_Save_Text );
    } else {
        fdlg.fl |= FDS_OPEN_DIALOG;
        fdlg.pszOKButton = (PSZ)LIT( FDlg_Open_Text );
    }
    if( ofn->flags & OFN_ALLOWMULTISELECT ) {
        fdlg.fl |= FDS_MULTIPLESEL;
    }

    fdlg.pszTitle = ofn->title;

    if( ofn->file_name ) {
        strncpy( fdlg.szFullFile, ofn->file_name, CCHMAXPATH );
        fdlg.szFullFile[CCHMAXPATH-1] = '\0';
    }

    if( ( !ofn->file_name || !*ofn->file_name ) && ofn->filter_index >= 0 ) {
        str_index = 0;
        for( i=0; ;i++ ) {
            if( ofn->filter_list[i] == '\0' ) {
                if( ofn->filter_list[i+1] == '\0' ) {
                    break;
                }
                str_index++;
                if( str_index == ofn->filter_index * 2 - 1 ) {
                    i++;
                    break;
                }
            }
        }
        if( ofn->filter_list[i] != '\0' ) {
            strncpy( fdlg.szFullFile, ofn->filter_list + i, CCHMAXPATH );
            fdlg.szFullFile[CCHMAXPATH-1] = '\0';
        }
    }

  #if defined( HAVE_DRIVES )
    if( drive ) {
        _dos_getdrive( &old_drive );
        _dos_setdrive( tolower( drive ) - 'a' + 1, &drives );
        if( *initial_path && *old_path ) {
            chdir( initial_path );
        }
    }
  #endif

    rc = (int)WinFileDlg( HWND_DESKTOP, GUIGetParentFrameHWND( wnd ), &fdlg );

    if( fdlg.papszFQFilename ) {
        ofn->file_name[0] = '\0';
        slen = 0;
        for( i=0; i<fdlg.ulFQFCount; i++ ) {
            flen = strlen( fdlg.papszFQFilename[0][i] );
            if( ( slen + flen + 2 ) > ofn->max_file_name ) {
                return( OFN_RC_FAILED_TO_INITIALIZE );
            }
            if( slen ) {
                ofn->file_name[slen++] = ' ';
            }
            memcpy( &ofn->file_name[slen], fdlg.papszFQFilename[0][i], flen + 1);
            slen += flen;
        }
        WinFreeFileDlgList( fdlg.papszFQFilename );
        if( ofn->base_file_name  != NULL ) {
            ofn->base_file_name[0] = '\0';
        }
    } else {
        if( strlen( fdlg.szFullFile ) > ( ofn->max_file_name - 1 ) ) {
            return( OFN_RC_FAILED_TO_INITIALIZE );
        } else {
            strcpy( ofn->file_name, fdlg.szFullFile );
            _splitpath( fdlg.szFullFile, NULL, NULL, fname, NULL );
            _splitpath( fdlg.szFullFile, NULL, NULL, NULL, fname+strlen(fname) );
        }
        if( ofn->base_file_name  != NULL ) {
            ofn->base_file_name[0] = '\0';
            if( strlen( fname ) <= ofn->max_base_file_name ) {
                strcpy( ofn->base_file_name, fname );
            }
        }
    }

  #if defined( HAVE_DRIVES )
    if( drive ) {
        _dos_setdrive( old_drive, &drives );
        if( *initial_path && *old_path ) {
            chdir( old_path );
        }
    }
  #endif

    if( fdlg.lReturn == DID_CANCEL ) {
        return( OFN_RC_NO_FILE_SELECTED );
    }

    if( rc ) {
        return( OFN_RC_FILE_SELECTED );
    }
  #endif
    return( OFN_RC_FAILED_TO_INITIALIZE );
} /* GUIGetFileName */
Exemple #30
0
ULONG LaunchFileDlg( HWND hwnd, HWND hwndBubbleHelp)

{
         BOOL           ulResult = MBID_ERROR;
         BOOL           fResult;
         FILEDLG        fd;

         CHAR           szMessage[ _MAX_PATH];
         PSZ            pszButtonCode;

// stop bubble help
WtkDeactivateBubbleHelp( hwndBubbleHelp);

do
   {
   // setup data
   memset( &fd, 0, sizeof( fd));
   fd.cbSize     = sizeof( fd);
   fd.fl         = FDS_CENTER | FDS_HELPBUTTON | FDS_OPEN_DIALOG;
   fd.pszTitle   = "System File test dialog";
   strcpy( fd.szFullFile, "C:\\*");

   // launch dialog
   fResult = WinFileDlg( HWND_DESKTOP, hwnd, &fd);

   if (!fResult)
      sprintf( szMessage, "error launching WinFileDlg\n");
   else if (fd.lReturn == DID_OK)
      sprintf( szMessage, "file is: %s\n", fd.szFullFile);
   else
      sprintf( szMessage, "error occurred!\n");

   switch (fd.lReturn)
      {
      case DID_OK:     pszButtonCode = "(DID_OK)";     break;
      case DID_CANCEL: pszButtonCode = "(DID_CANCEL)"; break;
      case DID_ERROR:  pszButtonCode = "(DID_ERROR)";  break;
      default:         pszButtonCode = "";             break;
      }

   sprintf( &szMessage[ strlen( szMessage)],
            "\015\015"
            "return code is: %u %s\015"
            "WinFileDlg error source code is: %u\015",
            fd.lReturn, pszButtonCode, fd.lSRC);

   WinMessageBox( HWND_DESKTOP, hwnd, szMessage, "File Dialog Result",
                  IDDLG_MSGBOX_RESULTFILEDLG, MB_MOVEABLE | MB_OK | MB_HELP);

   // on error return error code
   if (!fResult)
      break;

   // hand over result
   ulResult = fd.lReturn;

   } while (FALSE);


// restart bubble help
WtkActivateBubbleHelp( hwndBubbleHelp);
return ulResult;
}