ReactOS  0.4.13-dev-563-g0561610
opensave.c
Go to the documentation of this file.
1 #include <precomp.h>
2 
4 
5 /*
6  * Initialize file open / save structure
7  */
9 {
10  ZeroMemory(&ofn, sizeof(ofn));
11  ofn.lStructSize = sizeof(OPENFILENAME);
12  ofn.hwndOwner = hwnd;
15  ofn.lpstrDefExt = _T("bmp");
16 }
17 
18 
19 static BOOL
21 {
22  return TRUE;
23 }
24 
25 
26 BOOL
28  LPTSTR szFileName,
29  LPTSTR szTitleName)
30 {
31  DWORD err;
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");*/
39 
40  static TCHAR Filter[] = _T("Windows Bitmap (*.bmp)\0*.bmp\0");
41 
43  ofn.lpstrFile = szFileName;
44  ofn.lpstrFileTitle = szTitleName;
46 
47  if (GetOpenFileName(&ofn))
48  {
49  return TRUE;
50  }
51 
53 
54  if (err != CDERR_GENERALCODES)
55  MessageBox(NULL, _T("Open file failed"), NULL, 0);
56 
57  return FALSE;
58 }
59 
60 
61 
62 BOOL
64 {
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");
71 
73  ofn.lpstrFile = szFileName;
75 
76  if (GetSaveFileName(&ofn))
77  {
78  if (DoWriteFile(szFileName))
79  return TRUE;
80  }
81 
83  MessageBox(NULL, _T("Save to file failed"), NULL, 0);
84 
85  return FALSE;
86 }
87 
#define CDERR_GENERALCODES
Definition: cderr.h:5
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
LPSTR lpstrFileTitle
Definition: commdlg.h:338
HWND hwndOwner
Definition: commdlg.h:330
#define ZeroMemory
Definition: winbase.h:1635
LPCSTR lpstrDefExt
Definition: commdlg.h:345
#define GetOpenFileName
Definition: commdlg.h:665
CHAR * LPTSTR
Definition: xmlstorage.h:192
DWORD nMaxFile
Definition: commdlg.h:337
VOID FileInitialize(IN HWND hwnd)
Definition: opensave.c:13
#define GetSaveFileName
Definition: commdlg.h:666
BOOL DoSaveFile(IN OUT PWSTR pszFileName)
Definition: opensave.c:58
unsigned int BOOL
Definition: ntddk_ex.h:94
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1802
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:41
smooth NULL
Definition: ftsmooth.c:416
static BOOL DoWriteFile(LPCTSTR pszFileName)
Definition: opensave.c:20
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
static OPENFILENAME ofn
Definition: opensave.c:3
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL DoOpenFile(OUT PWSTR pszFileName)
Definition: opensave.c:36
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define MessageBox
Definition: winuser.h:5688
#define err(...)
LPSTR lpstrFile
Definition: commdlg.h:336
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:139
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342