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