ICE

TCP/IP Products => TCP-PRO => Topic started by: jmabbott on January 07, 2004, 02:39:43 pm

Title: OLE-API Questions
Post by: jmabbott on January 07, 2004, 02:39:43 pm
When is the best time to do things like:
   set terminal type
   set color mapping flag
   set colors
   set key maps
   etc.
Right after issuing the Connect method
or
While processing the OnConnectionComplete event.

I noticed that some things, like set terminal type, can only be done after a connection is established so I do all setups after a connection is established.  Maybe some items can be setup before the connection is established.
Title: Re:OLE-API When best to update terminal type, etc.
Post by: Bob on January 08, 2004, 05:01:14 pm
When is the best time to do things like:
   set terminal type
   set color mapping flag
   set colors
   set key maps
   etc.
Right after issuing the Connect method
or
While processing the OnConnectionComplete event.

I noticed that some things, like set terminal type, can only be done after a connection is established so I do all setups after a connection is established.  Maybe some items can be setup before the connection is established.

I'll check into that in more detail, however it's important to note that some things that are passed on connection, most importantly the terminal type, so the remote host has no way to know if you have changed the terminal type AFTER you have a connection. Some versions of Unix can properly respond to a lines/columns change after connection but this is not universal.

Changing things that are only cosmetic, like the color attributes is fine to do after the connection is established.
Title: OLE-API Questions
Post by: jmabbott on January 28, 2004, 05:00:11 pm
For Example.
1. Bring focus to the OCX control.
2. Connect to a host.
3. Press the Caps Lock key to turn ON the Caps Lock light on the keyboard.
4. Notice that pressing the letter keys gives upper case letters.
5. Move focus away from the application with the OCX control, like to the desk top.
6. Press the Caps Lock key to turn OFF the Caps Lock light on the keyboard.
7. Bring focus back to the OCX control.
8. Notice that pressing the letter keys continues to give upper case letters.
9. Press the Caps Lock key to turn ON the Caps Lock light on the keyboard.
10. Notice that pressing the letter keys now to gives lower case letters with the Caps Lock Light on.
11. Telnet Pro does not misbehave this way.

Has anyone else seen this or can it be something in my application? :-\

Title: Re:OLE-API Trouble With Caps Lock
Post by: jmabbott on January 29, 2004, 09:30:48 am
Additional information:
1. A disconnect - connect cycle will restore the Caps Lock synchronicity.
2. Even when synchronized, with the Caps Lock on and holding down the shift key, pressing the letter keys gives upper case letters instead of lower case letters.
Title: Re:OLE-API Trouble With Caps Lock
Post by: Bob on January 29, 2004, 03:00:30 pm
Additional information:
2. Even when synchronized, with the Caps Lock on and holding down the shift key, pressing the letter keys gives upper case letters instead of lower case letters.

Normal behavior. We do this on purpose to mimic what a terminal does.
Title: OLE-API Trouble With Caps Lock
Post by: Bob on January 29, 2004, 03:23:50 pm
For Example.
1. Bring focus to the OCX control.
2. Connect to a host.
3. Press the Caps Lock key to turn ON the Caps Lock light on the keyboard.
4. Notice that pressing the letter keys gives upper case letters.
5. Move focus away from the application with the OCX control, like to the desk top.
6. Press the Caps Lock key to turn OFF the Caps Lock light on the keyboard.
7. Bring focus back to the OCX control.
8. Notice that pressing the letter keys continues to give upper case letters.
9. Press the Caps Lock key to turn ON the Caps Lock light on the keyboard.
10. Notice that pressing the letter keys now to gives lower case letters with the Caps Lock Light on.
11. Telnet Pro does not misbehave this way.

Has anyone else seen this or can it be something in my application? :-\


Telnet Pro saves the state of the "shift" keys (shift, alt, caps-lock and control) internally. When regaining focus from outside, it rereads the state of those keys and resyncs the internal copy. I'm not sure how you would handle that in your app. I THINK if you do a SetScanCodeMode(true) then ScanCodeMode(false) it will clear the internal flags but then I think you'd have to do the same for windows at the same time.
Title: Re:OLE-API Trouble With Caps Lock
Post by: jmabbott on January 30, 2004, 02:29:03 pm
The SetScanCodeMode procedure didn't resync the Caps Lock but you sent me in the correct direction.  In the windows event OnActivate I use the GetKeyState and SendInput to remember and restore the key states.
Thanks.
Also, both the OCX and Telnet Pro have the equivalent problem with the SHIFT key.  In Pro, press and hold the SHIFT key, use the mouse to move focus to the desk top, release the SHIFT key, return focus to Pro and Pro thinks the SHIFT key is still pressed.  I don't know why anyone would do that but it is interesting.
Title: Re:OLE-API Trouble With Caps Lock
Post by: Bob on January 30, 2004, 03:19:00 pm
The SetScanCodeMode procedure didn't resync the Caps Lock but you sent me in the correct direction.  In the windows event OnActivate I use the GetKeyState and SendInput to remember and restore the key states.
Thanks.
Also, both the OCX and Telnet Pro have the equivalent problem with the SHIFT key.  In Pro, press and hold the SHIFT key, use the mouse to move focus to the desk top, release the SHIFT key, return focus to Pro and Pro thinks the SHIFT key is still pressed.  I don't know why anyone would do that but it is interesting.

