How to make Attachmate IBM Reflection 2014 Terminal Visible using external Application?

1.5k Views Asked by At

I am writing a external application for Attachmate's Reflection for IBM 2014, In that application I am trying to create relfection application with exisiting session file. The application is getting created successfully but its not visible to user, I tried several way to do that but had no luck yet.

If anybody has done this or know what needs to be done to make terminal visible please reply.

Following is piece of code that I am using to do so,

using Attachmate.Reflection;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.Emulation.IbmHosts;
using Attachmate.Reflection.UserControl.IbmHosts;
using Attachmate.Reflection.UserInterface;

Application reflectionApplication;
reflectionApplication = MyReflection.CreateApplication("app", true);
IIbmTerminal terminal =(IIbmTerminal)reflectionApplication.CreateControl(@"C:\mypath\test.rd3x");

reflectionApplication = MyReflection.ActiveApplication;
IFrame frame = (IFrame) reflectionApplication.GetObject("Frame");
frame.Visible = true;
1

There are 1 best solutions below

0
Hambone On

The best way to do this is to leverage an existing session file (that you would normally load within Reflection). This way you don't have to worry about hostname, port via code.

Here is a boilerplate for this, which I have successfully been using.

Attachmate.Reflection.Framework.Application reflectionApplication = null;

reflectionApplication = MyReflection.CreateApplication("myWorkspace", true);
if (reflectionApplication != null)
{
    IIbmTerminal terminal = (IIbmTerminal)reflectionApplication.CreateControl(
        @"C:\ProgramData\Attachmate\Reflection\<your session file>.rd3x");
    if (terminal != null)
    {
        terminal.Connect();
        //You can also use AfterConnect event to wait for the connection.
        while (!terminal.IsConnected)
        {
            System.Threading.Thread.Sleep(500);
        }

        IView sessionView;
        IFrame theFrame = (IFrame)reflectionApplication.GetObject("Frame");
        sessionView = theFrame.CreateView(terminal);

        IIbmScreen screen = terminal.Screen;
        screen.WaitForHostSettle(6000, 3000);
    }
    else
        Console.WriteLine("Can not create the control.");
}
else
    Console.WriteLine("Failed to get Application object.");