Export (0) Print
Expand All

Basic Edit Sample

Visual Studio 2005
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

The Basic Edit sample implements a standard (file-based) editor for rich text (.rtf) files.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.  Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

Building the Sample

To build this sample

  1. Start Visual Studio. Type devenv.exe at the command line.

  2. Open the BscEdt.sln file in Visual Studio .NET.

  3. On the Build menu, choose Rebuild Solution.

  4. Run devenv.exe /setup /rootsuffix exp to merge command bars and other UI items.

    devenv.exe /setup /rootsuffix exp

Running the Sample

Upon installation of this sample, an .rtf file is available for use with this sample. Use the following procedure to access the .rtf file and run the sample.

To run this sample

  1. Start Visual Studio using the experimental build by typing devenv.exe /rootsuffix exp at the command line.

  2. On the File menu, choose New, and then choose File. Click the Basic Editor Files. A customized toolbar with text formatting options is displayed in the open Basic Edit file.

Once you have built the sample, you can use the following:

  • Standard editor

  • Editor Factory

  • Macro Recording

  • Find and Replace

  • Simple object model exposure

  • Rich edit control for low-level .rtf file editing

The following table lists the interfaces implemented by the Basic Edit sample.

Implemented Interfaces

IBscEdt (Object Model)

IDataObject (In-place activation implementation only)

IDispatch (Object Model)

IOleCommandTarget

IOleInPlaceActiveObject (In-place activation implementation only)

IOleInPlaceComponent (In-place activation implementation only)

IOleInPlaceComponentSite (In-place activation implementation only)

IOleInPlaceObject (In-place activation implementation only)

IOleInPlaceObjectWindowless (In-place activation implementation only)

IOleObject (In-place activation implementation only)

IPersistFileFormat

ISelectionContainer

IVsDocDataFileChangeControl

IVsEditorFactory

IVsExtensibleObject

IVsFileChangeEvents

IVsFindTarget

IVsPackage

IVsPersistDocData

IVsStatusbarUser

IVsToolboxUser

IVsWindowPane (Simplified embedding implementation only)

The following table lists the interfaces called in the Basic Edit sample and their associated services.

The following table lists the important files used when implementing Basic Edit.

File name Description

VsPkg.cpp

Standard IVsPackage implementation in CBscEdtPackage object

Editor.cpp

Representation of the editor

EdtFact.cpp

Implementation of an editor factory

VsPkg.rgs

Registers the VSPackage along with its menus, commands, and editor factory

Robust Programming

A standard editor saves its data in a file and implements a standard set of interfaces (IVsEditorFactory and IVsPersistDocData2) that allows it to be used with any project that works with files. For more information, see Types of Editors. The Basic Edit sample demonstrates two methods for implementing a standard editor—in-place activation and simplified embedding.

In-place activation supports extensive document handling, window handling, and OLE functionality, including command routing and handling and is used for hosting ActiveX controls. In the Basic Edit sample, implementation of in-place activation of an ActiveX document object is demonstrated using IDataObject and associated interfaces on the CBscEditorDocument object. In a simplified embedding implementation, the HWND of the document view object is parented to the Visual Studio HWND and IVsWindowPane is implemented to support handling window commands. A simplified embedding implementation is also demonstrated in this sample.

In addition to providing two types of editors, the Basic Edit sample also demonstrates using an editor factory (that is, IVsEditorFactory), macro recording, and find and replace functionality.

NoteNote

The default location for the Basic Edit sample is <drive>:\Program Files\Visual Studio 2005 SDK\<build number>\VisualStudioIntegration\Unsupported\BscEdt\BscEdt.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.  Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft