Volume 3: Programming with the Visio Object Model disclaimer


Lab 3.8: Using the Visio Drawing Control



Download 0.78 Mb.
Page34/36
Date29.01.2017
Size0.78 Mb.
#11974
1   ...   28   29   30   31   32   33   34   35   36

Lab 3.8: Using the Visio Drawing Control


The ScheduleBuilder solution from the previous labs has been ported to a Visual Studio 2005 application that uses the Visio 2010 Drawing Control.

During this lab, you will make modifications to the application to enrich the functionality presented.

Estimated time to complete this lab: 60 minutes

Before You Begin

To complete this lab, you will need:

  • Participants should have completed the lessons within this module before completing this lab.

  • Visio 2010 installed and configured.

  • Visual Studio 2005 installed and configured.

  • All files from folder Labs\Vol3\Schedule Builder Start

  • All files from folder Labs\Vol3\Schedule Builder Finished

    • These files present a completed solution for the lab
What You Will Learn

After completing this lab, you will be able to:

  • Set the document Src property

  • Control windows in the Visio environment using the drawing control

  • Add menus and call procedures in the container application

  • Save the document to a Visio file

58.Exercise : Set the Src property of the document and display the External Data window

Scenario


Depending on where you placed the Lab files on your machine, you will likely get an error when you first start the application because the path to the Visio drawing being loaded is incorrect. You will fix that in this step.

Tasks


  1. Open the Visual Studio 2005 project Labs\Schedule Builder Start\ScheduleBuilder.sln

  2. Choose Debug > Start Debugging. The program will stop with an error when trying to set the Src property of the document.

  3. Correct the path and continue.

  4. The External Data window is turned off. Find the code that keeps the window off and make it visible.

59.Exercise 2: Add menus to place and delete Sections

Scenario


Add menus to access functions to Delete Selection Shapes, Drop Section Shapes, and Place Selected Shapes. These were all macros in the VBA version of this solution and have been ported to the Windows Form application containing the drawing control.

Tasks


  1. Display Form1.vb in design mode.

  2. Add a second top level menu item call ScheduleBuilder

  3. Add 3 menu items under ScheduleBuilder

    1. Delete Section Shapes

    2. Drop Section Shapes

    3. Place Selected Shapes

  4. Display Form1.vb (code view)

    1. In the objects drop down list at the top of the form choose DropSectionShapesToolStripMenuItem

    2. In the events drop down choose the Click event. This will stub in the event procedure for this menu

    3. Add the code

Document.DropSectionShapes()

This calls the DropSectionShapes procedure in the module ScheduleDocument.vb



  1. Add the Click event procedures for the other two menus. The procedures to call are in ScheduleDocument.vb

  2. Try out the code. You will find that the Delete Section Shapes does not delete the shapes properly. Fix this error.

60.Exercise 3: Add SaveAs menu

Scenario


To save the drawing you will need to add a SaveAs menu.

Tasks


  1. Display Form1.vb in design mode.

  2. Under the File menu insert a new menu before Exit and name it SaveAs

  3. In the code view of the form add the Click event for this menu

  4. Add the code for the SaveAs. Look back at the sample code in this module for an example.



Additional Resources – Drawing Control

Programming with the Microsoft Office Visio 2003 ActiveX Control

Learn to integrate the Microsoft® Office Visio® 2003 ActiveX® Control, also referred to as the Visio drawing control, into applications. Review best practices and how to use the Visio drawing control programmatically. (24 printed pages)

http://msdn2.microsoft.com/en-us/library/aa168480(office.11).aspx



Dev Luv: Top Ten Things to Know When Using the Visio 2003 ActiveX Control

Mai-lan's Visio Blog

This is a good summary blog on common things that can trip you up when using the drawing control.

http://blogs.msdn.com/mailant/archive/2004/09/24/233928.aspx

Drawing Visio Shapes in the Visio ActiveX Control using C# and .NET

A sample program from Mike Gold to help you get started using the ActiveX Drawing Control.

http://www.c-sharpcorner.com/UploadFile/mgold/VisioInDotNet12032006222024PM/VisioInDotNet.aspx



About Using the Visio Drawing Control in Your Application [Visio 2003 SDK Documentation]

Using this control, you can embed the full functionality of the Visio drawing surface into your applications. You can take advantage of the full Visio object model (API) and you can pick the aspects of the Visio user interface you want to expose to better integrate Visio seamlessly into the user interface of your application.

http://msdn2.microsoft.com/en-us/library/aa173510(office.11).aspx



Integrating Menus and Toolbars in Visio 2003 Drawing Control Applications

You can choose from several approaches when integrating Visio menus and toolbars in your applications that host the Visio drawing control. This article walks you through a sample application demonstrating these approaches, including the use of the IOleCommandTarget interface. (13 printed pages)

http://msdn2.microsoft.com/en-us/library/aa192480(office.11).aspx



Visio 2007: Bug in Drawing Control

Bill Morein's Weblog

There is a bug in the Visio 2007 Drawing Control such that if you have the SRC property set and add a new page (either through the UI or through code), Visio crashes.

http://blogs.msdn.com/wmorein/archive/2007/01/26/visio-2007-bug-in-drawing-control.aspx

Host an Interactive Visio Drawing Surface in .NET Custom Clients

Microsoft Office Visio 2003 introduces a new drawing component that allows you to embed an interactive drawing surface into your application's user interface. You can drive the Visio drawing component from events in your host application or with data from a Web Service and an ADO.NET data adapter. The Visio drawing component supports the rich Visio application programming model, giving you control over how graphics are used and displayed on the drawing surface. This article explains how to embed the Visio drawing component into a C#-based Windows Forms client app that retrieves data from the Fabrikam 2.0 Web Service.

http://msdn.microsoft.com/msdnmag/issues/03/12/Visio2003/





Download 0.78 Mb.

Share with your friends:
1   ...   28   29   30   31   32   33   34   35   36




The database is protected by copyright ©ininet.org 2024
send message

    Main page