Subversion Repositories filter_foundry

Rev

Rev 259 | Rev 369 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
259 daniel-mar 1
/*
268 daniel-mar 2
    This file is part of a common library
259 daniel-mar 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,
268 daniel-mar 34
                        OSType types[],int ntypes,const char *lpstrFilter,HWND hwndOwner){
259 daniel-mar 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;
268 daniel-mar 59
        }else{
60
                #ifdef DEBUG
259 daniel-mar 61
                char s[0x10];
62
                sprintf(s,"GetOpenFileName(): error %d",CommDlgExtendedError());
63
                dbg(s);
268 daniel-mar 64
                #endif
259 daniel-mar 65
        }
66
 
67
        return sfr->sfGood = false;
68
}
69
 
70
Boolean putfile(StringPtr prompt,StringPtr fname,OSType fileType,OSType fileCreator,
268 daniel-mar 71
                NavReplyRecord *reply,StandardFileReply *sfr,
72
                const char *lpstrDefExt,const char *lpstrFilter,int nFilterIndex,
73
                HWND hwndOwner){
259 daniel-mar 74
        OPENFILENAME ofn;
75
        char file[MAX_PATH];
76
        char title[0x100];
77
 
78
        ZeroMemory(&ofn, sizeof(ofn));
79
 
80
        ofn.lStructSize = sizeof(ofn);
81
        ofn.hwndOwner = hwndOwner;
82
        ofn.lpstrFilter = lpstrFilter;
83
        ofn.nFilterIndex = nFilterIndex;
84
        ofn.lpstrFile = myp2cstrcpy(file,fname);
85
        ofn.nMaxFile = MAX_PATH;
86
        ofn.lpstrTitle = myp2cstrcpy(title,prompt);
87
        ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
88
        ofn.lpstrDefExt = lpstrDefExt;
89
 
90
        if(GetSaveFileName(&ofn)){
91
                myc2pstrcpy(sfr->sfFile.name,file);
92
                return sfr->sfGood = true;
268 daniel-mar 93
        }else{
94
                #ifdef DEBUG
259 daniel-mar 95
                char s[0x10];
96
                sprintf(s,"GetSaveFileName(): error %d",CommDlgExtendedError());
97
                dbg(s);
268 daniel-mar 98
                #endif
259 daniel-mar 99
        }
100
 
101
        return sfr->sfGood = false;
102
}
103
 
104
OSErr completesave(NavReplyRecord *reply){
105
        return noErr;
106
}