Excellent, Thanks for the feedback!
Title: OLE-API Docs ONLINE
Post by: Bob on July 22, 2004, 01:20:26 pm
See:

ftp://ftp.jriver.com/pub/downloads/ICETCP.PRO.SDK/

For API docs and sample programs. Note that the debug version of dejavu.ocx (which provides the API) is NOT included. You can use your existing dejavu.ocx to try out the API functions and samples.
Title: Re:OLE-API Questions
Post by: jmabbott on July 22, 2004, 03:14:30 pm
ESP!  Just this morning I thought about getting online and checking for updates.  I can't wait to try the TraceViewer.  Thanks.
Title: OLE-API Questions
Post by: Bob on July 22, 2004, 04:05:32 pm
You might need the debug version of the dejavu.ocx for that. We are working on the next release so that won't be available until the release date.
Title: Re:OLE-API Questions
Post by: jmabbott on July 30, 2004, 10:51:08 am
My debug OCX is dated 07/13/2000 and I never could get it to register anyway.  I have a question but I am not sure if it should be a new thread.
1.  I see that version 5.1.21 fixed the sync problem with the Shift Key and the Caps Lock Key.  Now I need a way for my program to discover the version number of the OCX because my program shouldn't attempt to synchronize these keys for version 5.1.21.
2. A feature of my program that does "GetScreenContents", changes the color attributes, and then does "SetScreenContents", no longer functions with version 5.1.21.
So my question is: How do I obtain the version information from the OCX?
Title: Re:OLE-API Questions
Post by: Bob on July 30, 2004, 12:23:31 pm
My debug OCX is dated 07/13/2000 and I never could get it to register anyway.  I have a question but I am not sure if it should be a new thread.
1.  I see that version 5.1.21 fixed the sync problem with the Shift Key and the Caps Lock Key.  Now I need a way for my program to discover the version number of the OCX because my program shouldn't attempt to synchronize these keys for version 5.1.21.
I'll check with the person who knows the OCX on Monday and update this post then.
Quote
2. A feature of my program that does "GetScreenContents", changes the color attributes, and then does "SetScreenContents", no longer functions with version 5.1.21.
So my question is: How do I obtain the version information from the OCX?
Interesting, sounds like another unwanted side effect of statically linking  mfc42.dll. It really shouldn't have changed the behavior but it does seem to have affected the bold fonts as well. Will check into that more on Monday as well. Thanks for the report!
Title: Re:OLE-API Questions
Post by: jmabbott on August 16, 2004, 03:16:58 pm
This question is about setting colors via GetScreenContent and SetScreenContent.
Reference your documentation at figure 1.7 on page 24 which shows all possible combinations of background and foreground colors.  The background colors (and foreground colors) look as expected for rows 0 thru 7 and rows 10 thru 15. Rows 8 and 9, which are background color index values 8 and 9, do not have a uniform background color like the other rows.
If I set the attributes to 9F for white letters on a blue background the screen actually shows white letters on a teal background and a GetScreenContents shows the attributes to be 3F which is correct for the color displayed but it is not the 9F that I set.
Using SetColor works properly and all new text display as expected.
Are there any special rules for the background color index values of 8 and 9 when setting attributes via SetScreenContents?
Title: OLE-API Questions
Post by: Bob on August 16, 2004, 03:32:17 pm
Is the background color setting the only difference you noticed between the 5.1.21 version of the OCX and the older versions? That could be a good clue as to what is going on. The programmer who is most familar with OCX is out until next week. I'll pass this info on to him.

From the point of view of the emulator core, there is a conflict between the "blink" bit and the topmost BG (high intensity) bit. I don't think you've run into that though. The other possibility is that you are in an alternate character set which could invalidate this bit as well. Since you have said that it works on the older OCX though I would not think that either of these ideas would come into play.

As far as getting the version is concerned, there doesn't appear to be a way to get that in the OCX. The only workaround that I can think of is to check the creation date of the OCX.
Title: Re:OLE-API Questions
Post by: jmabbott on August 16, 2004, 04:09:09 pm
The backgroung color setting problem also occurs with version 5.1.09.  This "issue" is visible in your documentation.  So I thought that maybe a description was left out about how 8 and 9 function.

Two things that I noticed about version 5.1.21:

