JavaScript Editor js editor     Web development 



Main Page

File: ...\Samples\Solution\OLE\Commdlog.scx

This sample demonstrates how you can customize the appearance and behavior of the Open dialog box as exposed through the Common Dialog control.

To specify the behavior of the Open dialog box, you can set the Flags property of the Common Dialog control to the sum of specific flag values. The following table lists the possible individual values you can use.

Value Description

1

Causes the read-only check box to be initially checked when the dialog box is created. This flag also indicates the state of the read-only check box when the dialog box is closed.

2

Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether to overwrite the file.

4

Hides the read-only check box.

8

Forces the dialog box to set the current directory to what it was when the dialog box was opened.

16

Causes the dialog box to display the Help button.

256

Specifies that the common dialog box makes it possible for invalid characters in the returned file name.

512

Specifies that the File Name list box makes it possible for multiple selections. The user can select more than one file at run time by pressing the SHIFT key and using the UP ARROW and DOWN ARROW keys to select the desired files. When this is done, the File Name property returns a string containing the names of all selected files. The names in the string are delimited by spaces.

1024

Indicates that the extension of the returned file name is different from the extension specified by the DefaultExt property. This flag isn't set if the DefaultExt property is Null, if the extensions match, or if the file has no extension. This flag value can be checked upon closing the dialog box.

2048

Specifies that the user can enter only valid paths. If this flag is set and the user enters an invalid path, a warning message is displayed.

4096

Specifies that the user can enter only names of existing files in the File Name text box. If this flag is set and the user enters an invalid file name, a warning is displayed. This flag automatically sets the 2048 flag.

8192

Specifies that the dialog box prompts the user to create a file that doesn't currently exist. This flag automatically sets the 4096 and 2048 flags.

16384

Specifies that sharing violation errors will be ignored.

32768

Specifies using the Windows Explorer Open A File dialog box template.

524288

Use the Explorer Open A File dialog box template.

1048576

Do not dereference shell links (also known as shortcuts). By default, choosing a shell link causes it to be dereferenced by the shell.

1048576

Do not dereference shortcuts (shell links). By default, choosing a shortcut causes it to be dereferenced by the shell.

2097152

Makes it possible for the user to use long file names.

The following code in the Click event of cmdFiles checks the values of the various check boxes on the form and sets the Flags property of the Common Dialog control.

Set the Read-only Check Box Flag

В Copy Code
IF !thisform.chkRead.Value
   m.nFlags = m.nFlags + 4
ENDIF

Set the Multiple Files Flag

В Copy Code
IF thisform.chkMulti.Value
   m.nFlags = m.nFlags + 512
ENDIF

Set the Help Button Flag

В Copy Code
IF thisform.chkHelp.Value
   m.nFlags = m.nFlags + 16
ENDIF

Set the Enforce File Existence Flag

В Copy Code
IF thisform.chkMulti.Value
   m.nFlags = m.nFlags + 4096
ENDIF

Set the Flags Property of the Common Dialog Control

В Copy Code
THISFORM.oleCommDlog.Flags = m.nFlags

Set the Filter Property of the Common Dialog Control

You can use the Filter property of the Common Dialog control to specify what files a user is allowed to choose.

В Copy Code
THISFORM.oleCommDlog.Filter = "All files" + ;
   "(*.*)|*.*|Text (*.txt)|*.txt" + ;
   "|Pictures(*.bmp;*.ico)|*.bmp;*.ico"

See Also



JavaScript Editor js editor     Web development