>To all,
>
>I'm trying to make what should be a very simple app: a dialog to display all the DSNs available for a given type of data source and return the user selected DSN. The app has a listbox (displaying the DSNs) in a form. I don't much care for SCXs so the form was saved as a VCX.
>
>If I were using an SCX I could have done:
>DO FORM MyForm WITH m.vcDbType TO m.lcDSN
>
>but I don't want to go that way... it would work for this, but if the dialog required more complexity, a class would be better.
>
>Anyway, to achieve the equivalent functionality as the simple DO FORM command, I had to write the following shell program for the dialog class:
>
>LPARAMETER vcDbType
>
>LOCAL loFrom, lcDSN
>
>m.vcDBType = IIF(PARAMETERS() = 0, m.vcDbType, '')
>
>loForm = NEWOBJECT("myForm", "myForm.vcx")
>
>WITH loForm
> .pcDbType = m.vcDbType
> .Show()
>
> READ EVENTS
>
> .Set_RetVal() && determine which item in the listbox was selected
> m.lcDSN = .pcRetVal
>ENDWITH
>
>RELEASE ALL LIKE lo*
>
>RETURN(m.lcDSN)
>
>
>Hell of a lot of work for a simple dialog, and that doesn't show the extra stuff in the listbox to CLEAR EVENTS on an ENTER or ESCAPE.
>
>There's gotta be a better way.
>
>TIA,
>Thom C.
Thom,
With a show(1) you wouldn't need read/clear events. Hide() the form to continue on the line that follows read events. You'd get the value and release the for there.
PS: I didn't understand why "but if the dialog required more complexity, a class would be better" other than preference.
Cetin