Shape - The shape of the shape (!). stRectangle, stSquare,
stRoundRect, stRoundSquare, stEllipse, stCircle
Brush.Style - The fill style of the shape. bsSolid, bsClear
Brush.Color - The fill colour of the shape
Pen.Color - The outline colour of the shape
Pen.Width - The outline width of the shape
TTrackBar
---------
Properties:
Min - The minimum value of the track bar
Max - The maximum value of the track bar
Position - The track bar's position
Orientation - trHorizontal, trVertical
TProgressBar
------------
Properties:
Min - The minimum value of the progress bar
Max - The maximum value of the progress bar
Position - The progress bar's position
TTabControl (tabbed notebook)
-----------------------------
Properties:
Tabs - TStringList containing all the tabs in the tabbed
notebook
TabIndex - The number of the currently selected tab. -1 means
no tab selected, 0 means the first tab is selected,
1 the second, etc.
For information on how to use the TStringList object, see the "Non-visual
controls" section.
TOfficeButton (Office 97-style toolbar button)
----------------------------------------------
NOTE: TOFFICEBUTTON IS NOW DEFUNCT, AND SHOULD NOT BE USED. USE
TTOOLBARBUTTON97 INSTEAD.
Properties:
Caption - The caption on the button
Bitmap - The bitmap on the button (a TBitmap object)
NoFocusBitmap - The bitmap on the button when it is not selected
UnselectedColor - The colour of the caption when it is not selected
Layout - Where the bitmap is placed, relative to the caption.
blBitmapLeft, blBitmapTop, blBitmapRight, or
blBitmapBottom
Events:
OnClick - Fired when the button is pressed.
TToolbarButton97 (Office 97-style button)
-----------------------------------------
The properties of TToolbarButton97 are identical to those of TBitBtn, except
that the button is displayed with a different style.
TToolbarSep97 (button separator)
--------------------------------
This control has no properties, apart from Left, Top, Width and Height. Just
create it, set its size, and that's it.
TEdit97 (Office 97-style edit control)
--------------------------------------
This control is identical to TEdit, except that the edit box is displayed with
a different style.
Non-visual controls
===================
TStringList (string list object)
--------------------------------
The TStringList is a very powerful object. It can store a list of strings,
which can be saved to and from disk, sorted, and manipulated in a powerful
manner, rather like a sophisticated string array. TStringList objects are
used internally by TListBox, TComboBox, TTabControl etc. to maintain their
list of items. Strings start at index 0. TStringList objects grow and shrink
automatically to store all the strings.
Properties:
Count - The number of strings in the list
Methods:
GetString(i) - Gets the string at index i
SetString i text - Sets the string at index i to text
Add(text) - Adds a string, returns the index
Delete i - Deletes the string at index i, moves the others up by one
Clear - Clears the string list
Exchange i j - Exchanges the string at position i with the string at position j
SaveToFile file - Saves the string list to file
LoadFromFile file - Loads the string list from file
SaveToSet() - Converts the string list to a set (e.g. [one,two,three]) and returns the set
LoadFromSet set - Clears the string list and adds each element in the set to the string list
SaveToAlias alias - Overwrites alias's script code with the contents of the string list (alias MUST ALREADY EXIST!!)
LoadFromAlias alias - Clears the string list and loads the script code from alias into the list
SaveToEvent event - Overwrites event's script code with the contents of the string list (event MUST ALREADY EXIST!!)
LoadFromEvent event - Clears the string list and loads the script code from event into the list
GetDirList mask - Clears the string list and fills it with a list of directories whose names match mask. For example, mask could be set to c:\windows\*.* to return a list of directories in c:\windows, or it could simply be left as *.*.
GetFileList mask - Clears the string list and fills it with a list of files whose names match mask. See above (the GetDirList method) for more information.
Execute - Executes the strings in the list as ViRCScript code
Sort - Alphabetically sorts the strings in the string list
Note that the Sort method DOES NOT WORK for TStringList objects that are
properties of other controls (e.g. a TListBox's Items property). For these,
call the Sort method of the object (e.g. ListBox1.Sort), rather than of the
TStringList (e.g. do NOT do ListBox1.Items.Sort).
TBitmap (in-memory bitmap)
--------------------------
The TBitmap object represents a bitmap. The object has only one method.
Methods:
LoadFromFile filename.bmp - Reads the BMP file specified and loads it
into the TBitmap object.
After a bitmap has been loaded into a TBitmap object, the object can be
assigned to a TBitBtn's Glyph property, or a TOfficeButton's Bitmap or
NoFocusBitmap properties.
TIcon (in-memory icon)
----------------------
The TIcon object represents a window icon. The object has only one method.
Methods:
LoadFromFile filename.ico - Reads the ICO file specified and loads it
into the TIcon object.
After an icon has been loaded into a TIcon object, the object can be
assigned to a TForm's Icon property to make that icon the form's icon.
TSockets (Winsock socket control)
---------------------------------
ViRC '96 0.82 and above support a TSockets class, whose interface is similar
to the freeware Sockv3 Delphi control. Anyone who has used this will feel
instantly familiar!!
In versions before 0.91b, TSockets objects required an owner, which basically
meant that a TSockets object could only be made with a parent form. Now, this
is no longer true, and TSockets objects can be created freely without owners
(you can now do $new(TSockets), for example).
Properties:
IPAddr - The host name or IP address of where to connect to
Port - The port to connect to or listen on
LocalHost - The host name of the local machine
LocalIPAddr - The IP address of the local machine
RemoteIPAddr - The IP address of the remote machine the socket is
connected to, or about to accept an incoming
connection from
SocketNumber - Returns the socket number of the current connection.
If the socket is used to handle multiple incoming
connections, you should store the value of
SocketNumber for each connection in a TStringList in
the OnSessionAvailable event, and switch to the
required connection with the SetActiveConnection
method.
Methods:
SConnect - Connects to IPAddr:Port
SListen - Listens for connections on Port
SListenOnFreePort() - Finds an unused port and listens on it.
Returns the port that has been selected for
listening on.
SAccept() - Accepts an incoming connection. Returns the
unique socket number of the connection. Keep
this value if you're handling multiple
connections on one port, otherwise discard it
by calling this method as a statement.
SCancelListen - Cancels a previous SListen command
Send text - Sends text to the remote end
SendCRLF text - Sends text plus a CRLF to the remote end
SetActiveConnection(n) - When the socket is used to handle multiple
simultaneous incoming connections (for
example, for a chat server to handle multiple
users on the same port), this method will set
the active connection to n. Any further
socket operation, such as Send, will work on
that connection.
Events:
OnSessionConnected - Called after SConnect when session connects
OnSessionAvailable - Called after SListen when an incoming connection arrives
OnSessionClosed - Called when the remote end closes the connection
OnDataAvailable - Called when data, sent by the remote end, is available for reception
OnErrorOccurred - Called when a socket error occurs
$Msg = socket error message, $Error = socket
error number
Connecting somewhere
--------------------
To connect somewhere, first create the socket, ownedby a form (this is VERY
important, the socket WILL NOT WORK if it is not owned by anything). Then set
the IPAddr property to the name or IP of the host you wish to connect to, and
set Port to the port. Then call the SConnect method. Example:
@ $socketform = $new(TForm)
@ $socket = $new(TSockets ownedby $socketform)
@p $socket.IPAddr = post.demon.co.uk
@p $socket.Port = 25
$socket.SConnect
Listening for connections
-------------------------
Virtually identical to the above, except that IPAddr isn't specified and you
call SListen instead of SConnect. For example, to listen for incoming
connections on port 1234, do:
@ $socketform = $new(TForm)
@ $socket = $new(TSockets ownedby $socketform)
@p $socket.Port = 1234
$socket.SListen
To listen on a free port, assigning the port number selected to $sockport:
@ $sockport = $socket.SListenOnFreePort()
If you don't care what port the socket has chosen for listening on, you can
call it, like any method, as a statement:
$socket.SListenOnFreePort
The port chosen can then be retrieved later by reading the Port property.
Accepting incoming connections
------------------------------
When you are listening and an incoming connection comes in, the
OnSessionAvailable event is fired. You can then use the SAccept method to
accept the connection. Example:
@p $socket.OnSessionAvailable = SOCKET_INCOMING
Alias SOCKET_INCOMING
$socket.SAccept
EndAlias
When the remote end connects
----------------------------
After you have issued the SConnect call, V97 tries to connect with the remote
host. When a connection is established, the OnSessionConnected event is fired.
You must not send data to the socket before this event is fired!! Example:
@p $socket.OnSessionConnected = SOCKET_CONNECTED
Alias SOCKET_CONNECTED
TextOut > . clBlue *** We're connected!!
EndAlias
Socket errors
-------------
If the socket fails, either while attempting to connect or during data transfer
and so forth, the OnErrorOccurred event is fired:
@p $socket.OnErrorOccurred = SOCKET_ERROR
Alias SOCKET_ERROR
TextOut > . clRed *** Error occurred while using socket!!
EndAlias
In your SOCKET_ERROR handler, the local variables $Msg, containing the socket
error message, and $Error, containing the socket error number, are available.
Note that "Connection reset by peer" (which occurs when a client closes a
connection with a server) is treated as an error. By default, all errors will
shut V97 down (I will endeavour to change this behaviour in future releases).
Therefore it is STRONGLY recommended that, at the least (if you don't want to
do any actual error-handling), you have the following statement in:
@p $socket.OnErrorOccurred = Nop
NOP simply does nothing - this ensures that your application will continue
whenever a socket error occurs.
In an OnErrorOccurred handler, you may want to call SClose to close the socket,
otherwise it will remain open, even though an error had occurred.
Sending data
------------
Data is sent with the SEND or SENDCRLF methods, which are identical except for
that fact that SENDCRLF sends a CRLF at the end of the line, whereas SEND does
not. Usually, you will use SENDCRLF. Example, which sends the string "Hello!!"
after connecting to the host:
@p $socket.OnSessionConnected = SOCKET_CONNECTED
Alias SOCKET_CONNECTED
$socket.SendCRLF Hello!!
EndAlias
Receiving data
--------------
When data is received on the socket, the OnDataAvailable event is fired. You
can receive the data by reading the socket's Text property. Note that reading
the Text property REMOVES THE DATA FROM THE SOCKET'S QUEUE. RETRIEVING ITS
VALUE AGAIN WILL CAUSE AN ERROR!! Therefore, assign the value of the Text
property to a variable at the beginning of the event code, and only reference
that variable. Example, which sends "Good morning!!" back whenever "Hello!!"
is received:
@p $socket.OnDataAvailable = SOCKET_DATA
Alias SOCKET_DATA
@ $data = $prop($socket.Text)
if ([$data] == [Hello!!])
$socket.SendCRLF Good morning!!
endif
EndAlias
Closing the connection
----------------------
The socket connection can be closed with the SClose method, for example, this
closes the connection when QUIT is received:
@p $socket.OnDataAvailable = SOCKET_DATA
Alias SOCKET_DATA
@ $data = $prop($socket.Text)
if ([$data] == [QUIT])
$socket.SClose
endif
EndAlias
When the REMOTE END closes the connection, the OnSessionClosed event is fired.
You must close the local end of the socket with SClose when this event is
fired. You could do something like this:
@p $socket.OnSessionClosed = $socket.SClose
Similarly, in an OnErrorOccurred handler, you may want to call SClose to close
the socket, otherwise it will remain open, even though an error had occurred.
Cancelling listening
--------------------
If you're listening on a port and wish to cancel listening, call the
SCancelListen method. This listens on port 1234 and cancels listening when
an incoming connection appears:
@p $socket.Port = 1234
@p $socket.OnSessionAvailable = SOCKET_AVAILABLE
$socket.SListen
Alias SOCKET_AVAILABLE
$socket.SAccept
TextOut > . clBlue *** We're connected!!
$socket.SCancelListen
EndAlias
Handling multiple incoming connections on the same port