Views

A view is a specialized object package. It is a stand-alone data-entry unit. An example of a view might be a customer entry form or an order entry form. Views are used in Windows Applications.

As more views get added to a single program, the complexity of the program will increase. If the views are allowed to interact with other views, it will become increasingly difficult to manage and maintain a large program. By making each view independent of other views, you will be able to control this complexity. A large program will merely be a collection of small programs (views).

We must be able to create and test views by themselves. When we eventually add them to the larger program, we can do so with the knowledge that the new view will not affect or be affected by other views in the program.

A view will often consist of other object packages and class packages. For example, a view will usually contain a data dictionary object structure. Each DDO defined in the structure will need a data-dictionary class and those classes are included in the view component with the use statement. In addition views will often need several object packages for lookup lists, and an object package for confirmations.

Views can be coded and tested in an object package file. The conventional file extension for view object packages is .vw.

Once a view is completed, it may be added to a program through a simple selection process within the Studio.  Even if you were coding this manually, this only requires a few lines of code in a main program. This, along with a view's independence, makes it quite easy to add and remove views from a program.

The following sample shows a windows application main program. This program consists of a main menu and a series of use commands that includes the required views. Notice that the entire program is quite small.

Use DfAllEnt.pkg

Use dfPanel.pkg

Use DfAClnt.pkg

Use cHtmlHelp.pkg

 

Object oHtmlHelp is a cHtmlHelp

End_Object

 

Object oApplication is a cApplication

    Set psCompany to "Data Access Worldwide"

    Set psProduct to "DataFlex Examples"

    Set psVersion to "12.0"

    Set psProgram to "Order"

    Set psHelpFile to "Examples.chm"

    Set peHelpType to htHtmlHelp

End_Object    // oApplication

 

Object oMain is a Panel

    Set Label to "Order Entry Sample Application"

    Set Location to 2 35

    Set Size to 127 209

 

    DFCreate_Menu Main_Menu

        #Include File_PM.inc

        

        DFCreate_Menu "&View" ViewPopupMenu is a ViewPopupMenu

            On_Item "&Customer Entry View \aCtrl+1"                  Send Activate_oCustomerView

            On_Item "&Inventory Item View \aCtrl+2"                  Send Activate_oInventoryView

            On_Item "&Order Entry \aCtrl+3"                          Send Activate_oOrderEntryView

            On_Item "&Sales Person Entry View \aCtrl+4"              Send Activate_oSalesPersonView

            On_Item "&Vendor Entry View \aCtrl+5"                    Send Activate_oVendorView

        End_Pull_Down

 

        Set Status_Help to "Available Views"

        DFCreate_Menu "&Report" ReportPopupMenu is a ViewPopupMenu

            On_Item "&Basic Report - Customer List \aCtrl+6"        Send Activate_oCustomerListBR

            On_Item "&WinPrint - Customer List"                     Send Activate_oCustomerListWP

            On_Item "&WinPrint - Items per Order"                   Send Activate_oItemsPerOrderWP

            On_Item "&WinPrint - Orders"                            Send Activate_oOrdersWP

            On_Item "&WinPrint - Orders by Customer"                Send Activate_oOrdersByCustomerWP

        End_Pull_Down

 

        Set Status_Help to "Available Reports"

        #Include Navi_PM.inc

        #Include Win_PM.inc

        #Include HelpA_PM.inc

 

    End_Menu

 

    Use OrderToolbar.pkg  //  Tool-Bar object.

 

    Object oClientArea is a AppClientArea

        Use Customer.vw

        Use Invt.vw

        Use Order.vw

        Use SalesP.vw

        Use Vendor.vw

        

        Use Basic\CustomerListBR.rv

        Use WinPrint\CustomerListWP.rv

        Use WinPrint\ItemsPerOrderWP.rv

        Use WinPrint\OrdersWP.rv

        Use WinPrint\OrdersByCustomerWP.rv

 

        On_Key Key_Ctrl+Key_1 Send Activate_oCustomerView

        On_Key Key_Ctrl+Key_2 Send Activate_oInventoryView

        On_Key Key_Ctrl+Key_3 Send Activate_oOrderEntryView

        On_Key Key_Ctrl+Key_4 Send Activate_oSalesPersonView

        On_Key Key_Ctrl+Key_5 Send Activate_oVendorView

        On_Key Key_Ctrl+Key_6 Send Activate_oCustomerListBR

 

    End_Object

 

    Use DefaultStatusbar.pkg  //  Status-Bar object.

    Use DfAbout.pkg

 

    Object oAbout is An AboutDialog

        Set ProductName to "Order Sample Application"

        Set Copyright   to "Copyright: 2006 Data Access Corporation"

        Set Author      to "Author: Data Access Worldwide"

    End_Object

 

    Procedure Activate_About

        Send Popup_Modal of oAbout

    End_Procedure

 

End_Object

 

// open Order Entry view on application startup

Send Activate_oOrderEntryView of (oClientArea(oMain))

 

Start_UI

 

Next Topic

Creating a View