Dprogramming.com - The D Programming Language [archived content]
Directory

Home
News
Wiki
Entice Designer
DCode editor
Linkdef
bintod
Tutorial
D FAQ
Code
    bintod
    DFL GUI
    D irclib IRC
    fileprompt
    ini files
    Linkdef
    list linked list
    mtext
    Splat sockets
    trayicon
    wildcard
Contact
Paste
Links

fileprompt

Note: DFL has its own file dialog classes named OpenFileDialog and SaveFileDialog.

This module contains a class named FilePrompt that wraps two of the possibly ugliest Windows API functions: GetOpenFileName and GetSaveFileName. Download here. Here is an example showing just how easy this class makes it:
private import std.stdio;
private import fileprompt;

int main()
{
	FilePrompt fprompt = new FilePrompt;
	if(fprompt.open(null, "Text Files (*.txt)\0*.txt\0All Files\0*.*", "test.txt"))
	{
		writefln("The file you selected was: %s.", fprompt.file());
	}
	else
	{
		writefln("You did not select a file.");
	}
	
	return 0;
}
This module also contains a useful function named splitFiles, for splitting a list of files into an array. Useful when a user is able to select multiple files in the FilePrompt, and even the command line string passed to a windows program (through WinMain or GetCommandLine):
char[][] files = splitFiles("fileprompt.d \"long filename in quotes.txt\" foo.txt");
Copyright © 2004-2008 Christopher E. Miller