Dynamic dbForms << Back



There are a couple of small details you need to pay attention to when dynamically creating/destroying dbForms Here is a full-blown sample using the Order Entry's customer table.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Use DfAllEnt
Open "Customer.dat" as Customer
 
Object oPanel is a Panel
    Set Size to 300 500
    Object oClient is a ClientArea
        Activate_View Activate_oTestView for oTestView
        Object oTestView is a dbView
            Set Size to 300 300
            Property Handle[] phForms
            Object oDD is a DataDictionary
                Set Main_File to Customer.File_Number
                Set Ordering to 1
            End_Object
            Set Server to (oDD(Self))
            Set Main_DD to (oDD(Self))
            Procedure CreateForm Integer iField Integer iY String sLabel
                Handle[] hForms
                Handle hForm
                Object oForm Is A dbForm
                    Move Self to hForm
                    Set Label to sLabel
                    Send Bind_Data Customer.File_Number iField
                    Set Server to (oDD(Self))
                    Set Location to iY 100
                    Set Size to 20 100
                End_Object
                Send Activate of hForm
                Get phForms to hForms
                Move hForm to hForms[SizeOfArray(hForms)]
                Set phForms to hForms
            End_Procedure
            Procedure DestroyForms
                Handle[] hForms hBlanks
                Handle hServer
                Integer iCount
                Get phForms to hForms
                Move (SizeOfArray(hForms)) to iCount
                While (iCount > 0)
                    Decrement iCount
                    Get Server of hForms[iCount] to hServer
                    Send Remove_User_Interface of hServer hForms[iCount]
                    Send Destroy of hForms[iCount]
                Loop
                Set phForms to hBlanks
            End_Procedure
            Object oButton is a Button
                Set Label to "Create"
                Procedure OnClick
                    Send CreateForm Field Customer.Customer_Number 50 "Number"
                    Send CreateForm Field Customer.Name 70 "Name"
                    Send CreateForm Field Customer.Address 90 "Address"
                End_Procedure
            End_Object
            Object oButton is a Button
                Set Label to "Destroy"
                Set Location to 0 50
                Procedure OnClick
                    Send DestroyForms
                End_Procedure
            End_Object
             
        End_Object
    End_Object
End_Object
 
Send Activate_oTestView of (oClient(oPanel(Self)))
Start_UI





Free Web Hosting