Snap mode ("S" key), window-cross cursor ("C") by mapbasic

61 views
Skip to first unread message

Sergi Gàmiz Ribelles

unread,
Aug 2, 2022, 9:21:45 AM8/2/22
to MapInfo-L
Hi,
Is it possible to code with mapbasic  activation/deactivation Snap mode? the same for window-cross cursor ("C" key), for Autonode mode ("N" key), for autotrace mode ("T" key)?

Thank you,
SGR

Peter Horsbøll Møller

unread,
Aug 2, 2022, 9:34:30 AM8/2/22
to mapi...@googlegroups.com

Hi

 

Are you trying to activate these from MapBasic?

 

Peter Horsbøll Møller

www.precisely.com

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Sergi Gàmiz Ribelles
Sent: 2. august 2022 15:22
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Snap mode ("S" key), window-cross cursor ("C") by mapbasic

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

 

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/8ce11977-d1fc-4b38-b259-409271302a07n%40googlegroups.com.

Sergi Gàmiz Ribelles

unread,
Aug 2, 2022, 9:46:01 AM8/2/22
to MapInfo-L
Yes, I want code "S" and "C", in Mapbasic.

El dia dimarts, 2 d’agost de 2022 a les 15:34:30 UTC+2, Peter Horsbøll Møller va escriure:

Peter Horsbøll Møller

unread,
Aug 2, 2022, 9:55:12 AM8/2/22
to mapi...@googlegroups.com

I had hoped the commands might appear in the Keyboard shortcuts but they don’t.

 

It doesn’t seem to be possible through MapBasic.

One option could be to use the WIN API methods for sending a keystroke. I think it’s called SendKey or similar.

Not sure how stable that would be?

Sergi Gàmiz Ribelles

unread,
Aug 3, 2022, 10:49:33 AM8/3/22
to MapInfo-L
I've compiled a very very short VB.NET module into a DLL file ( SendKey2MapInfo.dll ) : it has just one module (named "SENDKEYC") with the method     My.Computer.Keyboard.SendKeys("C", true)     , previously imported the Namespace     Microsoft.VisualBasic.Devices   which contains the class My.Computer.Keyboard.
Well, In Mapbasic I've written
Declare Sub SENDKEYC Lib ".\SendKey2MapInfo.dll" Alias "SENDKEYC"
Then
Call SENDKEYC
MapBasic IDE compiles my MB program without errors, but at runtime MapInfo returns the following error "External library does not containSENDKEYC. Unable to read application file". No error number. 
What's going wrong?
Thank you
El dia dimarts, 2 d’agost de 2022 a les 15:55:12 UTC+2, Peter Horsbøll Møller va escriure:

Peter Horsbøll Møller

unread,
Aug 4, 2022, 8:35:15 AM8/4/22
to mapi...@googlegroups.com

The can be a couple of things that makes Pro complain about the missing method.

 

Here’s how I typically declare a .NET in my MapBasic source

Declare Method FILEBrowseForFolder

     Class "FILELib.Files"  Lib "FILELib.dll" Alias "BrowseForFolder"

     (      ByVal sDescription As String   'Text to display in the dialog

           , ByVal sFolder As String        'Start folder to use in the dialog

           ) As String

 

1. Declare Method is right syntax for declaring .NET methods for use in your MapBasic code

2. I never give a path to the file

3. Remember to include the namespace

4. Remember to add potential parameters and be sure to use the right types.

Sergi Gàmiz Ribelles

unread,
Aug 5, 2022, 10:57:38 AM8/5/22
to MapInfo-L

My VB.NET code:

Imports Microsoft.VisualBasic.Devices
Namespace MyApp1
    Public Class SENDKEY2MAPINFO
        Public Shared Function SENDKEYX(s_key As String) As String
            My.Computer.Keyboard.SendKeys(s_key, True)
            Return 0
        End Function
    End Class
End Namespace


It compliles right into "SendKey2Mapinfo.dll"

My MB code:

Declare Method SENDKEYX Class "MyApp1.SENDKEY2MAPINFO" Lib "SendKey2MapInfo.dll" (ByVal s_key as String) As String
...   ...   ...
Dim retval, s_key as String
s_key="C"
retval = SENDKEYX(s_key)

At runtime it crashes with the message : "(appname.mb:line) Could not find class "MyApp1.SENDKEY2MAPINFO". TypeLoadException, Could not load type 'MyApp1.SENDKEY2MAPINFO' from assembly 'SendKey2MapInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. "

The same failing result if the VB.NET code is 
 Imports Microsoft.VisualBasic.Devices
Namespace MyApp1
    Public Class SENDKEY2MAPINFO
        Public Shared Function SENDKEYX(s_key As String)
            My.Computer.Keyboard.SendKeys(s_key, True)
            Return 0
        End Function
    End Class
End Namespace

And MB code is:
Declare Method SENDKEYX Class "MyApp1.SENDKEY2MAPINFO" Lib "SendKey2MapInfo.dll" (ByVal s_key as String)
...   ...   ...
...
Call SENDKEYX(s_key)

Without parameters, the result is the same.

May anyone find where the problem is?
Thank you in advance.
SGR

El dia dijous, 4 d’agost de 2022 a les 14:35:15 UTC+2, Peter Horsbøll Møller va escriure:

Peter Horsbøll Møller

unread,
Aug 7, 2022, 1:28:50 AM8/7/22
to mapi...@googlegroups.com
You have the dll om the same folder as the mbx, right?
Should your method also specify the parameter as ByVal?

Peter Horsbøll Møller
Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 


Den 5. aug. 2022 kl. 16.57 skrev Sergi Gàmiz Ribelles <sector_...@iies.es>:



Sergi Gàmiz Ribelles

unread,
Aug 8, 2022, 3:51:28 AM8/8/22
to MapInfo-L
It doesn't work either after specifying "ByVal" in the function definition (in VB.NET code) .
I don't understant what is going wrong. I give up!
SGR
Thank you for your interest and patience.
El dia diumenge, 7 d’agost de 2022 a les 7:28:50 UTC+2, Peter Horsbøll Møller va escriure:
Reply all
Reply to author
Forward
0 new messages