Rev 239 | Rev 268 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
259 | daniel-mar | 1 | /* |
2 | This file is part of a common library |
||
3 | Copyright (C) 2002-6 Toby Thain, toby@telegraphics.com.au |
||
4 | |||
5 | This program is free software; you can redistribute it and/or modify |
||
6 | it under the terms of the GNU General Public License as published by |
||
7 | the Free Software Foundation; either version 2 of the License, or |
||
8 | (at your option) any later version. |
||
9 | |||
10 | This program is distributed in the hope that it will be useful, |
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
13 | GNU General Public License for more details. |
||
14 | |||
15 | You should have received a copy of the GNU General Public License |
||
16 | along with this program; if not, write to the Free Software |
||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | */ |
||
19 | |||
20 | /* Choose file dialog - Win32 |
||
21 | (C) 2002 Toby Thain <toby@telegraphics.com.au> */ |
||
22 | |||
23 | #include <string.h> |
||
24 | #include <stdio.h> |
||
25 | |||
26 | #include <windows.h> |
||
27 | |||
28 | #include "choosefile.h" |
||
29 | #include "str.h" |
||
30 | #include "dbg.h" |
||
31 | #include "compat_string.h" |
||
32 | |||
33 | Boolean choosefiletypes(StringPtr prompt,StandardFileReply *sfr,NavReplyRecord *reply, |
||
34 | OSType types[],int ntypes,const char *lpstrFilter,HWND hwndOwner){ |
||
35 | return choosefile(prompt,sfr,reply,types[0],lpstrFilter,hwndOwner); |
||
36 | } |
||
37 | |||
38 | Boolean choosefile(StringPtr prompt,StandardFileReply *sfr,NavReplyRecord *reply,OSType type,const char *lpstrFilter,HWND hwndOwner){ |
||
39 | OPENFILENAME ofn; |
||
40 | char file[MAX_PATH]={0}; |
||
41 | char title[0x100]; |
||
42 | |||
43 | ZeroMemory(&ofn, sizeof(ofn)); |
||
44 | |||
45 | ofn.lStructSize = sizeof(ofn); |
||
46 | ofn.hwndOwner = hwndOwner; |
||
47 | ofn.lpstrFilter = lpstrFilter ; |
||
48 | // ofn.nFilterIndex = 1; |
||
49 | ofn.lpstrFile = file; |
||
50 | ofn.nMaxFile = MAX_PATH; |
||
51 | ofn.lpstrTitle = myp2cstrcpy(title,prompt); |
||
52 | ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; |
||
53 | // ofn.lpstrDefExt = lpstrDefExt; |
||
54 | |||
55 | if(GetOpenFileName(&ofn)){ |
||
56 | myc2pstrcpy(sfr->sfFile.name,file); |
||
57 | sfr->nFileExtension = ofn.nFileExtension; |
||
58 | return sfr->sfGood = true; |
||
59 | } |
||
60 | #ifdef DEBUG |
||
61 | else{ |
||
62 | char s[0x10]; |
||
63 | sprintf(s,"GetOpenFileName(): error %d",CommDlgExtendedError()); |
||
64 | dbg(s); |
||
65 | } |
||
66 | #endif |
||
67 | |||
68 | return sfr->sfGood = false; |
||
69 | } |
||
70 | |||
71 | Boolean putfile(StringPtr prompt,StringPtr fname,OSType fileType,OSType fileCreator, |
||
72 | NavReplyRecord *reply,StandardFileReply *sfr, |
||
73 | const char *lpstrDefExt,const char *lpstrFilter,int nFilterIndex, |
||
74 | HWND hwndOwner){ |
||
75 | OPENFILENAME ofn; |
||
76 | char file[MAX_PATH]; |
||
77 | char title[0x100]; |
||
78 | |||
79 | ZeroMemory(&ofn, sizeof(ofn)); |
||
80 | |||
81 | ofn.lStructSize = sizeof(ofn); |
||
82 | ofn.hwndOwner = hwndOwner; |
||
83 | ofn.lpstrFilter = lpstrFilter; |
||
84 | ofn.nFilterIndex = nFilterIndex; |
||
85 | ofn.lpstrFile = myp2cstrcpy(file,fname); |
||
86 | ofn.nMaxFile = MAX_PATH; |
||
87 | ofn.lpstrTitle = myp2cstrcpy(title,prompt); |
||
88 | ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; |
||
89 | ofn.lpstrDefExt = lpstrDefExt; |
||
90 | |||
91 | if(GetSaveFileName(&ofn)){ |
||
92 | myc2pstrcpy(sfr->sfFile.name,file); |
||
93 | return sfr->sfGood = true; |
||
94 | } |
||
95 | #ifdef DEBUG |
||
96 | else{ |
||
97 | char s[0x10]; |
||
98 | sprintf(s,"GetSaveFileName(): error %d",CommDlgExtendedError()); |
||
99 | dbg(s); |
||
100 | } |
||
101 | #endif |
||
102 | |||
103 | return sfr->sfGood = false; |
||
104 | } |
||
105 | |||
106 | OSErr completesave(NavReplyRecord *reply){ |
||
107 | return noErr; |
||
108 | } |