Using Visio built-in menu in drawing control

Y

YOUNGHEE

Thank you for your answer, Mai-lan

I read the article that you recommended and I can succeed in importing
Visio's built-in menu in C#.

But I can't convert code into vb.net.

I tried below code but it didn't work.

Thank you,
Younghee

****************************************************************************
**************
Imports System.Runtime.InteropServices
Imports System

Namespace OleCommandTarget
<StructLayout(LayoutKind.Sequential)> _
Public Structure OLECMDTEXT
Public cmdtextf As Long
Public cwActual As Long
Public cwBuf As Long
Public rgwz As Char
End Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure OLECMD
Public cmdID As Long
Public cmdf As Long
End Structure

<ComImport(), Guid("B722BCCB-4E68-101B-A2BC-00AA00404770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface IOleCommandTarget
<PreserveSig()> Function QueryStatus( _
<MarshalAs(UnmanagedType.Struct)> ByRef pguidCmdGroup As Guid, _
<MarshalAs(UnmanagedType.U4)> ByVal cCmds As Integer, _
ByRef prgcmds As Integer, _
ByRef pCmdText As Integer) As Integer

<PreserveSig()> Function Exec( _
ByRef pguidCmdGroup As Guid, _
ByVal nCmdID As Long, _
ByVal nCmdExecOpt As Long, _
ByVal pvaIn As Object(), _
<MarshalAs(UnmanagedType.LPArray)> ByVal pvaOut As Object()) As
Integer
End Interface
End Namespace


****************************************************************************
***********
Private Sub SendCommand()
Dim i As Integer
Const VISCMD_DRCONNECTORTOOL As Long =
VisUICmds.visCmdDRConnectionTool

Dim commandTarget As IOleCommandTarget
commandTarget = ADC1.GetOcx()

Try
Dim CLSID_Application As Guid
CLSID_Application = New Guid("{0x00021A20, 0x0000, 0x0000,
{0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}")
commandTarget.Exec(CLSID_Application, VISCMD_DRCONNECTORTOOL, 0,
Nothing, Nothing)
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top