winemac.drv: Implement GetMonitorInfo.
[wine] / dlls / commdlg.dll16 / filedlg.c
1 /*
2  * COMMDLG - File Dialogs
3  *
4  * Copyright 1994 Martin Ayotte
5  * Copyright 1996 Albrecht Kleine
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20  */
21 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "wine/winbase16.h"
25 #include "wingdi.h"
26 #include "winuser.h"
27 #include "commdlg.h"
28 #include "cdlg16.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
32
33 static UINT_PTR CALLBACK dummy_hook( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
34 {
35     return FALSE;
36 }
37
38 /***********************************************************************
39  *           FileOpenDlgProc   (COMMDLG.6)
40  */
41 BOOL16 CALLBACK FileOpenDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam)
42 {
43     FIXME( "%04x %04x %04x %08lx: stub\n", hWnd16, wMsg, wParam, lParam );
44     return FALSE;
45 }
46
47 /***********************************************************************
48  *           FileSaveDlgProc   (COMMDLG.7)
49  */
50 BOOL16 CALLBACK FileSaveDlgProc16(HWND16 hWnd16, UINT16 wMsg, WPARAM16 wParam, LPARAM lParam)
51 {
52     FIXME( "%04x %04x %04x %08lx: stub\n", hWnd16, wMsg, wParam, lParam );
53     return FALSE;
54 }
55
56 /***********************************************************************
57  *           GetOpenFileName   (COMMDLG.1)
58  *
59  * Creates a dialog box for the user to select a file to open.
60  *
61  * RETURNS
62  *    TRUE on success: user selected a valid file
63  *    FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
64  *
65  * BUGS
66  *    unknown, there are some FIXMEs left.
67  */
68 BOOL16 WINAPI GetOpenFileName16( SEGPTR ofn ) /* [in/out] address of structure with data*/
69 {
70     LPOPENFILENAME16 lpofn = MapSL(ofn);
71     OPENFILENAMEA ofn32;
72     BOOL ret;
73
74     if (!lpofn) return FALSE;
75
76     ofn32.lStructSize       = OPENFILENAME_SIZE_VERSION_400A;
77     ofn32.hwndOwner         = HWND_32( lpofn->hwndOwner );
78     ofn32.lpstrFilter       = MapSL( lpofn->lpstrFilter );
79     ofn32.lpstrCustomFilter = MapSL( lpofn->lpstrCustomFilter );
80     ofn32.nMaxCustFilter    = lpofn->nMaxCustFilter;
81     ofn32.nFilterIndex      = lpofn->nFilterIndex;
82     ofn32.lpstrFile         = MapSL( lpofn->lpstrFile );
83     ofn32.nMaxFile          = lpofn->nMaxFile;
84     ofn32.lpstrFileTitle    = MapSL( lpofn->lpstrFileTitle );
85     ofn32.nMaxFileTitle     = lpofn->nMaxFileTitle;
86     ofn32.lpstrInitialDir   = MapSL( lpofn->lpstrInitialDir );
87     ofn32.lpstrTitle        = MapSL( lpofn->lpstrTitle );
88     ofn32.Flags             = (lpofn->Flags & ~OFN_ENABLETEMPLATE) | OFN_ENABLEHOOK;
89     ofn32.nFileOffset       = lpofn->nFileOffset;
90     ofn32.nFileExtension    = lpofn->nFileExtension;
91     ofn32.lpstrDefExt       = MapSL( lpofn->lpstrDefExt );
92     ofn32.lCustData         = lpofn->lCustData;
93     ofn32.lpfnHook          = dummy_hook;  /* this is to force old 3.1 dialog style */
94
95     if (lpofn->Flags & OFN_ENABLETEMPLATE)
96         FIXME( "custom templates no longer supported, using default\n" );
97     if (lpofn->Flags & OFN_ENABLEHOOK)
98         FIXME( "custom hook %p no longer supported\n", lpofn->lpfnHook );
99
100     if ((ret = GetOpenFileNameA( &ofn32 )))
101     {
102         lpofn->nFilterIndex   = ofn32.nFilterIndex;
103         lpofn->nFileOffset    = ofn32.nFileOffset;
104         lpofn->nFileExtension = ofn32.nFileExtension;
105     }
106     return ret;
107 }
108
109 /***********************************************************************
110  *           GetSaveFileName   (COMMDLG.2)
111  *
112  * Creates a dialog box for the user to select a file to save.
113  *
114  * RETURNS
115  *    TRUE on success: user enters a valid file
116  *    FALSE on cancel, error, close or filename-does-not-fit-in-buffer.
117  *
118  * BUGS
119  *    unknown. There are some FIXMEs left.
120  */
121 BOOL16 WINAPI GetSaveFileName16( SEGPTR ofn ) /* [in/out] address of structure with data*/
122 {
123     LPOPENFILENAME16 lpofn = MapSL(ofn);
124     OPENFILENAMEA ofn32;
125     BOOL ret;
126
127     if (!lpofn) return FALSE;
128
129     ofn32.lStructSize       = OPENFILENAME_SIZE_VERSION_400A;
130     ofn32.hwndOwner         = HWND_32( lpofn->hwndOwner );
131     ofn32.lpstrFilter       = MapSL( lpofn->lpstrFilter );
132     ofn32.lpstrCustomFilter = MapSL( lpofn->lpstrCustomFilter );
133     ofn32.nMaxCustFilter    = lpofn->nMaxCustFilter;
134     ofn32.nFilterIndex      = lpofn->nFilterIndex;
135     ofn32.lpstrFile         = MapSL( lpofn->lpstrFile );
136     ofn32.nMaxFile          = lpofn->nMaxFile;
137     ofn32.lpstrFileTitle    = MapSL( lpofn->lpstrFileTitle );
138     ofn32.nMaxFileTitle     = lpofn->nMaxFileTitle;
139     ofn32.lpstrInitialDir   = MapSL( lpofn->lpstrInitialDir );
140     ofn32.lpstrTitle        = MapSL( lpofn->lpstrTitle );
141     ofn32.Flags             = (lpofn->Flags & ~OFN_ENABLETEMPLATE) | OFN_ENABLEHOOK;
142     ofn32.nFileOffset       = lpofn->nFileOffset;
143     ofn32.nFileExtension    = lpofn->nFileExtension;
144     ofn32.lpstrDefExt       = MapSL( lpofn->lpstrDefExt );
145     ofn32.lCustData         = lpofn->lCustData;
146     ofn32.lpfnHook          = dummy_hook;  /* this is to force old 3.1 dialog style */
147
148     if (lpofn->Flags & OFN_ENABLETEMPLATE)
149         FIXME( "custom templates no longer supported, using default\n" );
150     if (lpofn->Flags & OFN_ENABLEHOOK)
151         FIXME( "custom hook %p no longer supported\n", lpofn->lpfnHook );
152
153     if ((ret = GetSaveFileNameA( &ofn32 )))
154     {
155         lpofn->nFilterIndex   = ofn32.nFilterIndex;
156         lpofn->nFileOffset    = ofn32.nFileOffset;
157         lpofn->nFileExtension = ofn32.nFileExtension;
158     }
159     return ret;
160 }
161
162
163 /***********************************************************************
164  *      GetFileTitle            (COMMDLG.27)
165  */
166 short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
167 {
168         return GetFileTitleA(lpFile, lpTitle, cbBuf);
169 }