[REGEDIT] Pre-select the text in the edit dialog.
[reactos.git] / rosapps / applications / imagesoft / opensave.c
1 #include <precomp.h>
2
3 static OPENFILENAME ofn;
4
5 /*
6 * Initialize file open / save structure
7 */
8 VOID FileInitialize(HWND hwnd)
9 {
10 ZeroMemory(&ofn, sizeof(ofn));
11 ofn.lStructSize = sizeof(OPENFILENAME);
12 ofn.hwndOwner = hwnd;
13 ofn.nMaxFile = MAX_PATH;
14 ofn.nMaxFileTitle = MAX_PATH;
15 ofn.lpstrDefExt = _T("bmp");
16 }
17
18
19 static BOOL
20 DoWriteFile(LPCTSTR pszFileName)
21 {
22 return TRUE;
23 }
24
25
26 BOOL
27 DoOpenFile(HWND hwnd,
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
42 ofn.lpstrFilter = Filter;
43 ofn.lpstrFile = szFileName;
44 ofn.lpstrFileTitle = szTitleName;
45 ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
46
47 if (GetOpenFileName(&ofn))
48 {
49 return TRUE;
50 }
51
52 err = CommDlgExtendedError();
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
63 DoSaveFile(HWND hwnd)
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
72 ofn.lpstrFilter = Filter;
73 ofn.lpstrFile = szFileName;
74 ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
75
76 if (GetSaveFileName(&ofn))
77 {
78 if (DoWriteFile(szFileName))
79 return TRUE;
80 }
81
82 if (CommDlgExtendedError() != CDERR_GENERALCODES)
83 MessageBox(NULL, _T("Save to file failed"), NULL, 0);
84
85 return FALSE;
86 }
87