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.

59 lines
1.6 KiB

  1. /*
  2. This is a very simple file open dbox.
  3. */
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <windows.h>
  8. #include "mcitest.h"
  9. #include "commdlg.h"
  10. // global stuff
  11. static TCHAR szSearchSpec[_MAX_PATH];
  12. // routine to invoke the standard file open dialog box
  13. int DlgOpen(HANDLE hModule, HWND hParent, LPTSTR lpName, int count, UINT flags)
  14. {
  15. OPENFILENAME ofn;
  16. strcpy(szSearchSpec, lpName);
  17. if (strlen(szSearchSpec) == 0) strcpy(szSearchSpec, TEXT("*.*"));
  18. dprintf3((TEXT("Search spec: %s"), szSearchSpec));
  19. *lpName = 0;
  20. ofn.lStructSize = sizeof(ofn);
  21. ofn.hwndOwner = hParent;
  22. ofn.hInstance = hModule;
  23. ofn.lpstrFilter = TEXT("MCI Files\0*.mci\0All Files\0*.*\0");
  24. ofn.lpstrCustomFilter = NULL;
  25. ofn.nMaxCustFilter = 0;
  26. ofn.nFilterIndex = 1;
  27. ofn.lpstrFile = lpName;
  28. ofn.nMaxFile = count;
  29. ofn.lpstrFileTitle = NULL;
  30. ofn.nMaxFileTitle = 0;
  31. ofn.lpstrInitialDir = TEXT(".mci");
  32. ofn.Flags = flags;
  33. ofn.nFileOffset = 0;
  34. ofn.nFileExtension = 0;
  35. ofn.lpstrDefExt = szSearchSpec;
  36. ofn.lCustData = 0;
  37. ofn.lpfnHook = NULL;
  38. ofn.lpTemplateName = NULL;
  39. if (flags & OFN_FILEMUSTEXIST) {
  40. ofn.lpstrTitle = TEXT("File Open");
  41. dprintf3((TEXT("Calling GetOpenFileName")));
  42. return GetOpenFileName(&ofn);
  43. } else {
  44. ofn.lpstrTitle = TEXT("File Save");
  45. dprintf3((TEXT("Calling GetSaveFileName")));
  46. return GetSaveFileName(&ofn);
  47. }
  48. }