1. I made the following change to my code because I was updating parts of both the visible and hidden screen buffer:
try
{
    m_Telnet.GetVisibleRect(&lLeft, &lTop, &lRight, &lBottom);

// changed for J.River version 5.1.21
//  m_Telnet.GetScreenContents((short)lLeft, (short)lTop, (short)lRight, (short)lBottom, &bstrScreen);
    m_Telnet.GetScreenContents(0, 0, (short)(lRight-lLeft), (short)(lBottom-lTop), &bstrScreen);
   
    m_Telnet.GetCursorPosition(&lColumn, &lRow);
}
catch (...)
{ }

2. The Caps Lock resyncs properly (and automatically) when focus is returned to my application by using the mouse to click anywhere within the application.  It does not resync if the application is activated by clicking on the application button on the task bar.  So far I have only tested the caps lock issue using NT.  I will try 2K and XP later this week.
Title: Re:OLE-API Questions
Post by: jmabbott on August 20, 2004, 11:14:04 am
1. Lets make sure the OCX programmer has plenty to do when he returns.

2. Item 2 above appears to only be an NT issue.  Caps lock resyncs properly under all conditions with XP and 2K.  Who needs NT anyway?

3. I don't think I have the "topmost BG (high intensity)" problem but I do have a problem with foreground color.  If I do SetColor (1,n) with n between 8 and F, a GetColor(1) returns n, but new characters on the screen display as if I had done SetColor (1,n-8).  I see that TelnetPro does not have this problem.

4. If I mistakenly do SetColor (1,0) and SetColor (2,0) - black letters on a black background - a GetScreenContents(...) returns garbage.

5. I develop on an NT but the operators run the application on XPs and 2Ks. We use the ICE 437 font with the application.  All our PCs are now at 5.1.21 so I can't determine if an issue is old or new.

6. Have a nice weekend.
Title: Re:OLE-API Questions
Post by: Bob on August 20, 2004, 11:37:05 am
1. Lets make sure the OCX programmer has plenty to do when he returns.
Ugh
Quote
2. Item 2 above appears to only be an NT issue.  Caps lock resyncs properly under all conditions with XP and 2K.  Who needs NT anyway?
Agreed.
Quote
3. I don't think I have the "topmost BG (high intensity)" problem but I do have a problem with foreground color.  If I do SetColor (1,n) with n between 8 and F, a GetColor(1) returns n, but new characters on the screen display as if I had done SetColor (1,n-8).  I see that TelnetPro does not have this problem.

4. If I mistakenly do SetColor (1,0) and SetColor (2,0) - black letters on a black background - a GetScreenContents(...) returns garbage.
Hmmm, what development environment are you using?
Quote
5. I develop on an NT but the operators run the application on XPs and 2Ks. We use the ICE 437 font with the application.  All our PCs are now at 5.1.21 so I can't determine if an issue is old or new.
You Could just copy the dejavu.ocx from 5.1.19, register it one one machine and try that. It would really be interesting to see what if any difference that makes.
Quote
6. Have a nice weekend.
Thanks, you too.
Title: Re:OLE-API Questions
Post by: jmabbott on August 20, 2004, 05:00:17 pm
I did the following and there was no improvement or change in performance: I restored 5.1.19 OCX; I rebuilt the "dejavu wrapper" - dejavu.cpp, dejavu.h, font.cpp, font.h - from 5.1.21 because mine where nearly two years old; Tried static and dynamic linking of the MFC dlls.  I did these test on my NT and on a 2K (the compile was done on the NT) that I use for testing.

I develop on a NT using MS Visual C++ 6.0.  The application is used in production on XPs and 2Ks.
Title: Re:OLE-API Questions
Post by: jmabbott on December 07, 2004, 09:54:45 am
Good morning.

I have upgraded to version 5.1.25.
I still have the problem of unable to set high intensity colors and by the way the little funny about "GetScreenContents(...) returns garbage when colors are set to black on black" still exist too.

My application allows operators to change colors on the fly.  That is when high intensity settings display as low intensity settings.  I see that TelnetPro only allows color changes when disconnected.

When is the best time to do things like:
    set color mapping flag
    set colors
    set key maps
    etc.
Before issuing the Connect.
While processing the OnConnectionComplete event.
After issuing the Connect.

Not to deviate from the color problem but I found that doing a "SetTerminalType()" before connecting crashed my application.  So I do it during the "OnConnectionComplete" event as:

try
{
m_Telnet.GetVisibleRect(&lLeft, &lTop, &lRight, &lBottom);
m_Telnet.GetScreenCharacters((short)lLeft, (short)lTop, (short)lRight, (short)lBottom, &bstrScreen);
m_Telnet.GetCursorPosition(&lColumn, &lRow);
m_Telnet.SetTerminalType (lType);
m_Telnet.SetScreenCharacters((short)lLeft, (short)lTop, (short)lRight, (short)lBottom, &bstrScreen);
m_Telnet.SetCursorPosition(lColumn, lRow);
}
catch (...)
{ }

