Highlighted
Anonymous_User Absent Member.
Absent Member.
6297 views

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.

Thanks
Amit
0 Likes
3 Replies
AutomaticReply Absent Member.
Absent Member.

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

apateldelta,

It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.

These forums are peer-to-peer, best effort, volunteer run and that if your issue
is urgent or not getting a response, you might try one of the following options:

- Visit https://www.microfocus.com/support-and-services and search the knowledgebase and/or check
all the other self support options and support programs available.
- Open a service request: https://www.microfocus.com/support
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.microfocus.com)
- You might consider hiring a local partner to assist you.
https://www.partnernetprogram.com/partnerfinder/find.html

Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.microfocus.com/faq.php

Sometimes this automatic posting will alert someone that can respond.

If this is a reply to a duplicate posting or otherwise posted in error, please
ignore and accept our apologies and rest assured we will issue a stern reprimand
to our posting bot.

Good luck!

Your Micro Focus Forums Team
http://forums.microfocus.com



0 Likes
vfast Absent Member.
Absent Member.

Re: Embed Attachmate Extra! X-treme session in Windows Forms

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,
GWLP_HINSTANCE = -6,
GWLP_HWNDPARENT = -8,
GWL_ID = -12,
GWL_STYLE = -16,
GWL_USERDATA = -21,
GWL_WNDPROC = -4,
DWLP_USER = 0x8,
DWLP_MSGRESULT = 0x0,
DWLP_DLGPROC = 0x4
}

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

public Form1()
{
InitializeComponent();
}

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 & ~WS_CAPTION;
SetWindowLong(hSess1, (int)WindowLongFlags.GWL_STYLE, getlongval);
SetWindowPos(hSess1, new IntPtr(0), 0, 0, groupBox1.Width, groupBox1.Height, SetWindowPosFlags.FrameChanged);

sess1.Visible = 1;
}
.
.
.
0 Likes
vfast Absent Member.
Absent Member.

Re: Embed Attachmate Extra! X-treme session in Windows Forms

Did you try this? how did it go?
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.