Show Contents / Index / Search

Get a View and its Session Using Title Text

This sample program gets both the View object and the embedded Control object for a session by referencing the title text of the View. For a list of methods by which you can identify View objects, see Terminal and View Objects.

To create a view using its title text

  1. Start Reflection 2008.
  2. Create a session document, name it test , and connect it to the host.
  3. In Visual Studio, create a new Console Application project.
  4. In the New Project dialog box, type Get View and Session in the Name box.
  5. Select the Create directory for solution box, click Browse to select your API projects folder (for example, C:\MyProjects), and then click OK.
  6. In Solution Explorer, add the class assemblies. (For instructions, see Create an API Project.)
  7. Copy the code from one of the following programs:

    Get View and Session (IBM)

    Get View and Session (OpenSystems)

  8. In Visual Studio, paste the code to the Program.cs tab, replacing all existing code.
  9. In the code, find the following line:

    sessionView=theFrame.GetViewByTitleText("");

  10. In the quotation marks, type the filename and extension of the session document that you created in step 2 (for example, test.rdox), making sure to match the letter case.
  11. Build the application (Build > Rebuild Solution) and then run it (Debug > Start Without Debugging).

    A Windows console box appears with a line of text extracted from the host screen, and the following text: "The session is connected to: the_host_address" and "Press any key to continue….."

  12. To terminate the application, press any key.