Title: Re:OLE-API Questions
Post by: jmabbott on March 04, 2005, 03:05:26 pm
Any estimate about when I will get a reply?
(If it helps, we are scheduled to buy 60 additional licenses this month.)

In summary, the two hot questions are:
1. How do I make SetColor(ID,Value) work with Values between 8 and F?
2. When is the best time to do things like:
    set color mapping flag
    set colors
    set key maps
    etc.
 a:Before issuing the Connect.
 b:While processing the OnConnectionComplete event.
 c:After issuing the Connect.
Title: Re:OLE-API Questions
Post by: Bob on March 08, 2005, 10:00:23 am
Any estimate about when I will get a reply?
(If it helps, we are scheduled to buy 60 additional licenses this month.)

In summary, the two hot questions are:
1. How do I make SetColor(ID,Value) work with Values between 8 and F?
I'm not sure. What terminal type are you setting?

Quote
2. When is the best time to do things like:
    set color mapping flag
    set colors
    set key maps
    etc.
 a:Before issuing the Connect.
 b:While processing the OnConnectionComplete event.
 c:After issuing the Connect.
You cannot set emulation related parameters until after a connect. This is because the emulator core isn't initialized until just before the connect and there is no hook to get into the process between the core initialization and the connect that I know of.

I think the best bet is to set the terminal type OnConnectionComplete then set the color mapping flag, colors, etc OnTerminalTypeChanged. I'm assuming that these are all acting on the active profile. The default profile must be used for the connection. Perhaps it's possible to change the default profile to get what you want before the connect?
Title: Re:OLE-API Questions
Post by: jmabbott on March 08, 2005, 11:39:59 am
1. Terminal type is 2 - ANSI (25 Line).  At OnConnectionComplete: the terminal type is set, the colors are set (with bright foreground), the screen is re-written.  At that point the J.River copyright is on the screen in bright letters.  Then the text that arrives from the host is in dim letters.

2. Thanks - great info.  I never considered changing the color info in the default profile.  Our application extracts key mapping information from a user profile and passes it on to the OCX during OnConnectionComplete.  That lets us use your profile editor to setup key mappings.  Do you guys publish the exact structure of a profile?

Thanks again.  I have a few things to try.
Title: OLE-API Questions
Post by: Bob on March 08, 2005, 03:13:33 pm
The bright foreground on the copyright is normal. Also, it should go dim forground after you change terminal type to ANSI because that is the default for all non-wyse terminals. If it didn't go dim, the normal attribute changes (i.e. bold) wouldn't work right.

I'm not sure about whether or not changing the default profile will help (it's in the registry), We were thinking that it might be already read by the container before the OCX is run however you can try to test it if you want. The easiest test would be to just run telnet pro and change something in the default profile and see if the chage is reflected in your app.

Update, the default profile in the registry isn't read by the ocx. The default profile in the ocx needs to be changed with the get and set profile commands documented below.
Title: Re:OLE-API Questions
Post by: jmabbott on July 06, 2005, 08:23:19 am
1. Changes to the default profile are not reflected in applications using the OCX.  I just thought about rebooting - maybe the OCX only reads the default profile once.

2. Using the code below that swaps the ColorEntryTerminal makes Dejavu ANSI terminal emulation behave like other emulators that my users seem to like.

Thanks.


// long l0 = m_ac1.GetColorTableEntry (0);
   long l1 = m_ac1.GetColorTableEntry (1);
   long l2 = m_ac1.GetColorTableEntry (2);
   long l3 = m_ac1.GetColorTableEntry (3);
   long l4 = m_ac1.GetColorTableEntry (4);
   long l5 = m_ac1.GetColorTableEntry (5);
   long l6 = m_ac1.GetColorTableEntry (6);
   long l7 = m_ac1.GetColorTableEntry (7);
// m_ac1.SetColorTableEntry (0, m_ac1.GetColorTableEntry ( 8));
   m_ac1.SetColorTableEntry (1, m_ac1.GetColorTableEntry ( 9));
   m_ac1.SetColorTableEntry (2, m_ac1.GetColorTableEntry (10));
   m_ac1.SetColorTableEntry (3, m_ac1.GetColorTableEntry (11));
   m_ac1.SetColorTableEntry (4, m_ac1.GetColorTableEntry (12));
   m_ac1.SetColorTableEntry (5, m_ac1.GetColorTableEntry (13));
   m_ac1.SetColorTableEntry (6, m_ac1.GetColorTableEntry (14));
