Share via


ATLPages Sample: Implements a Property Page Using IPropertyPageImpl

The ATLPages sample demonstrates the implementation of a property page using IPropertyPageImpl.

This sample consists of:

  • A property page class, CDocumentProperties, that uses the EnvDTE::Documentinterface to display (and allow changes to) the properties of a text document.

  • A helper component, CHelper, that exposes a simplified wrapper to the OleCreatePropertyFrame API to scripting languages.

  • A simple test macro, Test in the ATLPages.vsmacros project, that uses the helper to display the property page for the active document within the Visual C++ editor.

Security noteSecurity Note

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

Building and Running the Sample

To run the sample, you need to build the solution and then run the test macro.

To build this sample

  1. Open the solution file ATLPages7.sln.

  2. From the Build menu, click Build Solution.

To run the macro

  1. Open a text document in the editor. For example, open one of the source files for the ATLPages sample.

  2. From the Tools menu, point to Macros and then click Macro Explorer. This will open the Macro Explorer window.

  3. From the Tools menu, point to Macros and then click Load Macro Project. This will open the Add Macro Project dialog box.

  4. Browse to the location of the ATLPages.vsmacros file (it's in the same folder as the ATLPages sample) and click the Open button. This action will load the macros file and it will appear in the Macro Explorer.

  5. Expand the ATLPages node and double-click the Test macro.

    If no text document is open when you run the macro, it does nothing. If a document is open, a property page for that document will be displayed indicating the name of the file and its read-only status. You can change either of these items. Your changes will be applied when you click the Apply or OK button. Changing the name of the file will cause the file to be saved to disk under the new name. Changing the read-only status of the file affects whether the file can be changed within the Visual C++ editor (it doesn't affect the read-only attribute of the file on disk).

    Note

    Changing the read-only property of files under source code control is not possible using this property page.

Keywords

This sample uses the following keywords:

IPropertyPage, IPropertyPageImpl, OleCreatePropertyFrame, IPropertyPage::SetObjects, IPropertyPage::Activate, IPropertyPage::Apply, EnvDTE

See Also

Other Resources

ATL Samples