Overview
 Top Next

The Door library is a special library.
It allows you to access .Net objects, methods and properties from Basic4ppc code without creating new libraries.
It won't replace any existing library but rather make these libraries and Basic4ppc itself more complete.
For example you can use this library to access all the properties of a control (on the desktop or device) and not only the subset supported by Basic4ppc.

You should have some knowledge with the .Net Framework if you want to fully exploit this library.

There are three types of objects in the Door library.
Object - The main data type which holds the value of a specific .Net object.
ObjectArray - An array of objects. It is mostly used to pass arguments to methods or constructors.
Event - Represents an event and allows adding events to objects.
The following types of events arguments are supported:
- EventHandler
- KeyEventHandler
- KeyPressEventHandler
- MouseEventHandler
- PaintEventHandler

Examples:
Change the Form's KeyPreview property to true - All keystrokes will be first handled by Form_KeyPress event.
Form1 is a regular Form, ofrm is an Object
Sub App_Start
    Form1.Show
    ofrm.New1(false)
    ofrm.FromControl("Form1")
    ofrm.SetProperty("KeyPreview",true)
End Sub

Desktop only: Change the icon of a specific form.
Form1 is a regular Form, ofrm and oIcon are Objects, args is an ObjectArray.
Sub App_Start
    Form1.Show
    ofrm.New1(false)
    oIcon.New1(false)
    ChangeIcon("Form1",AppPath & "\SomeIcon.ico")
    'ChangeIcon("Form2",AppPath & "\AnotherIcon.ico")
End Sub

Sub ChangeIcon (FormName, IconFile)
    ofrm.FromControl(FormName)
    args.New1(1)
    args.SetValue(0,IconFile,"System.String")
    oIcon.CreateNew2("System.Drawing.Icon" & oIcon.System_Drawing, args.Value)
    ofrm.SetProperty2("Icon",oIcon.Value)
End Sub

Set the WebRequest Referer header's value.
WebRequest1 is a WebRequest object (HTTP library), obj is an Object.
Sub App_Start
    WebRequest1.New1("http://www.basic4ppc.com")
    obj.New1(false)
    obj.FromLibrary("Main.WebRequest1","req",B4PObject(2))
    obj.SetProperty("Referer","http://xxx.xxx.xx")
    'Msgbox(obj.GetProperty("Referer"))
End Sub


Passing color value.
Sub App_Start
    Form1.Show
    clr.New1(false)
    txt.New1(false)
    txt.FromControl("textbox1")
    clr.CreateNew("System.Drawing.Color" & clr.System_Drawing)
  txt.SetProperty2("BackColor",clr.RunMethod2("FromArgb",cRed,"System.Int32")) 'Use Color.FromArgb(Int32) to pass the color
End Sub

Events examples:
Handle the TextChanged event (fires whenever the text changes).
'obj is an Object, TextBox1ChangedEvent is an Event.
Sub App_Start
    Form1.Show
    obj.New1(false)
    obj.FromControl("textbox1")
    TextBox1ChangedEvent.New1( obj.Value,"TextChanged")
End Sub

Sub TextBox1ChangedEvent_NewEvent
    form1.Text = textbox1.Text
End Sub

Show which mouse button was pressed.
'obj and o are Objects, MouseDownEvent is an Event.
Sub App_Start
    Form1.Show
    obj.New1(false)
    o.New1(false)
    obj.FromControl("form1")
    MouseDownEvent.New1( obj.Value,"MouseDown")
End Sub

Sub MouseDownEvent_NewEvent
    o.Value = MouseDownEvent.Data 'Get the event's data.
    form1.Text = o.GetProperty("Button") 'Returns Left, Middle or Right
End Sub