Theater SDK Banner 

Art
[Previous][Next]

Simple Administration Application

This application uses all of the View controls on one form. It adds three title servers named TitleServer1, TitleServer2, and TitleServer3 to the ServerView control. Information about the server currently selected in ServerView is dynamically displayed in the TitleView, ClientView, and TraceView controls.

Form Layout

From the Visual Basic toolbox, select and size the ServerView, ClientView, TitleView and TraceView controls onto a form. Your form must look similar to the following.

Initializing the Controls

Add the following code to the Form_Load event to add the title servers to the ServerView control, and to set the other controls to display data about the first server in the list. Save the name of the first server in the list so you can check to see when it changes.

Dim strSelectedServer As String

Private Sub Form_Load()
 ' Add servers to ServerView tree
 ServerView1.AddServer ("TitleServer1")
 ServerView1.AddServer ("TitleServer2")
 ServerView1.AddServer ("TitleServer3")

 ' Save the default server name
 strSelectedServer = "TitleServer1"

 ' Set other view controls to default to the first server
 ClientView1.SetServer (strSelectedServer)
 TitleView1.SetServer (strSelectedServer)
 TraceView1.SetServer (strSelectedServer)
 
End Sub

Selecting a New Server

Each time a new selection is made in the ServerView control, an OnSelectionChange event is triggered. This event can be used to change the data displayed in the other controls if a different server is selected. The following code uses the server name that was saved in the FORM_LOAD procedure to determine if the server has changed:

Private Sub ServerView1_OnSelectionChanged(ByVal Selection As Long, ByVal infotype As NSTAdminCtl.BaseInfoType)

Dim strNewServer As String ' New server selected 
Dim objServer As Object ' Temp object

Set objServer = ServerView1.GetItemObject
strNewServer = objServer.Name

' If the server name has changed,
' set other view controls to new server.
If strNewServer <> strSelectedServer Then
   strSelectedServer = strNewServer
   ClientView1.SetServer (strSelectedServer)
   TitleView1.SetServer (strSelectedServer)
   TraceView1.SetServer (strSelectedServer)
End If

End Sub

Running the Application

Change the name values being passed into the AddServer method to valid title server names. If you connect successfully, your application must look similar to the following:

Note   You can place each control on a tab of a tabbed dialog control, such as the Microsoft® Tabbed Dialog Control.

[Previous][Next]



© 1996-1998 Microsoft Corporation. All rights reserved