次の方法で共有


Visual Studio 2010 (Windows Forms Application): Working with the Visio 2010 control (Microsoft Office Visio 14.0 Drawing Control - 'AxInterop.Microsoft.Office.Interop.VisOcx.dll), and how to enable the hidden ‘Shapes’ pane

.

.

Where did the 'Shapes' pane disappear in the 2010 version of the Microsoft Office Visio 14.0 Drawing Control ?

 

   It seems that in the latest version (2010) of the 'VisOcx.dll' control, the left hand side
instruments panel does not show up anymore.

       I looked into this and tried to get some feedback from our Visio developers. According to their reply: yes, it is expected behavior. Having the 'Shapes' pane show-up by default was disabled, primarily because of the feedback we were receiving from the customers: on most instances when this control was used, the developers were programmatically adding all the needed shapes to the drawing canvas. The good news is that this feature can be re-enabled by code.

.

How to enumerate all the available hidden panes

   To demonstrate how can we list all the available Visio panes, we need to start with a new Visual Studio Windows Forms project and then we have to insert a reference to the Visio Interop class. Please note that in order for you to be able to use the Visio Control, you need to have the main application installed .. there is no stand-alone (redistributable) version available for VisOcx.dll.  

https://msdn.microsoft.com/en-us/library/ff765109.aspx

About Using the Visio Drawing Control in Your Application -------------------------------------------------------------------

To install the Visio Drawing Control, install Visio. When you install Visio, you can choose various installation options, including the Minimal Install option. If you want to minimize the installation file size of Visio on your computer, you can choose Minimal Install, which installs only the minimum required Visio components, including the Visio drawing application and the Visio Drawing Control. This

 

This code sniped will help you enumerate all the Visio Window components:

Dim wnd As Microsoft.Office.Interop.Visio.Window

For Each wnd InAxDrawingControl1.Window.Windows Debug.WriteLine(wnd.Caption & " / " & wnd.ID)Next

 

Output

========================================================================== Shape(Data ................................./ 1658Pan & Zoom ................................./ 1653Size & Position ............................/ 1670Shapes ...................................../ 1669 ............................................/ 2263 ............................................/ 1721External(Data) ............................./ 2044Basic Flowchart Shapes (Metric) ............/ 13503Cross-Functional Flowchart Shapes (Metric) ./ 13505

 

As you can see, the pane we are interested in has this ID: 1669.

You can use the VBA-style Debug.Print statement in a Visual Studio project to write to the Output window, if you add a reference to: System.Diagnostics.

            

The full code listing:

'==============================================================' * Please note that Microsoft provides programming ' * examples for illustration only, without' * warranty either expressed or implied, including, ' * but not limited to, the implied warranties ' * of merchantability and/or fitness ' * for a particular purpose. Any use by you of the code ' * provided in this blog is at your own risk. '===============================================================

Imports Microsoft.Office.Interop.VisioImports System.Windows.Forms Public Class Form1     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click         Dim dlg As New OpenFileDialog         dlg.DefaultExt = "*.vss"         If dlg.ShowDialog = DialogResult.OK Then   Me.AxDrawingControl1.Src = dlg.FileName  'MsgBox(Me.AxDrawingControl1.Controls.Count)    Dim wnd As Microsoft.Office.Interop.Visio.Window      For Each wnd In AxDrawingControl1.Window.Windows       Debug.WriteLine(wnd.Caption & " / " & wnd.ID)          Next   'Make the Shapes window wisible using it's ID    AxDrawingControl1.Window.Windows.ItemFromID(1669).Visible = True   Me.AxDrawingControl1.Document.OpenStencilWindow()End If End Sub End Class

For more information about working with the Microsoft Visio Drawing Control, please review this articles:

 > https://www.eggheadcafe.com/community/csharp/2/10295201/using-microsoft-office-visio-140-drawing-control-in-a-c-wpf-project.aspx (Using Microsoft Office Visio 14.0 Drawing Control in a C# WPF Project)
 > https://msdn.microsoft.com/en-us/magazine/cc164043.aspx (Host an Interactive Visio Drawing Surface in .NET Custom Clients)