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: Getting the X,Y position when mouse is clicked
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted March 15, 2004 3:38 PM


Here is a handy way to determine which row/col was clicked. It uses the Mousedown event and the CharacterSize property:

  Private Sub Vt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Vt1.MouseDown
    Dim x As Integer = (e.X / Vt1.CharacterSize.Width) + 1
    Dim y As Integer = (e.Y / Vt1.CharacterSize.Height) + 1
    Vt1.Write("Vt1_MouseDown: " + "(" + x.ToString + "," + y.ToString + ")" + vbCrLf)
  End Sub
ja928

From: Canton, OH USA
Posts: 17
Member Since: 03/31/04
posted March 31, 2004 2:54 PM

Hi Tony,
You and I have talked via email about this. This code does not work for me. Try this:

Start a project, add a VT to a windows form. Set BufferRows = 0

Add the following code:

 Private Sub Vt1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Vt1.MouseDown
  If e.Clicks > 1 Then
   Dim x As Integer = (e.X / Vt1.CharacterSize.Width) + 1
   Dim y As Integer = (e.Y / Vt1.CharacterSize.Height) + 1
   Vt1.Write("Vt1_MouseDown: " + "(" + x.ToString + "," + y.ToString + ")" + vbCrLf)
   MessageBox.Show(Vt1.ScrapeText(y, 0, 80))
  End If
 End Sub

 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  Vt1.Write("Line1 abcdefg" & vbCrLf)
  Vt1.Write("Line2 abcdefg" & vbCrLf)
  Vt1.Write("Line3 abcdefg" & vbCrLf)
  Vt1.Write("Line4 abcdefg" & vbCrLf)
  Vt1.Write("Line5 abcdefg" & vbCrLf)
  Vt1.Write("Line6 abcdefg" & vbCrLf)

 End Sub

Double-Click on each of the "numbered" lines. As the Vt1.Write statements add up, this logic gets less and less accurate. Double-Click on some of the added lines. Am I missing something?

I am sorely in need of a function to reliably determine the character clicked (preferably accounting for different font sizes and scrollback buffer.

I appreciate all your help,
Jason
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted April 1, 2004 2:35 PM

This would be something you would need to determine on your own. I don't have any pre-written code for you.

If you aren't able to figure it out, please contact us directly to discuss consulting / support options.

Reply | PowerTCP Emulation for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX