Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.5 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995, 1996 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: file.cpp
  6. *
  7. ***************************************************************************/
  8. #include <windows.h>
  9. #include <commdlg.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <fstream.h>
  13. char* OpenPMFile( HWND hwnd, const char *wndTitle, int must_exist)
  14. {
  15. static char file[256];
  16. static char fileTitle[256];
  17. static char filter[] = "PM files (*.pmx)\0*.pmx\0"
  18. "All Files (*.*)\0*.*\0";
  19. OPENFILENAME ofn;
  20. lstrcpy( file, "");
  21. lstrcpy( fileTitle, "");
  22. ofn.lStructSize = sizeof(OPENFILENAME);
  23. ofn.hwndOwner = hwnd;
  24. ofn.hInstance = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE);
  25. ofn.lpstrFilter = filter;
  26. ofn.lpstrCustomFilter = (LPSTR) NULL;
  27. ofn.nMaxCustFilter = 0L;
  28. ofn.nFilterIndex = 1L;
  29. ofn.lpstrFile = file;
  30. ofn.nMaxFile = sizeof(file);
  31. ofn.lpstrFileTitle = fileTitle;
  32. ofn.nMaxFileTitle = sizeof(fileTitle);
  33. ofn.lpstrInitialDir = NULL;
  34. ofn.lpstrTitle = wndTitle;
  35. ofn.nFileOffset = 0;
  36. ofn.nFileExtension = 0;
  37. ofn.lpstrDefExt = "*.pm";
  38. ofn.lCustData = 0;
  39. ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST;
  40. if (must_exist) ofn.Flags |= OFN_FILEMUSTEXIST;
  41. if (GetOpenFileName(&ofn))
  42. return (char*)ofn.lpstrFile;
  43. else
  44. return NULL;
  45. }