// m_ac1.SetColorTableEntry (7, m_ac1.GetColorTableEntry (15));
// m_ac1.SetColorTableEntry ( 8, l0);
   m_ac1.SetColorTableEntry ( 9, l1);
   m_ac1.SetColorTableEntry (10, l2);
   m_ac1.SetColorTableEntry (11, l3);
   m_ac1.SetColorTableEntry (12, l4);
   m_ac1.SetColorTableEntry (13, l5);
   m_ac1.SetColorTableEntry (14, l6);
// m_ac1.SetColorTableEntry (15, l7);
Title: Re:OLE-API Questions
Post by: Bob on July 07, 2005, 04:04:01 pm
1. Changes to the default profile are not reflected in applications using the OCX.  I just thought about rebooting - maybe the OCX only reads the default profile once.
I believe the "Default Profile" when using the ocx is in the data section of the ocx. This "default" is overwritten by the registry default when the telnet pro container reads the registry on  execution. Then if a different profile is selected in the telnet pro app it lays that over the same data area  again.
Quote
2. Using the code below that swaps the ColorEntryTerminal makes Dejavu ANSI terminal emulation behave like other emulators that my users seem to like.

Thanks.


// long l0 = m_ac1.GetColorTableEntry (0);
   long l1 = m_ac1.GetColorTableEntry (1);
   long l2 = m_ac1.GetColorTableEntry (2);
   long l3 = m_ac1.GetColorTableEntry (3);
   long l4 = m_ac1.GetColorTableEntry (4);
   long l5 = m_ac1.GetColorTableEntry (5);
   long l6 = m_ac1.GetColorTableEntry (6);
   long l7 = m_ac1.GetColorTableEntry (7);
// m_ac1.SetColorTableEntry (0, m_ac1.GetColorTableEntry ( 8  ));
   m_ac1.SetColorTableEntry (1, m_ac1.GetColorTableEntry ( 9));
   m_ac1.SetColorTableEntry (2, m_ac1.GetColorTableEntry (10));
   m_ac1.SetColorTableEntry (3, m_ac1.GetColorTableEntry (11));
   m_ac1.SetColorTableEntry (4, m_ac1.GetColorTableEntry (12));
   m_ac1.SetColorTableEntry (5, m_ac1.GetColorTableEntry (13));
   m_ac1.SetColorTableEntry (6, m_ac1.GetColorTableEntry (14));
// m_ac1.SetColorTableEntry (7, m_ac1.GetColorTableEntry (15));
// m_ac1.SetColorTableEntry ( 8, l0);
   m_ac1.SetColorTableEntry ( 9, l1);
   m_ac1.SetColorTableEntry (10, l2);
   m_ac1.SetColorTableEntry (11, l3);
   m_ac1.SetColorTableEntry (12, l4);
   m_ac1.SetColorTableEntry (13, l5);
   m_ac1.SetColorTableEntry (14, l6);
// m_ac1.SetColorTableEntry (15, l7);


What change does that make to the colors? (just curious).
Title: OLE-API Questions
Post by: jmabbott on July 07, 2005, 05:17:55 pm
Before the change the application displayed all text as dim letters no matter how the colors are set.  After changing the color table the application displays text as bright and dim letters as it does in other emulators.  Makes my users happy.
Title: OLE-API Questions
Post by: Bob on July 07, 2005, 07:59:35 pm
What happens when an application sets bold mode? The point of the dim default is to act like a real terminal which uses the bright colors to represent the bold attribute when an application sets it.
Title: OLE-API Questions - set/get profile call structure
Post by: Bob on September 20, 2005, 05:06:00 pm
This file contains the struct's and functions used to construct the profile variant that is used in the connect function (2nd parameter).
Theoretically you should be able to get the profile, change the terminal type and set the profile before calling the connect.

This code Copyright(C) Jriver, Inc. All rights reserved.

typedef struct {
        // data members
        char    ProfileName[128];
        int             TerminalType;

        LOGFONT fontText;

        int             TextColor;              // Index into color table.
        int             BkColor;                // Index into color table.


        BYTE    TerminalScreenHeight;   // Based on terminal type...
        DWORD   LineWidth;              // Current width of a line on the terminal screen.
        DWORD   NumberOfLines;  // Number of lines in virtual screen...cannot be smaller
                                                        // than terminal screen height.

        BOOL    UseVisualBell;
        BOOL    UseKeyboardCopyPaste;
        BOOL    TelnetSendOnEveryChar;  // Or send on EOL if false.
        BOOL    TelnetRemoteEcho;               // Or local echo if false.

        // Printing settings...either use system default or specify a printer.
        BOOL    UseDefaultPrinter;              
        char    Device[128];
        char    Driver[128];
   
   char  LocalModeDevice[128];
   char  LocalModeDriver[128];

        int      PrinterTimeout;
        long    PrintMethod;
        char    DirectPrintName[128];
        long    SegmentSize;
        int       BoldFont;

        BOOL    UsePCScanCodeKeyboard;

        // Hypertext link settings.
        BOOL    UseLinkHighlighting;
        int         LinkHighlightTextColor;
        BOOL    LinkHighlightingUnderLined;

        int       NumberOfVirtualScreens;
        char    MScreenPath[128];               // Directory to find mscreen program.
        char    MScreenCapPath[128];            // Directory to store mscreencap config file.
} PassProfile;

