The R Project SVN R

Rev

Rev 22842 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22842 Rev 22872
Line 133... Line 133...
133
    GetCurrentDirectory(MAX_PATH, cod);
133
    GetCurrentDirectory(MAX_PATH, cod);
134
}
134
}
135
 
135
 
136
char *askfilename(char *title, char *default_name)
136
char *askfilename(char *title, char *default_name)
137
{
137
{
138
	int i;
-
 
139
	OPENFILENAME ofn;
-
 
140
        char cwd[MAX_PATH]="";
-
 
141
	if (! default_name)
-
 
142
		default_name = "";
-
 
143
	strcpy(strbuf, default_name);
-
 
144
        GetCurrentDirectory(MAX_PATH,cwd);
-
 
145
        if (!strcmp(cod,"")) strcpy(cod,cwd);
-
 
146
 
-
 
147
	ofn.lStructSize     = sizeof(OPENFILENAME);
-
 
148
	ofn.hwndOwner       = current_window ?
-
 
149
				current_window->handle : 0;
-
 
150
	ofn.hInstance       = 0;
-
 
151
        ofn.lpstrFilter     = userfilter?userfilter:filter[0];
138
	if (*askfilenames(title, default_name, 0, userfilter?userfilter:filter[0], 0,
152
	ofn.lpstrCustomFilter = NULL;
-
 
153
	ofn.nMaxCustFilter  = 0;
-
 
154
	ofn.nFilterIndex    = 0;
-
 
155
	ofn.lpstrFile       = strbuf;
139
				          strbuf, BUFSIZE)) return strbuf;
156
	ofn.nMaxFile        = BUFSIZE;
-
 
157
	ofn.lpstrFileTitle  = NULL;
-
 
158
	ofn.nMaxFileTitle   = _MAX_FNAME + _MAX_EXT;
-
 
159
        ofn.lpstrInitialDir = cod;
-
 
160
	ofn.lpstrTitle      = title;
-
 
161
	ofn.Flags           = OFN_CREATEPROMPT | OFN_HIDEREADONLY;
-
 
162
	ofn.nFileOffset     = 0;
-
 
163
	ofn.nFileExtension  = 0;
-
 
164
	ofn.lpstrDefExt     = "*";
-
 
165
	ofn.lCustData       = 0L;
-
 
166
	ofn.lpfnHook        = NULL;
-
 
167
	ofn.lpTemplateName  = NULL;
-
 
168
 
-
 
169
	if (GetOpenFileName(&ofn) == 0) {
-
 
170
		GetCurrentDirectory(MAX_PATH,cod);
-
 
171
		SetCurrentDirectory(cwd);
-
 
172
		return NULL;
140
	else return NULL;
173
	} else {
-
 
174
		GetCurrentDirectory(MAX_PATH,cod);
-
 
175
		SetCurrentDirectory(cwd);
-
 
176
		for (i=0; i<10; i++)
-
 
177
			if (peekevent()) doevent();
-
 
178
		return strbuf;
-
 
179
	}
-
 
180
}
141
}
181
 
142
 
182
char *askfilenames(char *title, char *default_name, char *strbuf, int bufsize)
143
char *askfilenames(char *title, char *default_name, int multi,
-
 
144
			       char *filters, int filterindex, char *strbuf, int bufsize)
183
{
145
{
184
	int i;
146
	int i;
185
	OPENFILENAME ofn;
147
	OPENFILENAME ofn;
186
        char cwd[MAX_PATH]="";
148
        char cwd[MAX_PATH]="";
187
	if (! default_name)
149
	if (! default_name)
Line 192... Line 154...
192
 
154
 
193
	ofn.lStructSize     = sizeof(OPENFILENAME);
155
	ofn.lStructSize     = sizeof(OPENFILENAME);
194
	ofn.hwndOwner       = current_window ?
156
	ofn.hwndOwner       = current_window ?
195
				current_window->handle : 0;
157
				current_window->handle : 0;
196
	ofn.hInstance       = 0;
158
	ofn.hInstance       = 0;
197
        ofn.lpstrFilter     = userfilter?userfilter:filter[0];
159
    ofn.lpstrFilter     = filters;
198
	ofn.lpstrCustomFilter = NULL;
160
	ofn.lpstrCustomFilter = NULL;
199
	ofn.nMaxCustFilter  = 0;
161
	ofn.nMaxCustFilter  = 0;
200
	ofn.nFilterIndex    = 0;
162
	ofn.nFilterIndex    = filterindex;
201
	ofn.lpstrFile       = strbuf;
163
	ofn.lpstrFile       = strbuf;
202
	ofn.nMaxFile        = bufsize;
164
	ofn.nMaxFile        = bufsize;
203
	ofn.lpstrFileTitle  = NULL;
165
	ofn.lpstrFileTitle  = NULL;
204
	ofn.nMaxFileTitle   = _MAX_FNAME + _MAX_EXT;
166
	ofn.nMaxFileTitle   = _MAX_FNAME + _MAX_EXT;
205
        ofn.lpstrInitialDir = cod;
167
        ofn.lpstrInitialDir = cod;
206
	ofn.lpstrTitle      = title;
168
	ofn.lpstrTitle      = title;
207
	ofn.Flags           = OFN_CREATEPROMPT | OFN_HIDEREADONLY
169
	ofn.Flags           = OFN_CREATEPROMPT | OFN_HIDEREADONLY | OFN_EXPLORER;
208
	                    | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
170
	if (multi) ofn.Flags |= OFN_ALLOWMULTISELECT;
209
	ofn.nFileOffset     = 0;
171
	ofn.nFileOffset     = 0;
210
	ofn.nFileExtension  = 0;
172
	ofn.nFileExtension  = 0;
211
	ofn.lpstrDefExt     = "*";
173
	ofn.lpstrDefExt     = "*";
212
	ofn.lCustData       = 0L;
174
	ofn.lCustData       = 0L;
213
	ofn.lpfnHook        = NULL;
175
	ofn.lpfnHook        = NULL;