Customize the Open Dialog Box

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

This sample illustrates customizing the appearance and behavior of the Open dialog box as exposed through the Common Dialog control.

You can set the Flags property of the Common Dialog control to specify the behavior of the Open dialog box. For a list of the various Flags values, see Open Dialog Box Flag Values.

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

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

Set the Multiple files flag

IF thisform.chkMulti.Value
   m.nFlags = m.nFlags + 512
ENDIF

Set the Help button flag

IF thisform.chkHelp.Value
   m.nFlags = m.nFlags + 16
ENDIF

Set the enforce file existence flag

IF thisform.chkMulti.Value
   m.nFlags = m.nFlags + 4096
ENDIF

Set the Flags property of the Common Dialog control

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.

thisform.oleCommDlog.Filter = "All files" + ;
   "(*.*)|*.*|Text (*.txt)|*.txt" + ;
   "|Pictures(*.bmp;*.ico)|*.bmp;*.ico"