Subject Re: Subforms
From Mervyn Bick <invalid@invalid.invalid>
Date Wed, 13 Aug 2014 11:56:14 +0200
Newsgroups dbase.getting-started
Attachment(s) Unnamed File 1Unnamed File 2Unnamed File 3Unnamed File 4Unnamed File 5
create_subform.wfmUnnamed File 7Unnamed File 8Unnamed File 9





On Wed, 13 Aug 2014 10:24:53 +0200, Duncan <finance@iacsa.co.za> wrote:

> I have created a three page form with a datalink for displaying /  
> updating the rowset information. I am trying to create a subform  
> containing the rowset's memo field (for making notes) that can be  
> invoked through a popup menu on any of the three pages. I used the form  
> designer to create the subform and followed the manual's instructions to  
> change:-
>
> class TestFormForm of FORM
>
> to
>
> class TestFormform( Testpopup, "Mypopup") of SUBFORM( Testpopup,  
> "Mypopup")
>
> i.e. Testpopup is the 3 page parent form
>
> but i continually get syntax errors on the above statement which I have  
> amended to exclude the parent name without any success.
> I would welcome any advice to work around the problem.


I found subforms a PITA as the form designer can't handle them.  To get  
round this I wrote a little program to convert forms to sub forms.  This  
way I keep the form available for tweaking in the designer and the subform  
available for use.  If I change the form all I need to do is recreate the  
subform again.  I name all forms to be converted to subforms as  
subxxxxx.wfm and the converted  files are saved as subxxxxx.sfm.

Coordinates for .wfm are relative to the screen coordinates but subform  
coordinates are relative to the parent form's coordinates.  Remember to  
move the .wfm form that is to be converted to a .sfm form to the top left  
corner of the designer before saving it.

The parent object and title for the subform are passed as arguments when  
the subform is instantiated so these values should not be hard coded in  
the subform source code.

class TestFormform( oParent, cTitle) of SUBFORM( oParent, cTitle)

In practice I've found that the value in cTitle does NOT get passed to the  
subform so one needs to set the subform text property manually once the  
subform has been instantiated.

Mervyn.



********* Start of sub1.sfm ********
class sub1Form( oParent, cTitle ) of SUBFORM( oParent, cTitle )
    with (this)
       height = 16.0
       left = 21.5714
       top = 1.1364
       width = 40.0
       text = ""
    endwith

    this.PUSHBUTTON1 = new PUSHBUTTON(this)
    with (this.PUSHBUTTON1)
       onClick = class::PUSHBUTTON1_ONCLICK
       height = 1.0909
       left = 8.2857
       top = 8.7273
       width = 15.2857
       text = "Pushbutton1"
    endwith


    function PUSHBUTTON1_onClick
       this.parent.close()
       return

endclass
********* End of sub1.sfm *********

****** Start of subformtest.wfm *******
** END HEADER

class SubFormTestForm of FORM
    with (this)
       onOpen = class::FORM_ONOPEN
       onClose = class::FORM_ONCLOSE
       height = 19.6818
       left = 71.5714
       top = 4.8182
       width = 70.2857
       text = "Parent Form"
    endwith

    this.TEXT1 = new TEXT(this)
    with (this.TEXT1)
       height = 1.7727
       left = 1.8571
       top = 1.0
       width = 37.4286
       text = "Form with a subform."
    endwith

    this.PUSHBUTTON1 = new PUSHBUTTON(this)
    with (this.PUSHBUTTON1)
       onClick = class::PUSHBUTTON1_ONCLICK
       height = 1.0909
       left = 3.2857
       top = 11.2727
       width = 15.2857
       text = "Open SubForm"
    endwith

    this.PUSHBUTTON2 = new PUSHBUTTON(this)
    with (this.PUSHBUTTON2)
       onClick = class::PUSHBUTTON2_ONCLICK
       height = 1.0909
       left = 3.2857
       top = 13.6818
       width = 15.2857
       text = "Close SubForm"
    endwith


    function form_onClose
       close procedure sub1.sfm
       return

    function form_onOpen
       // instantiate subform
       set procedure to sub1.sfm
       form.subform = new sub1Form( this, " My Subform" )
       //title passed above is ignored. so set it specifically
       form.subform.text = "My subform"

    return

    function PUSHBUTTON1_onClick
        form.subform.open()
       return

    function PUSHBUTTON2_onClick
        form.subform.close()
       return

endclass
********* End of subformtest.wfm *********