////////////////////////////////////////////////////////////////////

PassProfile ProfileData::GetPassProfile()
{
        PassProfile     Result;

        ZeroMemory(&Result, sizeof(Result));

        strcpy(Result.ProfileName, ProfileName.GetBuffer(ProfileName.GetLength()));
        ProfileName.ReleaseBuffer();

        Result.TerminalType = TerminalType;

        Result.fontText = fontText;
        Result.TextColor = Colors[DEJACOLOR_F_NORMAL];
        Result.BkColor = Colors[DEJACOLOR_B_NORMAL];
        Result.BoldFont= BoldFont;
        Result.TerminalScreenHeight = TerminalScreenHeight;
        Result.NumberOfLines = NumberOfLines;
        Result.LineWidth = LineWidth;

        Result.UseVisualBell = UseVisualBell;
        Result.UseKeyboardCopyPaste = UseKeyboardCopyPaste;
        Result.TelnetSendOnEveryChar = TelnetSendOnEveryChar;  
        Result.TelnetRemoteEcho = TelnetRemoteEcho;            

        // Printing settings...either use system default or specify a printer.
        Result.UseDefaultPrinter = UseDefaultPrinter;          
        strcpy(Result.Device, Device.GetBuffer(Device.GetLength()));
        Device.ReleaseBuffer();
        strcpy(Result.Driver, Driver.GetBuffer(Driver.GetLength()));
        Driver.ReleaseBuffer();

        strcpy(Result.LocalModeDevice, LocalModeDevice.GetBuffer(LocalModeDevice.GetLength()));
        LocalModeDevice.ReleaseBuffer();
        strcpy(Result.LocalModeDriver, LocalModeDriver.GetBuffer(LocalModeDriver.GetLength()));
        LocalModeDriver.ReleaseBuffer();
        Result.PrinterTimeout = PrinterTimeout;
                 Result.PrintMethod = PrintMethod;
        strcpy(Result.DirectPrintName,DirectPrintName.GetBuffer(Device.GetLength()));
        Result.SegmentSize = SegmentSize;

        Result.UsePCScanCodeKeyboard = UsePCScanCodeKeyboard;

        // Hypertext link settings.
        Result.UseLinkHighlighting = UseLinkHighlighting;
        Result.LinkHighlightTextColor = Colors[DEJACOLOR_F_LINK];
        Result.LinkHighlightingUnderLined = LinkHighlightingUnderLined;

        Result.NumberOfVirtualScreens = NumberOfVirtualScreens;

        strcpy(Result.MScreenPath, MScreenPath.GetBuffer(MScreenPath.GetLength()));
        MScreenPath.ReleaseBuffer();

        strcpy(Result.MScreenCapPath, MScreenCapPath.GetBuffer(MScreenCapPath.GetLength()));
        MScreenCapPath.ReleaseBuffer();

        return Result;
} // ProfileData::GetPassProfile()

////////////////////////////////////////////////////////////////

