2.20.3 Open Dialog Sample Form

Copy and paste this code to a form to execute a sample application that invokes the Open Dialog. The form must be enabled for full RDLMX.

*

*

* COMPONENT:  STD_FORM

*

*

Function Options(*DIRECT)

Begin_Com Role(*EXTENDS #PRIM_FORM) CLIENTHEIGHT(686) CLIENTWIDTH(475) HEIGHT(713) LEFT(465) TOP(108) WIDTH(483)

Define_Com Class(#PRIM_LABL) Name(#InitialValuesLbl) CAPTION('Open dialog Inital values') DISPLAYPOSITION(6) HEIGHT(20) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(6) TABSTOP(False) TOP(8) WIDTH(137)

Define_Com Class(#PRIM_LABL) Name(#InitialOpenFileLbl) CAPTION('Initial Directory') DISPLAYPOSITION(5) HEIGHT(20) LEFT(24) PARENT(#COM_OWNER) TABPOSITION(5) TABSTOP(False) TOP(32) WIDTH(81)

Define_Com Class(#PRIM_EDIT) Name(#InitialDirectory) DISPLAYPOSITION(3) LEFT(112) PARENT(#COM_OWNER) SHOWSELECTION(False) SHOWSELECTIONHILIGHT(False) TABPOSITION(3) TOP(32) WIDTH(289)

Define_Com Class(#PRIM_PHBN) Name(#PHBN_1) CAPTION('Start Open File Dialog') DISPLAYPOSITION(1) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(1) TOP(224) WIDTH(161)

Define_Com Class(#PRIM_APPL.ICommonDialogFileOpen) Name(#openFileDlg) Reference(*DYNAMIC)

Define_Com Class(#PRIM_LABL) Name(#ResultLbl) CAPTION('Open File dialog results') DISPLAYPOSITION(7) HEIGHT(25) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(7) TABSTOP(False) TOP(264) WIDTH(121)

Define_Com Class(#PRIM_LABL) Name(#FileCountLb) CAPTION('Selected File Count') DISPLAYPOSITION(4) HEIGHT(20) LEFT(32) PARENT(#COM_OWNER) TABPOSITION(4) TABSTOP(False) TOP(400) WIDTH(105)

Define_Com Class(#PRIM_PHBN) Name(#GotoOpenFileForm) CAPTION('Goto Open File Dialog form') DISPLAYPOSITION(8) LEFT(280) PARENT(#COM_OWNER) TABPOSITION(8) TOP(656) WIDTH(185)

Define_Com Class(#PRIM_EDIT) Name(#FileCount) DISPLAYPOSITION(9) LEFT(152) PARENT(#COM_OWNER) SHOWSELECTION(False) SHOWSELECTIONHILIGHT(False) TABPOSITION(9) TOP(392) WIDTH(49)

Define_Com Class(#PRIM_GPBX) Name(#GPBX_1) DISPLAYPOSITION(10) HEIGHT(81) LEFT(32) PARENT(#COM_OWNER) TABPOSITION(10) TABSTOP(False) TOP(304) WIDTH(193)

Define_Com Class(#PRIM_RDBN) Name(#OkButtonPressed) CAPTION('OK Button pressed') DISPLAYPOSITION(1) LEFT(16) PARENT(#GPBX_1) TABPOSITION(1) TOP(16)

Define_Com Class(#PRIM_RDBN) Name(#CancelButtonPressed) CAPTION('Cancel Button pressed') DISPLAYPOSITION(2) LEFT(16) PARENT(#GPBX_1) TABPOSITION(2) TOP(48) WIDTH(153)

Define_Com Class(#PRIM_CKBX) Name(#ExplorerMode) CAPTION('Explorer Mode') DISPLAYPOSITION(11) LEFT(24) PARENT(#COM_OWNER) TABPOSITION(11) TOP(152)

Define_Com Class(#AAsavefil) Name(#SaveFileDlgForm)

Define_Com Class(#PRIM_CKBX) Name(#Multiselect) CAPTION('Multiselect') DISPLAYPOSITION(12) LEFT(24) PARENT(#COM_OWNER) TABPOSITION(12) TOP(176)

Define_Com Class(#PRIM_EDIT) Name(#Title) DISPLAYPOSITION(13) LEFT(112) PARENT(#COM_OWNER) SHOWSELECTION(False) SHOWSELECTIONHILIGHT(False) TABPOSITION(13) TOP(56) WIDTH(289)

Define_Com Class(#PRIM_LABL) Name(#TitleLbl) CAPTION('Title') DISPLAYPOSITION(14) HEIGHT(25) LEFT(24) PARENT(#COM_OWNER) TABPOSITION(14) TABSTOP(False) TOP(56) WIDTH(81)

Define_Com Class(#PRIM_CKBX) Name(#HideReadOnly) CAPTION('Hide Read-Only') DISPLAYPOSITION(15) LEFT(24) PARENT(#COM_OWNER) TABPOSITION(15) TOP(128)

Define_Com Class(#PRIM_LTBX) Name(#fileLst) DISPLAYPOSITION(2) HEIGHT(210) LEFT(16) PARENT(#COM_OWNER) SHOWSELECTION(True) TABPOSITION(2) TOP(450) WIDTH(225)

Define_Com Class(#PRIM_LBCL) Name(#TRACECOL1) DISPLAYPOSITION(1) PARENT(#fileLst) SOURCE(#STD_TEXT) WIDTH(10)

Define_Com Class(#PRIM_EDIT) Name(#File) DISPLAYPOSITION(16) LEFT(112) PARENT(#COM_OWNER) SHOWSELECTION(False) SHOWSELECTIONHILIGHT(False) TABPOSITION(16) TOP(80) WIDTH(289)

Define_Com Class(#PRIM_LABL) Name(#FileLb) CAPTION('File') DISPLAYPOSITION(17) HEIGHT(23) LEFT(27) PARENT(#COM_OWNER) TABPOSITION(17) TABSTOP(False) TOP(80) WIDTH(54)

Evtroutine Handling(#com_owner.Initialize)

Set Com(#com_owner) CAPTION(*component_desc)

Endroutine

Evtroutine Handling(#PHBN_1.Click)

Invoke Method(#sys_appln.CreateFileOpenDialog) RESULT(#OpenFileDLG)

Define Field(#boolRes) Type(*BOOLEAN)

#OpenFileDLG.Title := #TITLE.Text

#OpenFileDLG.InitialDir := #INITIALDIRECTORY.Text

#OPENFILEDLG.File := #FILE.Text

#OpenFileDLG.AddFilter( 'First entry (*.nothing)' '*.nothing' )

* deliberately make .cpp as .hpp to check overwriting facility later

#OpenFileDLG.AddFilter( 'C++ defn files (*.cpp)' '*.hpp' )

#OpenFileDLG.AddFilter( 'C++ header files ( ended with *.hpp)' '*.hpp' )

* correct the first the initial filter

#OpenFileDLG.FilterCaption<2> := 'C++ defn files (corrected to *.cpp & *.c)'

#OpenFileDLG.FilterExtension<2> := '*.cpp;*.c'

* add an extra filter

#OpenFileDLG.FilterCaption<4> := 'Text Files (*.txt)'

#OpenFileDLG.FilterExtension<4> := '*.txt'

* select something non-default

#OpenFileDLG.FilterIndex := 2

If (#Hidereadonly.ButtonState = checked)

#OPENFILEDLG.HideReadOnly := true

Else

#OPENFILEDLG.HideReadOnly := false

Endif

If (#Explorermode.ButtonState = checked)

#OPENFILEDLG.ExplorerStyle := true

Else

#OPENFILEDLG.ExplorerStyle := false

Endif

If (#Multiselect.ButtonState = checked)

#OPENFILEDLG.MultiSelect := true

Else

#OPENFILEDLG.MultiSelect := false

Endif

Invoke Method(#OpenFileDLG.Show) OKPRESSED(#boolRes) FORMOWNER(#com_self)

* ensure fresh start every time the dialog is open

Clr_List Named(#filelst)

If (#BOOLRES)

#OKBUTTONPRESSED.ButtonChecked := true

#CANCELBUTTONPRESSED.ButtonChecked := false

Define Field(#i) Type(*INT)

#i := 1

#std_count := #oPENFileDLG.FileCount

If Cond(#std_count = 0)

#std_text := #OPENFILEDLG.FileTitle

Add_Entry To_List(#filelst)

Else

Dountil Cond(#i > #std_count)

#std_text := #OPENFileDLG.Files<#i>

Add_Entry To_List(#filelst)

#i := #i + 1

Enduntil

Endif

#FILECOUNT.Value := #OPENFILEDLG.FileCount.AsString

Else

#CANCELBUTTONPRESSED.ButtonChecked := true

#okbUTTONPRESSED.ButtonChecked := false

Endif

Endroutine

Evtroutine Handling(#GotoOpenFileForm.Click)

Invoke Method(#SAVEFILEDLGFORM.ShowForm)

Endroutine

End_Com