3 static OPENFILENAME ofn
;
6 * Initialize file open / save structure
8 VOID
FileInitialize(HWND hwnd
)
10 ZeroMemory(&ofn
, sizeof(ofn
));
11 ofn
.lStructSize
= sizeof(OPENFILENAME
);
13 ofn
.nMaxFile
= MAX_PATH
;
14 ofn
.nMaxFileTitle
= MAX_PATH
;
15 ofn
.lpstrDefExt
= _T("bmp");
20 DoWriteFile(LPCTSTR pszFileName
)
32 /*static TCHAR Filter[] = _T("All image files (*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png)\0*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png\0") \
33 _T("All files (*.*)\0*.*\0") \
34 _T("Graphics Interchange format (*gif)\0*.gif\0") \
35 _T("Windows Bitmap (*bmp)\0*.bmp\0") \
36 _T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \
37 _T("TAG Image File Format (*tif)\0*.tif\0") \
38 _T("Portable Network Graphics (*png)\0*.png\0\0");*/
40 static TCHAR Filter
[] = _T("Windows Bitmap (*.bmp)\0*.bmp\0");
42 ofn
.lpstrFilter
= Filter
;
43 ofn
.lpstrFile
= szFileName
;
44 ofn
.lpstrFileTitle
= szTitleName
;
45 ofn
.Flags
= OFN_EXPLORER
| OFN_FILEMUSTEXIST
| OFN_HIDEREADONLY
;
47 if (GetOpenFileName(&ofn
))
52 err
= CommDlgExtendedError();
54 if (err
!= CDERR_GENERALCODES
)
55 MessageBox(NULL
, _T("Open file failed"), NULL
, 0);
65 TCHAR szFileName
[MAX_PATH
] = _T("");
66 static TCHAR Filter
[] = _T("Graphics Interchange format (*gif)\0*.gif\0") \
67 _T("Windows Bitmap (*bmp)\0*.bmp\0") \
68 _T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \
69 _T("TAG Image File Format (*tif)\0*.tif\0") \
70 _T("Portable Network Graphics (*png)\0*.png\0\0");
72 ofn
.lpstrFilter
= Filter
;
73 ofn
.lpstrFile
= szFileName
;
74 ofn
.Flags
= OFN_EXPLORER
| OFN_PATHMUSTEXIST
| OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
;
76 if (GetSaveFileName(&ofn
))
78 if (DoWriteFile(szFileName
))
82 if (CommDlgExtendedError() != CDERR_GENERALCODES
)
83 MessageBox(NULL
, _T("Save to file failed"), NULL
, 0);