void SessionControl::CreateSafeArrayProfile(VARIANT & var, ProfileData * Data)
{
        ASSERT_POINTER(Data, ProfileData);

        // prepare data for ole
        HRESULT hCheckReturnValue;

        VariantInit(&var);


        SAFEARRAYBOUND  bound;
        bound.lLbound = 0;
        bound.cElements = sizeof(PassProfile);

        var.parray = SafeArrayCreate(VT_UI1, 1, &bound);

        if (NULL != var.parray)
        {
                var.vt = VT_ARRAY | VT_UI1;
                void *pArrayData = NULL;

                PassProfile     TempPassProfile = Data->GetPassProfile();

                // Lock the memory.
                hCheckReturnValue = SafeArrayAccessData(var.parray, &pArrayData);

                ASSERT(S_OK == hCheckReturnValue);

                // Copy the profile into the variant's SafeArray.
                memcpy(pArrayData, &TempPassProfile, sizeof(PassProfile));

                // Unlock the memory.
                hCheckReturnValue = SafeArrayUnaccessData(var.parray);

                ASSERT(S_OK == hCheckReturnValue);

        } // if
        else
        {
                TRACE("Error creating SafeArray.\n");
        } // if


///////////////////////////////////////////////////////////////

Code Making the call:


                        VARIANT var;

                        CreateSafeArrayProfile(var, Profile);

                        ...
                        // Finally, make the OLE Automation call to connect to the host.
                        pNewConnection->Connect(&strName, var);



Values for the terminal type:
const int DV_ANSI_24    = 1;
const int DV_ANSI_25    = 2;
const int DV_AT386        = 3;
const int DV_ATT60       = 4;
const int DV_VT102        = 5;
const int DV_VT2207BIT  = 6;
const int DV_VT2208BIT  = 7;
const int DV_IBM3151_24 = 8;
const int DV_IBM3151_25 = 9;
const int DV_WYSE60_24  = 10;
const int DV_WYSE60_25  = 11;
const int DV_WYSE160_24 = 12;
const int DV_WYSE160_25 = 13;
const int DV_PCTERM     = 14;
const int DV_LINUX_24   = 15;
const int DV_LINUX_25   = 16;


Title: OLE-API Questions
Post by: jwf on September 29, 2005, 12:05:39 pm
Hey Bob,

Thanks!  I'm using your AXControl in .NET using managed code.  From your description above I get:

   [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
   public struct LOGFONT
   {
      public const int LF_FACESIZE = 32;
      public int lfHeight;
      public int lfWidth;
      public int lfEscapement;
      public int lfOrientation;
      public int lfWeight;
      public byte lfItalic;
      public byte lfUnderline;
      public byte lfStrikeOut;
      public byte lfCharSet;
      public byte lfOutPrecision;
      public byte lfClipPrecision;
      public byte lfQuality;
      public byte lfPitchAndFamily;
      [MarshalAs(UnmanagedType.ByValTStr, SizeConst=LF_FACESIZE)]
      public string lfFaceName;
   }
   
   [ StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi) ]
   public struct PassProfile
   {
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  ProfileName;
      public int     TerminalType;
      public LOGFONT fontText;
      public int     TextColor;              // Index into color table.
      public int     BkColor;                // Index into color table.
      public byte    TerminalScreenHeight;  // Based on terminal type...
      public uint    LineWidth;              // Current width of a line on the terminal screen.
      public uint    NumberOfLines;  // Number of lines in virtual screen...cannot be smaller
                              // than terminal screen height.
      public bool    UseVisualBell;
      public bool    UseKeyboardCopyPaste;
      public bool    TelnetSendOnEveryChar;  // Or send on EOL if false.
      public bool    TelnetRemoteEcho;       // Or local echo if false.

      // Printing settings...either use system default or specify a printer.
      public bool    UseDefaultPrinter;              
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  Device;
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  Driver;
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  LocalModeDevice;
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  LocalModeDriver;
      public int     PrinterTimeout;
      public uint    PrintMethod;
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  DirectPrintName;
      public uint    SegmentSize;
      public int     BoldFont;
      public bool    UsePCScanCodeKeyboard;

      // Hypertext link settings.
      public bool    UseLinkHighlighting;
      public int     LinkHighlightTextColor;
      public bool    LinkHighlightingUnderLined;

      public int     NumberOfVirtualScreens;
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  MScreenPath;              // Directory to find mscreen program.
      [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst=128)]
      public string  MScreenCapPath;           // Directory to store mscreencap config file.
   }


For a quick test I checked Marshal.Sizeof(typeof(PassProfile)) and got 1164.
Is this the right size for this structure?

Next, using aximp.exe I shall see if I can call GetProfile(object l_profile)
Title: Re:OLE-API Questions
Post by: jwf on September 29, 2005, 04:21:12 pm
Okay, not having super luck with this.  Is it possible to get the IDL definitions for SetProfile and GetProfile?

