ReactOS 0.4.15-dev-8116-gf69e256
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));
15 ofn.lpstrDefExt = _T("bmp");
16}
17
18
19static BOOL
21{
22 return TRUE;
23}
24
25
26BOOL
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
51 MessageBox(NULL, _T("Open file failed"), NULL, 0);
52
53 return FALSE;
54}
55
56
57
58BOOL
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
BOOL DoSaveFile(IN OUT PWSTR pszFileName)
Definition: opensave.c:58
BOOL DoOpenFile(OUT PWSTR pszFileName)
Definition: opensave.c:36
VOID FileInitialize(IN HWND hwnd)
Definition: opensave.c:13
static OPENFILENAMEW ofn
Definition: opensave.c:10
#define CDERR_GENERALCODES
Definition: cderr.h:5
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:148
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define GetSaveFileName
Definition: commdlg.h:666
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define GetOpenFileName
Definition: commdlg.h:665
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
_Must_inspect_result_ _In_opt_ PFLT_FILTER Filter
Definition: fltkernel.h:1801
#define err(...)
HWND hwndOwner
Definition: commdlg.h:361
DWORD Flags
Definition: commdlg.h:373
DWORD nMaxFileTitle
Definition: commdlg.h:370
LPWSTR lpstrFile
Definition: commdlg.h:367
LPWSTR lpstrFileTitle
Definition: commdlg.h:369
LPCWSTR lpstrDefExt
Definition: commdlg.h:376
DWORD lStructSize
Definition: commdlg.h:360
DWORD nMaxFile
Definition: commdlg.h:368
LPCWSTR lpstrFilter
Definition: commdlg.h:363
static BOOL DoWriteFile(LPCTSTR pszFileName)
Definition: opensave.c:20
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define _T(x)
Definition: vfdio.h:22
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define MessageBox
Definition: winuser.h:5822
char TCHAR
Definition: xmlstorage.h:189
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
CHAR * LPTSTR
Definition: xmlstorage.h:192