Callback in VB.net

Source: Internet
Author: User
Even though I'm not quite sure as to what the problem exactly is
With your callback function (was not supported ded in your sample code ),
Here is the complete code for a very simple Visual Basic. NET app,
Using two mi ole callback functions (sorting ing status text and
Custom tool input event notification ):

Form1 contains the map window (PictureBox, "pbMap") and a text box
("TbStatus"), displaying the contents of the status line.

''' Begin of VBN code ''''''''''''''''''''''' ''''''''''''

Public Class Form1

The MapInfo OLE object:
Private mi As Object

'The object implementing The COM/OLE2 automation server
The target of the callbacks originating from the mi ole object:
Private comServObj As New ComClass1

'A shared object reference to the status text control
'Later access within the status text callback function:
Public Shared tbStatObj As Object

Public Sub New ()

'Initialize main form (built with VS Form Designer ):
InitializeComponent ()

'Save persistent (shared) obj ref to status text control:
TbStatObj = Me. tbStatus

'Create and configure the mi com object, open a map etc .:
Mi = CType (CreateObject ("MapInfo. Application"), MapInfo. DMapInfo)
Mi. do ("Set Application Window" & CType (Me. pbMap. Handle, String ))
Mi. do ("Set Next Document Parent" & CType (Me. pbMap. Handle, String )_
& "Style 1 ")
Mi. do ("Open Table" "c:/maps/world. tab" "Interactive Map From World ")
Mi. Do ("Set Map Display Position ")
Mi. Do ("Create Buttonpad" "SelectGeneric" "As Toolbutton ID 785 "_
& "DrawMode 34 Cursor 134 Calling OLE" "SelectGeneric """)
Mi. Do ("Run Menu Command ID 785 ")
Mi. SetCallback (comServObj)

End Sub

End Class

'Register this class as a COM/OLE2 class:
<ComClass (ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1

'Unique IDs for this COM app interface:
Public Const ClassId As String =
"9CC9946D-C1E4-4f42-9E8C-C4693BD04577"
Public Const InterfaceId As String =
CC6697F7-968D-47dc-9B5B-84DEF8FD5D6B"
Public const eventsid as string =
"2a765f7e-e628-4427-a730-a695543edb79"

Public sub new ()
Mybase. New ()
End sub

'Callback function refreshing the contents of the Mapinfo status line,
'When changed:
Public sub setstatustext (byval strstatus as string)
'Show status line text in text box:
Ctype (form1.tbstatobj, control). Text = strstatus
End sub

'Callback function for notification of user input events
'Generated by the custom tool (ID 785, see above ):
Public Sub SelectGeneric (ByVal str As String)
MessageBox. Show ("A user input event occurred with the parameters :"_
& VbCrLf & str, "MI Custom Tool Callback ")
End Sub

End Class

''''' ''' End of VBN code ''''''''''''''''''''''' ''''''''''''
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.