Embed Attachmate Extra! X-treme session in Windows Forms App

I am looking to embed Attachmate Extra! X-treme session in a .net Windows Form application. I also need it to be interactive(sending and capturing screen data) with other elements of my application.
Is there specific control which can help me embed the Session screen within my application and interact with the screen data. Any help is greatly appreciated.

Parents Reply Children
  • On the form you want to embed an EXTRA window, place a "GroupBox" control on the form, and remove any caption on the group box. This will become the parent window for EXTRA, and this will allow you to size and place it on the form appropriately, so that you can easily include other buttons or things on the form.

    Use the EXTRA COM API to open an EXTRA session. Use EXTRA's "Sessions.Open" method to do this. The session will open and connect, but will still be invisible.

    Get the handle for the session using the "WindowHandle" property of the EXTRA "_Session" object, and save this in an IntPtr variable.

    Use the Win32 "SetParent" API to cause the group box window on the form to become the parent window for EXTRA.

    After doing this, you will probably want to remove the title bar from the EXTRA window, so it will look more embedded, and not like it just got stuck on the form. To do this, use the Win32 "GetWindowLong" function to get the window style flags for the EXTRA window, turn off the caption-style using the bitwise "not" operator, then use "SetWindowLong" to set the edited window style. It is necessary to use "SetWindowPos" after doing this to make the change take place.

    Finally, make the session visible.

    public partial class Form1 : Form
    private const int WS_CAPTION = 0xC00000;
    private enum SetWindowPosFlags : uint
    AsynchronousWindowPosition = 0x4000,
    DeferErase = 0x2000,
    DrawFrame = 0x0020,
    FrameChanged = 0x0020,
    HideWindow = 0x0080,
    DoNotActivate = 0x0010,
    DoNotCopyBits = 0x0100,
    IgnoreMove = 0x0002,
    DoNotChangeOwnerZOrder = 0x0200,
    DoNotRedraw = 0x0008,
    DoNotReposition = 0x0200,
    DoNotSendChangingEvent = 0x0400,
    IgnoreResize = 0x0001,
    IgnoreZOrder = 0x0004,
    ShowWindow = 0x0040
    private enum WindowLongFlags : int
    GWL_EXSTYLE = -20,
    GWL_ID = -12,
    GWL_STYLE = -16,
    GWL_USERDATA = -21,
    GWL_WNDPROC = -4,
    DWLP_USER = 0x8,
    DWLP_DLGPROC = 0x4

    [DllImport("user32.dll", SetLastError=true)]
    static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    [DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    [return: MarshalAs(UnmanagedType.Bool)]
    static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, SetWindowPosFlags uFlags);

    public Form1()

    private void Form1_Load(object sender, EventArgs e)
    IntPtr hGroupbox1 = this.groupBox1.Handle;

    EXTRA.ExtraSessions sessions = new ExtraSessions();
    EXTRA._Session sess1 = (_Session)sessions.Open("Session1.edp");

    IntPtr hSess1 = (IntPtr)sess1.WindowHandle;
    SetParent(hSess1, hGroupbox1);
    int getlongval = GetWindowLong(hSess1, (int)WindowLongFlags.GWL_STYLE);
    getlongval = getlongval