is GetProfile: GetProfile([in, out] VARIANT...
or GetProfile([out] VARIANT

I assume that it expects/produces (whichever) a safearray containing a V_RECORD?

I assume that SetProfile and Connect use ([in] VARIANT...)
Title: OLE-API Questions
Post by: Bob on September 29, 2005, 04:43:48 pm
I'll check and get back to you. It may not be until Monday.
Title: OLE-API Questions
Post by: Bob on October 03, 2005, 02:06:40 pm
Here is how the container does it. Hope this helps....

This code Copyright(C) Jriver, Inc. All rights reserved.

TelnetPro.exe code:

void CAquarius::Connect(BSTR* Host, const VARIANT& Profile)
{
        static BYTE parms[] = VTS_PBSTR VTS_VARIANT;
        InvokeHelper(0x53, DISPATCH_METHOD, VT_EMPTY, NULL, parms, Host, &Profile);
}

void CAquarius::GetProfile2(const VARIANT& l_Profile)
{
        static BYTE parms[] = VTS_VARIANT;
        InvokeHelper(0x54, DISPATCH_METHOD, VT_EMPTY, NULL, parms, &l_Profile);
}

void CAquarius::SetProfile2(const VARIANT& l_Profile)
{
        static BYTE parms[] = VTS_VARIANT;
        InvokeHelper(0x55, DISPATCH_METHOD, VT_EMPTY, NULL, parms, &l_Profile);
}


----------------------------------

OCX Code:

/////////////////////////////////////////////////////////////////////////////
//
// Function:    SetProfile/GetProfile
//
// Purpose:             These are the methods to get and set the profile property.
//
// Comments:    I couldn't figure out how to pass any type I wanted, so I
//                              chose LPCTSTR, cast a pointer to a ProfileData object to
//                              LPCTSTR before calling and it should work fine.
//
/////////////////////////////////////////////////////////////////////////////

void CAquariusCtrl::SetProfile(const VARIANT FAR& Profile)
{
        void *pArrayData;
        PassProfile     TempPassProfile;
   
        SafeArrayAccessData(Profile.parray, &pArrayData);
        CopyMemory(&TempPassProfile, pArrayData, sizeof(PassProfile));
        SafeArrayUnaccessData(Profile.parray);

        // TODO:  Write code to check the profile for reasonable values.
        int iPassProfileReturn = IsPassProfileValid(&TempPassProfile);
        if (0 == iPassProfileReturn)
        {
                ProfileData     OldProfile = *m_Profile;
                m_Profile->SetPassProfile(&TempPassProfile);

                // Check for actions that need to be taken based on differences
                // in new and old profiles.
                ActOnNewProfile(&OldProfile, m_Profile);
        } //
        else
        {
                DejaTrace(sevError,traceProfile,"Pass Profile is invalid, bad field =%d.\n", iPassProfileReturn);
        } // else

} // CAquariusCtrl::SetProfile

void CAquariusCtrl::GetProfile(const VARIANT FAR& l_Profile)
{

        void *pArrayData;
        PassProfile     TempPassProfile;

        SafeArrayAccessData(l_Profile.parray, &pArrayData);
        TempPassProfile = m_Profile->GetPassProfile();
        CopyMemory(pArrayData, &TempPassProfile, sizeof(PassProfile));
        SafeArrayUnaccessData(l_Profile.parray);
} // CAquariusCtrl::GetProfile

///////////////////////////////
void CAquariusCtrl::Connect(BSTR FAR* Host, const VARIANT FAR& Profile)
{
....
}



/////////////////////////////////////
header file declarations:

        afx_msg void Connect(BSTR FAR* Host, const VARIANT FAR& Profile);
        afx_msg void GetProfile(const VARIANT FAR& l_Profile);
        afx_msg void SetProfile(const VARIANT FAR& l_Profile);

/////////////////////////////////////
Dispatch calls:

        DISP_FUNCTION(CAquariusCtrl, "Connect", Connect, VT_EMPTY, VTS_PBSTR, VTS_VARIANT)
        DISP_FUNCTION(CAquariusCtrl, "GetProfile", GetProfile, VT_EMPTY, VTS_VARIANT)
        DISP_FUNCTION(CAquariusCtrl, "SetProfile", SetProfile, VT_EMPTY, VTS_VARIANT)
Title: Re:OLE-API Questions
Post by: BGA on October 19, 2005, 09:34:52 pm
How do I hide the status area at the bottom of the terminal screen ? or change it to a different color other than white.

cheers.
Title: OLE-API Questions
Post by: Bob on October 20, 2005, 09:52:26 am
Is this an API question??

If not, the status bar appears as it normally would on a 24 line terminal (you must be in 24 line mode). To change the color in the PRO client, edit the colors in the profile, the status line is one of the things you can change under appearance as label foreground and label background
Title: Re: OLE-API Questions, workaround for easily setting the terminal type, etc.
Post by: Bob on January 29, 2008, 03:54:11 pm
You can set the terminal type in the default profile without dealing with the profile variant. You can do a connect/set term type/disconnect/reconnect

This will use the terminal type set during the first (essentially instantaneous) open/close. In VB code it looks like this:

        vProfile = Null
        ' set the font
        DejaVu.Font.Name = "ICE 437"
        ' connect to the host
        Call DejaVu.Connect(sHostName, vProfile)
        ' set terminal type to att605
        Call DejaVu.SetTerminalType(3)
        ' disconnect from the host
        Call DejaVu.Disconnect
        ' reconnect to the host (using previously set terminal type)
        Call DejaVu.Connect(sHostName, vProfile)
        ' enable color mapping
        DejaVu.ColorMappingFlag = True
        ' set normal foreground to cyan
        Call DejaVu.SetColor(1, 3)
        ' set normal background to black
        Call DejaVu.SetColor(2, 0)
        ' clear the screen with the new colors
        Call DejaVu.ResetTerminal

Title: Re: OLE-API Questions
Post by: jimn on August 19, 2008, 02:12:05 pm
Connecting with SSH:

On the Connect call, add "++ssh" (no quotes) to the host name.