Page 1 of 1
How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by Anonymous >> Tue, 6 Jan 2004 0:42:57 GMT
I have been scanning over the forums here, and through the documentation, but can't seem to find a way to create a browse dialogue which would allow a user to select a file path. This is trivial I suppose, but I am unable to figure this out!
Any help would be appreciated!
Re: How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by cnwjhp1 >> Tue, 6 Jan 2004 1:37:39 GMT
You probably want to use CMDFileOpen. Real-life example below. There is also a form that allows you to search on the server machine.
fileSelect() updating;
vars
cfo:CMDFileOpen;begin
create cfo;
cfo.fileMustExist:=true;
cfo.defaultExt:=".log";
cfo.initDir:=folder.fileName;
cfo.fileName:="*.log";
if cfo.open=0 then
folder.fileName:=cfo.fileName;
currentForm.addFile(cfo.fileName);
endif;
epilog
delete cfo;
end;
Re: How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by scott >> Tue, 6 Jan 2004 2:55:43 GMT
You can use FileFolder class to get a file path. getFilePath():String,updating;
vars
ff:FileFolder;
path:String;begin
create ff transient;
path := ff.browseForFolder("Specify output directory for skin files", "c:\");
return path;
epilog
delete ff;
end;
rgds,
Scott
Bizpoint System Pte Ltd
Re: How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by cnwdad1 >> Tue, 6 Jan 2004 1:46:30 GMT
There's a method on the FileFolder class called "browseForFolder" (and "browseForServerFolder").
regards,
darrell.
Re: How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by Anonymous >> Wed, 7 Jan 2004 20:46:30 GMT
Thx for the replies, they were helpful, but they are able to retrieve the path to a folder, not a file. Is there an easy way to extend this? Thanks agian!
Re: How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by cnwdad1 >> Wed, 7 Jan 2004 21:03:02 GMT
Take a look at the documentation for the "CMDFileOpen" and "CMDFileSave" classes, in the EncycloSys.pdf document. The following is an example of a method I have implemented on the "File" class using the CMDFileOpen class:
cnEcSetOpenName(pMustExist:Boolean; pCreatePrompt:Boolean; pFileFilter:String):Boolean updating;
// ------------------------------------------------------------------------- -------
// Created: 17 August 2001 by cnwdad1
//
// Purpose: This method will prompt the user to select (or enter) a file name,
// and will then use that name to set the receiver's file name.
//
// Parameters: pMustExist - If true, then the file being opened must already exist.
// pCreatePrompt - If true, the user will be prompted to create the
// file if it doesn't already exist.
// pFileFilter - The file-type filter string.
//
// Returns: True if the file name was successfully set, otherwise false. //
// Changed On Changed By Reason
// ---------- ---------- --------------------------------------------------- ----
//
// ------------------------------------------------------------------------- -------
vars
isSuccessful : Boolean;
fileOpenObj : CMDFileOpen;
begin
isSuccessful := false;
create fileOpenObj;
fileOpenObj.fileMustExist := pMustExist;
fileOpenObj.createPrompt := pCreatePrompt;
if pFileFilter <> null then
fileOpenObj.filter := pFileFilter;
endif;
if fileOpenObj.open = 0 then
self.fileName := fileOpenObj.fileName;
isSuccessful := true;
endif;
epilog
delete fileOpenObj;
return isSuccessful;
end;
regards,
darrell.
Re: How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by cnwdad1 >> Wed, 7 Jan 2004 21:22:16 GMT
I guess an example of how the "cnEcSetOpenName" method is used may also be helpful:
browseForFile() updating, protected;
// ------------------------------------------------------------------------- -------
// Created: 19 November 2001 by cnwdad1
//
// Purpose: Browse for a picture file, and load it into the picture control.
//
// Parameters: None
//
// Returns: Nothing
//
// Changed On Changed By Reason
// ---------- ---------- --------------------------------------------------- ----
//
// ------------------------------------------------------------------------- -------
vars
fileObj : File;
fileData : Binary;
fileFilter : String;begin
create fileObj transient;
fileFilter := "All Files (*.*)|*.*|Bitmap Files (*.bmp)|*.bmp|PNG Files (*.png)|*.png";
if fileObj.cnEcSetOpenName(true, false, fileFilter) then
fileData := fileObj.readBinary(theFile.fileLength());
picPicture.picture := fileData;
endif;
epilog
delete fileObj;
end;
regards,
darrell.
Re: How is a browse dialogue created?
Posted: Fri Aug 07, 2009 12:29 pm
by ConvertFromOldNGs
by cnwjhp1 >> Thu, 8 Jan 2004 2:28:15 GMT
Check the first reply to your message - it browses to a file.