The Big Red Toolbox

MGCENet

Tools for the Net: HTML and IP Addresses

October 24, 1999

© NSB Corporation. All rights reserved.


MGCENet - Windows CE Custom Control Objects
Written by Mark Gamber, October 1999

NS Basic is (c) NS Basic Corporation
Windows CE is (c) Microsoft Corporation

MGCENet provides two separate controls for Windows CE applications capable of making use of COM oriented controls such as NS Basic. Included in this package are:

Installation

Connect your Windows CE device to your desktop using ActiveSync. On the desktop, run the program MGCENet.exe. Follow the instructions on the screen to complete the installation. Both controls will be installed and registered automatically.


IP Address Control

The IP Address control makes it easy to display and obtain an IP address from a user by providing the interface used in several other components, such as dial-up network setup, ethernet setup and so on. The IP Address control supports the following properties, methods and events:

Object Creation

addobject "MGCENet.IPAddress", "IPAddr", 10, 10, 140, 20

Samples

Properties

Value Value sets and retrieves the current contents of the IP Address as a text string. Partial addresses may be specified as well as full four byte addresses.

IPAddr.Value = "192.168.0.1"
ip = IPAddr.Value

Border TRUE (non-zero) enables a border around the control (the default). FALSE (zero) removes the control border.

IPAddr.Border = TRUE
iBorder = IPAddr.Border

Enabled TRUE (non-zero) enables the control, FALSE (zero) disables the control. The default is TRUE.

IPAddr.Enabled = TRUE
iIsEnabled = IPAddr.Enabled

BackColor Set and retrieve the control background color RGB value. The default value is White (16777215).

IPAddr.BackColor = (255 * 65536 ) + ( 255 * 256 )
nBackColor = IPAddr.BackColor

ForeColor Set and retrieve the control text color, including the dots between numbers. The default value is Black (0)

IPAddr.ForeColor = 0
nForeColor = IPAddr.ForeColor

FontName Set and retrieve the name of the font used by the control. The default is "Arial"

IPAddr.FontName = "Courier New"
sFont = IPAddr.FontName

FontSize Set and retrieve the size of the font used by the control. The default value is 14.

IPAddr.FontSize = 12
iFontSize = IPAddr.FontSize

FontBold TRUE (non-zero) causes the control to display text using a bold font. FALSE (zero) sets it to use a non-bold font. The default is FALSE.

IPAddr.FontBold = TRUE
bBold = IPAddr.FontBold

Tabstop TRUE (non-zero) allows you to Tab to the control. FALSE (zero) prevents Tab from reaching the control. The default value is TRUE.

IPAddr.Tabstop = TRUE
iTab = IPAddr.Tabstop

Version Returns the version number of the control as an integer.

Methods

Show Call this method to make the control visible.

IPAddr.Show

Hide Call the Hide method to make the control invisible.

IPAddr.Hide

SetFocus SetFocus sets the input focus to the first number in the control.

IPAddr.SetFocus

Events

The IP Address control supports no events.

HTML Control

The HTML control allows the addition of the Windows HTML viewer to your program. The HTML control accepts HTML formatted text from literal strings or files and triggers an event when a hyperlink has been clicked upon, sending along the link text and any related data, such as from a form. The HTML is not a browser control, it has no concept of TCP/IP or the Internet, it simply displays the HTML you stream into it. That HTML can, of course, come from the internet via a TCP/IP or Winsock control.

Object Creation

addobject "MGCENet.HTML","HTML",10,24,OUTPUT.Width-20,OUTPUT.Height-26

Samples

Properties

Border Set Border to TRUE (non-zero) to display a border around the control or FALSE (zero) to remove the border. The default value is TRUE.

HTML.Border = TRUE
bBorder = HTML.Border

ForceFit Set and retrieve the ForceFit flag. When set to TRUE, images are forced to to fit within the display area of the control. Set to FALSE to allow the images to display using their normal size regardless of the control size. The default value is FALSE.

HTML.ForceFit = FALSE
Forced = HTML.ForceFit

Style Set and retrieve the Style property which determines how the edge of the control is displayed. This is different from the Border property. Styles include:
  • 0: No edge
  • 1: "Sunken" edge
  • 2: "Raised" edge
HTML.Style = 2
iStyle = HTML.Style
Tabstop TRUE (non-zero) allows you to Tab to the control. FALSE (zero) prevents Tab from reaching the control. The default value is TRUE.

HTML.Tabstop = TRUE
iTab = HTML.Tabstop

Version Returns the version number of the control as an integer.

Methods

Clear Remove all data from the HTML control by calling Clear.

HTML.Clear

Copy The Copy method causes all selected text to copy to the clipboard.

HTML.Copy

Show Call the Show method to make the control visible.

HTML.Show

Hide Call the Hide method to make the control invisible.

HTML.Hide

SetText The SetText method clears the contents of the control and adds a specified HTML formatted text string.

HTML.SetText = "<font size=3><b><center>Fission Boosting</center>"
AddText AddText appends text to the control, adding it to existing data within the control.

HTML.AddText = "Your string here"
SetTextFromFile SetTextFromFile clears the control and adds new HTML formatted text from a specified ASCII file.

HTML.SetTextFromFile "html1.dat"

AddTextFromFile This method adds HTML formatted text read from a specified ASCII file but does not clear the control. The text is appended to exist data.

HTML.AddTextFromFile "tinium.txt"

ToAnchor An "anchor" is an HTML tag which identifies a section of the text. You may create hyperlinks to the anchor and, upon receiving a click event from the control you may jump to that section by calling the ToAnchor method.

HTML: <a href='#anchor1'>To Anchor #1</a>

Basic: HTML.ToAnchor "anchor"

TextDone Call this method when you are done adding text to the control until the next time Clear, SetText or SetTextFromFile are used. This causes the control to do "clean up" work, fixing any errors in HTML and finishing rendering, such as with images and tables.

HTML.TextDone

SelectAll SelectAll does just that, selects all text in the HTML control.

HTML.SelectAll

SetFocus Call this method to set the input focus to the HTML control.

HTML.SetFocus

Events

Click The click event is triggered when a hyperlink is selected or a form is submitted. Two parameters are passed to the event handler, Text and Data. The text parameter ismost commly used and contains the hyperlink text or the ACTION text from a form. In addition, a form using "METHOD=GET" will cause the field names and data to be appended to the action text. For example, "formtext?Field1= Yes&Field2=My+Name&Field3=Yes". When a form using "METHOD=POST" is submitted, only the action text is sent as the Text parameter. The field names and data of a "METHOD=POST" type form is passed as the Data parameter. Using the first example, Text would contain "formtext" and Data would contain "?Field1=Yes& Field2=My+Name&Field3=Yes".

sub HTML_Click( Text, Data )
MsgBox "Text is " & Text, vbOKOnly, "Hyperlink"
end sub


Change Log

10/23/99: Added Copy method to HTML object.