home *** CD-ROM | disk | FTP | other *** search
/ 3D GFX / 3D GFX.iso / pcutils / os2 / imshow / source / filedlg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-31  |  3.9 KB  |  76 lines

  1. /*****************  Module "FILEDLG.C" Source Code File  *******************/
  2. /*                                                                         */
  3. /* MODULE: FileDlg.c (Routines to choose a file)                           */
  4. /*                                                                         */
  5. /*                                                                         */
  6. /* DEVELOPED BY:                                                           */
  7. /* -------------                                                           */
  8. /*  Martin Erzberger, 1989/93                                              */
  9. /*                                                                         */
  10. /* VERSION: 2.02, 1/93                                                     */
  11. /* --------                                                                */
  12. /*                                                                         */
  13. /* PURPOSE OF MODULE:                                                      */
  14. /* ------------------                                                      */
  15. /*  - Routines to choose a file to load.                                   */
  16. /*                                                                         */
  17. /***************************************************************************/
  18.  
  19.  
  20. #define INCL_WINSTDFILE                /* File dialog                      */
  21. #include <os2.h>                       /* Main OS/2 header file            */
  22.  
  23. #include <stdio.h>
  24. #include <string.h>
  25. #include <memory.h>
  26.  
  27.  
  28. /********************  Start of procedure GetFileName  *********************/
  29. /*                                                                         */
  30. /* The procedure GetFileName is the moduleinterface. It gets the parent-   */
  31. /* and ownerhandle of the dialog box as input, and giver back the          */
  32. /* choosen filename.                                                       */
  33. /* The flag bOpen is not currently used.                                   */
  34. /*                                                                         */
  35. /* Returncodes: TRUE -  A filename was choosen                             */
  36. /*              FALSE - There was an error or the user chose "cancel"      */
  37. /*                                                                         */
  38. /***************************************************************************/
  39.  
  40. BOOL GetFileName (CHAR *szFileName, HWND hwndParent,
  41.                         HWND hwndOwner, BOOL bOpen)
  42. {
  43.   FILEDLG  fild;
  44.   CHAR tempFileName[255];
  45.  
  46.   memset (&fild, 0, sizeof(FILEDLG));
  47.  
  48.   fild.cbSize = sizeof(FILEDLG);
  49.  
  50.   if (bOpen) {
  51.      fild.fl = FDS_OPEN_DIALOG | FDS_CENTER;
  52.      fild.pszTitle = "Open im or Bitmap File:";
  53.   } else {
  54.      fild.fl = FDS_SAVEAS_DIALOG | FDS_CENTER;
  55.      fild.pszTitle = "Save im or Bitmap File:";
  56.   } /* endif */
  57.  
  58.   WinFileDlg (hwndParent, hwndOwner, &fild);
  59.   if (fild.lReturn == DID_OK) {                  /* There was a selection  */
  60.      strcpy (szFileName, fild.szFullFile);       /* Get the filename       */
  61.      /* I want to change AND STAY into a directory, so there is some       */
  62.      /* more coding to do:                                                 */
  63.      DosSetDefaultDisk ((ULONG)(szFileName[0]-'@'));  /* Set drive         */
  64.      strcpy (tempFileName, szFileName);               /* Save filename     */
  65.      *(strrchr(tempFileName, '\\')) = '\0';           /* Cut of filename   */
  66.      if (tempFileName[0] == '\0')                     /* Was file in root? */
  67.        DosSetCurrentDir ("\\");                       /* ok, so set it     */
  68.      else
  69.        DosSetCurrentDir (tempFileName);               /* else set dir.     */
  70.      return TRUE;                                    /* Give back success  */
  71.   } else {
  72.      return FALSE;                                   /* or failure...      */
  73.   } /* endif */
  74. }
  75. /*********************  End of procedure GetFileName  *********************/
  76.