home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mnth0109.zip / Timur / files.c < prev    next >
Text File  |  1993-06-07  |  5KB  |  97 lines

  1. /* FILES.C - File I/O routines & dialog boxes window procedures
  2.  
  3. Copyright (c) 1992-1993 Timur Tabi
  4. Copyright (c) 1992-1993 Fasa Corporation
  5.  
  6. The following trademarks are the property of Fasa Corporation:
  7. BattleTech, CityTech, AeroTech, MechWarrior, BattleMech, and 'Mech.
  8. The use of these trademarks should not be construed as a challenge to these marks.
  9.  
  10. */
  11.  
  12. #define INCL_DOSFILEMGR
  13. #define INCL_WINSTDFILE
  14. #include <os2.h>
  15. #include <string.h>
  16.  
  17. #include "header.h"
  18. #include "errors.h"
  19. #include "hexes.h"
  20. #include "window.h"
  21.  
  22. /* From the PM reference:
  23.  
  24. typedef struct _FILEDLG {
  25.  ULONG      cbSize;                            // Structure size
  26.  ULONG      fl;                                // FDS_* flags
  27.  ULONG      ulUser;                            // Used by the application
  28.  LONG       lReturn;                           // Result code
  29.  LONG       lSRC;                              // System return code
  30.  PSZ        pszTitle;                          // Dialog title string
  31.  PSZ        pszOKButton;                       // OK push button text
  32.  PFNWP      pfnDlgProc;                        // Custom dialog procedure
  33.  PSZ        pszIType;                          // Extended-attribute type filter
  34.  PAPSZ      papszITypeList;                    // Pointer
  35.  PSZ        pszIDrive;                         // The initial drive
  36.  PAPSZ      papszIDriveList;                   // Pointer
  37.  HMODULE    hMod;                              // Module for custom dialog resources
  38.  CHAR       szFullFile[CCHMAXPATH];            // Character array
  39.  PAPSZ      papszFQFilename;                   // Pointer
  40.  ULONG      ulFQFCount;                        // Number of file names
  41.  USHORT     usDlgId;                           // Custom dialog ID
  42.  SHORT      x;                                 // X-axis dialog position
  43.  SHORT      y;                                 // Y-axis dialog position
  44.  SHORT      sEAType;                           // Selected extended-attribute type
  45. } FILEDLG;
  46.  
  47. */
  48.  
  49. static FILEDLG fdg={
  50.   sizeof(FILEDLG),                                         // Structure size
  51.   FDS_CENTER | FDS_PRELOAD_VOLINFO | FDS_OPEN_DIALOG,      // FDS_* flags
  52.   0,                                                       // Used by the application
  53.   0,                                                       // Result code
  54.   0,                                                       // System return code
  55.   NULL,                                                    // Dialog title string
  56.   NULL,                                                    // OK push button text
  57.   NULL,                                                    // Custom dialog procedure
  58.   NULL,                                                    // Extended-attribute type filter
  59.   NULL,                                                    // Pointer
  60.   NULL,                                                    // The initial drive
  61.   NULL,                                                    // Pointer
  62.   NULLHANDLE,                                              // Module for custom dialog resources
  63.   "*",                                                     // Character array
  64.   NULL,                                                    // Pointer
  65.   0,                                                       // Number of file names
  66.   0,                                                       // Custom dialog ID
  67.   0,                                                       // X-axis dialog position
  68.   0,                                                       // Y-axis dialog position
  69.   0                                                        // Selected extended-attribute type
  70. };
  71.  
  72. ERROR FileOpen(char *szTitle, char *szFileName) {
  73. /* Creates a file dialog box intended to open an existing file.
  74. */
  75.   fdg.pszTitle=szTitle;
  76.   fdg.pszOKButton="Open";
  77.   strcpy(fdg.szFullFile,"*");
  78.  
  79.   if (!WinFileDlg(HWND_DESKTOP,hwndClient,&fdg)) return ERR_FILES_DLG;
  80.   if (fdg.lReturn != DID_OK) return ERR_FILES_CANCEL;                            // User cancelled
  81.   strcpy(szFileName,fdg.szFullFile);
  82.   return ERR_NOERROR;
  83. }
  84.  
  85. ERROR FileSave(char *szTitle, char *szFileName) {
  86. /* Creates a file dialog box intended to save a file under a new name
  87. */
  88.   fdg.pszTitle=szTitle;
  89.   fdg.pszOKButton="Save";
  90.   strcpy(fdg.szFullFile,"*");
  91.  
  92.   if (!WinFileDlg(HWND_DESKTOP,hwndClient,&fdg)) return ERR_FILES_DLG;
  93.   if (fdg.lReturn != DID_OK) return ERR_FILES_CANCEL;                            // User cancelled
  94.   strcpy(szFileName,fdg.szFullFile);
  95.   return ERR_NOERROR;
  96. }
  97.