Please enable JavaScript to view this site.

KOL/MCK - User Guide

fileselection

 

Dialogues are also non-visual objects, although working with them leads to the appearance of some system windows on the screen. But these are system windows, they cannot be configured as a form, and they appear only for a while, to perform certain actions.

 

The file selection dialog allows the user, using a standard interface, to select a file name to create and write to it some information provided by the application, or the name of an existing file to perform any actions with it. The file selection dialog can be a file open or save dialog. Only an existing file can be specified in the open dialog. In the save dialog, it is also possible to specify an existing file, and it is usually accepted that the system in this case asks the user an additional question about whether he really wants to write new information into it (most likely, by screwing up the previous contents of this file). Although, if you specify the "silent" mode in the options, this question will not be asked.

 

The constructor of this control object with such a dialog:

 

NewOpenSaveDialog(s, dir, options) - creates a dialog with the header s (if the string is empty, then the system header is used), with the initial dir directory and options from the following set:

 

OSCreatePrompt - asking the user for confirmation to create a file, if it does not already exist;

OSExtensionDifferent - contains true after the end of the dialog, if the extension of the selected file differs from the default;

OSFileMustExist - the file must exist;

OSHideReadonly - hide the "Read only" switch in the dialog;

OSNoChangedir - the user can select the file name only in the specified directory;

OSNoReferenceLinks - for shortcuts (.lnk) return the path to the shortcut file itself, and not to the file associated with it;

OSAllowMultiSelect - allows multiple choice (multiple filenames are returned);

OSNoNetworkButton - does not allow selection in network folders;

OSNoReadonlyReturn - do not return files with the "read-only" attribute, including from devices and directories to which writing is not allowed;

OSOverwritePrompt - issue a request for confirmation of overwriting for existing files;

OSPathMustExist - the directory must exist;

OSReadonly - the "read-only" switch is initially on, when the dialog is finished this option shows the last value of the switch;

OSNoValidate - do not check the presence of such a file and the correctness of the name (when manually typing the file name in the dialog box);

OSTemplate - the dialog extension template from resources is used (see the Template property);

OSHook - enables an additional custom dialog message handler (see the HookProc property).

 

To simplify the creation procedure, so as not to write out all the necessary properties every time, you can pass the global constant DefOpenSaveDlgOptions as a parameter. Subsequently, the options can be changed to the standard ones that are most suitable for the open or save dialog by changing the value of the OpenDialog property.

 

So, the properties, fields, method and event of the object to control the file selection dialog:

 

Execute - a function for invoking a dialogue. Returns true if the dialog ended with a successful file selection;

Filename - a string that at the output contains the name of the selected file (if the dialog ended successfully, i.e. the Execute method returned true). At the entrance, i.e. before calling the Execute method, this property can be used to assign a default filename to return (this name will be shown initially in the filename input field). When enabling multiple file selection in a dialog, be sure to clear this property by assigning an empty string before calling Execute. For the case when multiple files are selected, the output line is split into parts separated by # 13, the first part contains the path to the directory, and all the rest contain only the file names;

InitialDir - the source directory, the list of which is opened when calling Execute. After calling the dialog, in case of its successful completion, this property contains the path to the directory in which the file was selected;

Filter - a string containing pairs <filter definition> | <filter patterns> separated by '|' (i.e., if there are several filters, then it schematically looks like this: <OF1> | <WF1> | <OF2> | <WF2> | ...). If there are several templates in one filter, then they are separated by the ';' symbol. An example of a typical filter: 'Documents | * .doc; *. Txt | All files | *. *';

FilterIndex - index of the current filter (both before the call to Execute and as a result of its successful execution);

DefExtension - the default extension string (written without a leading period, i.e., for example, 'txt', not '.txt'. Apparently, this property has no other purpose than the ability to check for differences in the extension of the selected file from the default extension, just not;

Title - the title of the dialogue. If this line is empty, the system displays its title;

WndOwner - a window for processing messages, and for transferring to the system as the "owner" of the dialogue (at the end of the dialogue, this window will be activated, as after the usual exit from any modal dialogue);

OpenDialog - when assigning a value (true or false) to the Options property, a set of the most appropriate options is assigned, respectively, for the dialog for opening and saving a file;

Options - dialogue options;

OpenReadOnly - TRUE after Execute, if Read Only check box was checked by the user. Options are not affected anyway.

TemplateName - the name of the resource from which the system loads and configures the extension for the dialog. It is required to add the OpenSaveDialog_Extended symbol to the list of symbols of the conditional compilation of the project, and the osTemplate value in the option;

HookProc - an event for processing messages from the dialogue. It also requires the symbol for conditional compilation OpenSaveDialog_Extended, and the option values ​​osHook;

NoPlaceBar - prohibits showing the "placements" ruler on the left side of the new style dialog.

An additional window template for a dialog in a resource can be created using Borland Workshop or MS Visual C ++. Thus, for example, a set of additional checkboxes, buttons or windows can be created to display the contents of the selected file. You will have to work with windows in the HookProc handler at a low level by calling API functions. But sometimes the ability to add your own controls to the standard opening dialog can be very useful or just necessary.

 

In the MCK package, this object is represented by a non-visual mirror component TOpenSaveDialog.

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC