*FormLib*

Back to the start
Back to the libraries overview


Overview (FormLib)
AddContextMenu
ChangeFont
FullScreen
MinimizeBox
New1 (FormLib)
RemoveContextMenu
SetFontStyle

Overview (Context Menu)
AddItem (Context Menu)
Click Event (Context Menu)
Count (Context Menu)
New1 (Context Menu)
RemoveItem (Context Menu)
SelectedIndex (Context Menu)
SelectedText (Context Menu)
Value (Context Menu)


Overview (FormLib) Top

FormLib library adds support for full screen applications, handles screen rotation, sets or removes the minimize button, allows changing fonts and fonts styles and adds support for context menus.

Example:
'First add an object named flb of type FormLib.

Sub Globals
End Sub

Sub App_Start
Form1.show
flb.New1("Form1",B4PObject(1))
flb.FullScreen(cPPC) 'On the device it will remove the title bar too
End Sub

Sub flb_Resize 'Fires when the user changes the screen orientation
if Form1.Width > Form1.Height then
msgbox("Landscape")
else
msgbox("Portrait")
end if
End Sub


AddContextMenu Top

Adds a context menu to the specified control.
Syntax: AddContextMenu (ControlName As Control, ContextMenu As ContextMenu)

Example:
'Add a FormLib object named FormLib1 and a ContextMenu object named Context1.

Sub Globals
End Sub

Sub App_Start
Form1.Show
FormLib1.New1("Form1",b4pobject(1))
Context1.New1
Context1.AddItem("Yes")
Context1.AddItem("No")
Context1.AddItem("-") 'Adds a separator
Context1.AddItem("Maybe")
FormLib1.AddContextMenu("TextBox1",Context1.Value)
End Sub

Sub Context1_Click
Select Context1.SelectedText
Case "Yes"
'Do something
Case "No"
'Do something
Case "Maybe"
'Do something
End Select
End Sub


ChangeFont Top

Changes the font of the specified control.

Syntax: ChangeFont (ControlName As Control, FontName As String)

You can add fonts to the device by copying a font file to the fonts library: \windows\fonts

Example:

FormLib1.ChangeFont("TextBox1","Courier New")


FullScreen Top

FullScreen method removes the menu bar and the title bar if requested.
Syntax: FullScreen (RemoveTitle As Boolean)
When removing the title bar be sure to provide a way to close the form.


MinimizeBox Top

Gets or sets whether the minimize option is available to the user.
On the device the minimize option replaces the close option.

Syntax: MinimizeBox

It is not recommended to use this property while debugging on the device as the forms will not be closed unless AppClose is used.

Example:

flb.MinimizeBox = True


New1 (FormLib) Top

Initializes the FormLib object.

Syntax: New1 (frm As Form, B4PObject1 As Object)
frm - The form that will be affected by this object.

Example:

flb.New1 ("Form1",B4PObject(1))


RemoveContextMenu Top

Removes the context menu from the specified control

Syntax: RemoveContextMenu (ControlName As Control)

Example:

Context1.RemoveContextMenu ("TextBox1")


SetFontStyle Top

Changes the font style of a control.

Syntax: SetFontStyle (ControlName As Control, Bold As Boolean, UnderLine As Boolean, Italic As Boolean, StrikeOut As Boolean)

Changing the font style of a form will change the font style of strings that are written using Form.DrawString method.

Example:

flb.SetFontStyle ("Button1", true, true, false, false)




Overview (Context Menu) Top

A ContextMenu object is a menu that shows when the user clicks with the right button on a control (desktop) or when a user taps and holds the pen over a control (device).
The menu is added to a specific control using a FormLib object.
One menu can be used by more than one control.
The context menu exposes one event, the Click event.
Using SelectedText or SelectedIndex properties you can find out which menu item was
clicked.
Note that on the desktop a context menu will appear on the chosen control and all its
child controls.

For example, if you add a context menu to a form it will show when you right click on
any control on the form.
On the device it will show only when you tap and hold on the form itself.

Example:

'Add a FormLib object named FormLib1 and a ContextMenu object named
Context1.

Sub Globals
End Sub

Sub App_Start
Form1.Show
FormLib1.New1("Form1",b4pobject(1))
Context1.New1
Context1.AddItem("Yes")
Context1.AddItem("No")
Context1.AddItem("-") 'Adds a separator
Context1.AddItem("Maybe")
FormLib1.AddContextMenu("TextBox1",Context1.Value)
End Sub

Sub Context1_Click
Select Context1.SelectedText
Case "Yes"
'Do something
Case "No"
'Do something
Case "Maybe"
'Do something
End Select
End Sub


AddItem (Context Menu) Top

Adds a menu item to the context menu object.

Syntax: AddItem (Text As String)

To add a separator to the menu set the Text to "-".


Click Event (Context Menu) Top

Occurs when the user clicks on an item in the context menu object.

Syntax: Click

Use SelectedText or SelectedIndex to find the specific item that was clicked.

Example:

Sub App_Start
Form1.Show
FormLib1.New1("Form1",b4pobject(1))
Context1.New1
Context1.AddItem("Yes")
Context1.AddItem("No")
Context1.AddItem("-") 'Adds a separator
Context1.AddItem("Maybe")
FormLib1.AddContextMenu("TextBox1",Context1.Value)
End Sub

Sub Context1_Click
Select Context1.SelectedText
Case "Yes"
'Do something
Case "No"
'Do something
Case "Maybe"
'Do something
End Select
End Sub


Count (Context Menu) Top

Returns the number of menu items in the context menu object.

Syntax: Count


New1 (Context Menu) Top

Initializes a context menu object.

Syntax: New1


RemoveItem (Context Menu) Top

Removes a menu item from the context menu object.

Syntax: RemoveItem (Index As Int32)


SelectedIndex (Context Menu) Top

Returns the index of the clicked menu item.

Syntax: SelectedIndex


SelectedText (Context Menu) Top

Returns the text of the clicked item.

Syntax: SelectedText


Value (Context Menu) Top

Gets a reference to the actual context menu.

Syntax: Valu