Basic4ppc libraries reference

◄   Previous page         Table of Contents          Next page 

Basic4ppc  Home  |  Forum

 

Internal vs. External controls

 

Using a control added from a library ("External control") is different than using a control internally included in Basic4ppc ("internal control"). There are some minor differences you should be aware of:

 

1. With internal controls, when you pass a control to a Sub in an external library, that needs a control as a parameter, you specify the controls name. For example (see full example below):

 

     tvMain.New1("Form1", 0, 0, 200, 200)

 

When working with controls added from a library, Basic4ppc compiler will not recognize the name you gave the control when you added it. When pssing such controls as parameters, use the ControlRef property found in (almost) every control. This property references the control itself in a way that allows external method to take it as a paremeter. Consider this property as a link between Basic4ppc and objects imported from outside world, ad in the following example:

 

1  Sub App_Start

2      tvMain.New1("Form1", 100, 100, 200, 200)

3      tvMain.AddNewNode("first node")

4      tvMain.AddNewNode("second node")

5      AddObject("TabControl1", "TabControl")

6      TabControl1.New1("Form1", 0, 0, 200, 200)

7      TabControl1.AddTabPage("first page")

8      TabControl1.AddControl(tvMain.ControlRef, 0, 0, 0)

9      Form1.Show

10 End Sub

 

 

Note, that after adding a TabControl in line 5, we add it to a form called Form1 using the New1 constructor. Form1 is an internal control and can be passed as a parameter to the external control literally, using its name. But both tvMain (that was added using the Tools menu) and TabControl1 are an external controls. If we wish to add the TreeView tvMain to our TabControl (TabControl1), we cannot pass the literal string "tvMain" as a parameter to the AddControl method. Instead, we use the ControlRef property.

 

2. External controls cannot be visually added to the designer, hence their properties must be programmatically set.

 

Go to the next page to learn about common error messages you may encounter...

Basic4ppc libraries reference

◄   Previous page         Table of Contents          Next page 

Basic4ppc  Home  |  Forum