ReactOS  0.4.15-dev-1068-g467feb9
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 
33  static TCHAR Filter[] = _T("All documents (*.txt,*.rtf)\0*.txt;*.rtf\0") \
34  _T("Rich Text Document (*.rtf)\0*.rtf\0") \
35  _T("Text Document (*.txt)\0*.txt\0");
36 
37 
39  ofn.lpstrFile = szFileName;
40  ofn.lpstrFileTitle = szTitleName;
42 
43  if (GetOpenFileName(&ofn))
44  {
45  return TRUE;
46  }
47 
49 
50  if (err != CDERR_GENERALCODES)
51  MessageBox(NULL, _T("Open file failed"), NULL, 0);
52 
53  return FALSE;
54 }
55 
56 
57 
58 BOOL
60 {
61  TCHAR szFileName[MAX_PATH] = _T("");
62  static TCHAR Filter[] = _T("Rich Text Document (*.rtf)\0*.rtf\0") \
63  _T("Text Document (*.txt)\0*.txt\0");
64 
66  ofn.lpstrFile = szFileName;
68 
69  if (GetSaveFileName(&ofn))
70  {
71  if (DoWriteFile(szFileName))
72  return TRUE;
73  }
74 
76  MessageBox(NULL, _T("Save to file failed"), NULL, 0);
77 
78  return FALSE;
79 }
80 
#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
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
LPSTR lpstrFileTitle
Definition: commdlg.h:338
HWND hwndOwner
Definition: commdlg.h:330
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1648
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
#define FALSE
Definition: types.h:117
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
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
#define MAX_PATH
Definition: compat.h:34
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:5797
static BOOL DoWriteFile(LPCTSTR pszFileName)
Definition: opensave.c:20
#define err(...)
LPSTR lpstrFile
Definition: commdlg.h:336
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
LPCSTR lpstrFilter
Definition: commdlg.h:332
static OPENFILENAME ofn
Definition: opensave.c:3
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:148
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342