IBM PCOMM Emulator, Accessing Selected Text via COM/C# interface

1.8k views Asked by At

Bear with me as this question is a bit complex.

When a user selects a block of text in the IBM Personal Communications (PCOMM) UI, how can I access attributes of the text they selected using code?

Consider the screenshot below: enter image description here

The user has selected text from Row 02, Column 17 to Row 02 Column 66.

However the cursor (which I can access via API) is at Row 15 Column 26.

I can access the .NET/COM interop API in:

using AutOIATypeLibrary;
using AutPSTypeLibrary;

How can I get the details of the user's selection i.e.{02,17} to {02,66}?

2

There are 2 answers

0
Valerie R On BEST ANSWER

It's definitely a challenging task, but not impossible if you really, really need to do it.

Unless you can convince the PCOMM support team to give you an API (or document one that probably exists, but is hidden), what you're trying to do can be done in one of two ways.

The "brute force" method would require interrogating the stack of objects on the screen to find the rectangle that PCOMM drew to show the text selection. Using standard Windows API calls, you can get its attributes, including the screen coordinates relative to the window. Of course, the problem is that this is in pixels, not 3270-characters, so you'd need to understand font metrics and all that stuff to understand that a pixel XY of (98, 123) is really line 2, column 16 in the 3270 display. It's possible, but you'll need a good bit of Windows programming skills.

Method number two is something I used in a similar situation a long time ago, and it relies on the fact that PCOMM has that area highlighted in order to allow things like cut-and-paste. What you'd do in your code would be to write something that send a Windows "COPY" command to the PCOMM app, and then you could read what was captured off the clipboard. Not guaranteed to work 100%, but certainly this would be much easier than the "brute force" method.

Finally, a mix of the two methods would be to run PCOMM under a good debugger and see if you can figure out the internal method it uses when a user selects an area and copies it to the clipboard. At some level, it's doing exactly what you need to do: the user selects an arbitrary area, then when he takes some other action (copy to the clipboard), PCOMM has to map that graphic area to the underlining 3270 characters. I'll wager that PCOMM has code that implements my "brute force" approach all bundled up in one of their DLLs. If you can figure out what PCOMM calls to fetch the text under a selected area, then there's no reason you can't call the same thing in your own code.

A good Windows debugger is definitely your friend if you want to go down these paths...

0
Kenny On

Instead of using PCOMM, use Host On Demand (which you should also be licensed for). The API is Java based, and much easier to navigate.