Login  
Search All Forums
Dart Home | PowerTCP Emulation for .NET | Custom Development Reply | PowerTCP Emulation for .NET Topics | Forums   
AuthorForum: PowerTCP Emulation for .NET
Topic: Running the Emulator from another Class
jliszka

From: Mountain View, CA USA
Posts: 12
Member Since: 02/06/04
posted February 26, 2004 1:25 PM

I'm trying to operate the Emulator through another class. I can connect and "send()", but I can't the display. I've tried focus, refresh, etc.

In my example below, I start a new project, then import all the modules from the emulation demo (and add the license and Dart references of course).


Imports WindowsApplication1.frmMain

Public Class Form1
Inherits System.Windows.Forms.Form


#Region " Windows Form Designer generated code "

Dim tnObj As New frmMain

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tnObj.Show()
End Sub

Private Sub b1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles b1.Click
If tnObj.Telnet1.Connected Then tnObj.Telnet1.Dispose()
tnObj.Telnet1.Connect("10.3.0.162", 7001)
End Sub

End Class
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted February 26, 2004 2:08 PM

It has to do with setting the Parent of the Vt to the form it's on. Below is a class I used to test and it worked ok for me:

Imports Dart.PowerTCP.Emulation

Public Class Class1
  Private m_Vt As New Vt

  Public Sub New(ByVal Parent As Form)
    m_Vt.Parent = Parent
  End Sub

  Public Sub Show()
    m_Vt.Top = 0
    m_Vt.Left = 0
    m_Vt.Width = m_Vt.Parent.ClientSize.Width
    m_Vt.Height = m_Vt.Parent.ClientSize.Height
    m_Vt.Show()
  End Sub

  Public Sub Display(ByVal Text As String)
    m_Vt.Write(Text)
  End Sub
End Class


Here is the code that uses the class:

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim c As New Class1(Me)
    c.Show()
    c.Display("Hello World")
  End Sub
jliszka

From: Mountain View, CA USA
Posts: 12
Member Since: 02/06/04
posted February 26, 2004 4:08 PM

Thanks for the prompt reply.

My goal is not to create a new instance of the emulator, but to use the emulator instantiated on another form (frmMain from your sample code in my example).

My application is to have a form with the telnet and emulator controls running in the background while other classes issue commands and process results.

The form with the emulator is primarilly available for the user to observe the communication, but must also be available for user input.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted February 26, 2004 4:48 PM

The following works for me:

Public Class VtAccess
  Private m_Vt As Dart.PowerTCP.Emulation.Vt

  Public Sub Display(ByVal Text As String)
    m_Vt.Write(Text)
  End Sub

  Public Sub New(ByVal Vt As Dart.PowerTCP.Emulation.Vt)
    m_Vt = Vt
  End Sub
End Class

then on the form:

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim v As New VtAccess(Vt1)
    v.Display("Hello World")
  End Sub
jliszka

From: Mountain View, CA USA
Posts: 12
Member Since: 02/06/04
posted February 26, 2004 5:12 PM

What you wrote the first time works here too. What you wrote in your second post resulted in a complaint that in "Button1_Click…Dim v As New VtAccess(vt1)", vt1 is not declared. With whatever it is missing, I’m sure it would work too.

But this still would make a new emulator control which is not what I want to do. I want to refer to an emulator control placed on a form at design time, such as frmMain in your demo.

Carrying forth in the example I originally posted, from Form1.tnObj, I can successfully connect and can successfully issue commands, but it appears that frmMain’s Telnet1_EndReceive never fires.

Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted February 26, 2004 5:17 PM

Vt1 is the Emulator control on the form. I am passing a reference to it to the new class.

I think this has become too complex for the forum. Please create a very simple sample project that does exactly what you are trying to describe. Zip it up and email it to support@dart.com and I will see if I can figure it out. Please make sure you eliminate all unnecessary code from the sample.
jliszka

From: Mountain View, CA USA
Posts: 12
Member Since: 02/06/04
posted February 26, 2004 5:18 PM

Ok.

Thanks
jliszka

From: Mountain View, CA USA
Posts: 12
Member Since: 02/06/04
posted March 13, 2004 12:18 PM

It turns out the text WAS there the whole time. When you create a new form object with the VT emulator control on it, the scroll bar is in the center position, not at the bottom. I never operated long enough for the text to fill up the scrollback. I didn't notice the scroll position for a long time, especially because when I clicked on the VT control, what I thought was a block curser appeared (the true cursor was actually off screen with everything thing else). Though it wasn't intuitive for me, the solution is easy, issuing VT1.Clear() after connecting brings the scroll bar down.
Reply | PowerTCP Emulation for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX