home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / source / sprites / file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-05  |  2.3 KB  |  80 lines

  1. /*
  2.     file.c
  3.  
  4.     File loading functions and corresponding object delete functions
  5.  
  6. */
  7.  
  8. #include "global.h"
  9.  
  10. //
  11. // local data
  12. //
  13.  
  14. char *szOpenFilter = "DIB Files (*.dib)\0*.dib\0"
  15.                      "Bitmap files (*.bmp)\0*.bmp\0"
  16.                      "All Files (*.*)\0*.*\0"
  17.                      "\0";
  18. char *szIniFilter  = "INI Files (*.ini)\0*.ini\0"
  19.                             "All Files (*.*)\0*.*\0"
  20.                             "\0";
  21.  
  22. //
  23. // Put up a dialog to get a filename
  24. //
  25.  
  26. BOOL 
  27. PromptForFileName(hwndOwner, hInst, achFileName, cchFileName,
  28.     szCaption, szFilter, szDefExt, dwFlags)
  29. HWND        hwndOwner;        // window that will own dialog box
  30. HANDLE        hInst;            // module that contains the resources
  31. LPSTR        achFileName;        // where to put file name
  32. WORD        cchFileName;        // size of <achFileName>
  33. LPSTR       szCaption;        // caption string
  34. LPSTR       szFilter;        // file filter
  35. LPSTR       szDefExt;        // default extension
  36. DWORD        dwFlags;        // random flags
  37. {
  38.     OPENFILENAME    ofname;        // parameter block
  39.     BOOL        f;
  40.  
  41.     /* the initial file name is "" unless PFFN_SHOWDEFAULT is given */
  42.     if (!(dwFlags & PFFN_SHOWDEFAULT))
  43.         achFileName[0] = 0;
  44.  
  45.     /* fill in the other fields of <ofname> */
  46.     ofname.lpstrFilter = szFilter;
  47.     ofname.lpstrTitle = szCaption;
  48.     ofname.lpstrDefExt = szDefExt;
  49.     ofname.lStructSize = sizeof(ofname);
  50.     ofname.hwndOwner = hwndOwner;
  51.     ofname.hInstance = hInst;
  52.     ofname.lpstrCustomFilter = NULL;
  53.     ofname.nMaxCustFilter = 0;
  54.     ofname.nFilterIndex = 1;
  55.     ofname.lpstrFile = achFileName;
  56.     ofname.nMaxFile = cchFileName;
  57.     ofname.lpstrFileTitle = NULL;
  58.     ofname.nMaxFileTitle = 0;
  59.     ofname.lpstrInitialDir = NULL;
  60.     ofname.Flags = OFN_HIDEREADONLY |
  61.         (dwFlags & PFFN_OVERWRITEPROMPT ? OFN_OVERWRITEPROMPT : 0);
  62.     ofname.lCustData = NULL;
  63.     ofname.lpfnHook = NULL;
  64.     ofname.lpTemplateName = NULL;
  65.  
  66.     /* prompt the user for the file name */
  67.     if (dwFlags & PFFN_OPENFILE)
  68.         f = GetOpenFileName(&ofname);
  69.     else
  70.         f = GetSaveFileName(&ofname);
  71.  
  72.     /* make the name uppercase if requested */
  73.     if (f && (dwFlags & PFFN_UPPERCASE))
  74.         AnsiUpper(achFileName);
  75.  
  76.     return f;
  77. }
  78.  
  79.  
  80.