Dela via


Properties Window Fields and Interfaces

The model for selection to determine what information is displayed in the Properties window is based on the window that has focus in the IDE. Every window, and object within the selected window, can have its selection context object pushed to the global selection context. The environment updates the global selection context with values from a window frame when that window has the focus. When the focus changes, so does the selection context.

Tracking Selection in the IDE

The window frame or site, owned by the IDE, has a service called STrackSelection. The following steps show how a change in a selection, caused by the user either changing focus to another open window or selecting a different project item in Solution Explorer, is implemented to change the content displayed in the Properties window.

  1. The object created by your VSPackage that is sited in the selected window calls QueryService to have STrackSelection invoke ITrackSelection.

  2. The selection container, provided by the selected window, creates its own ISelectionContainer object. When the selection changes, the VSPackage calls OnSelectChange to notify any listeners in the environment, including the Properties window, of the change. It also provides access to hierarchy and item information related to the new selection.

  3. Calling OnSelectChange and passing it the selected hierarchy items in the VSHPROPID_BrowseObject parameter populates the ISelectionContainer object.

  4. An object derived from the IDispatch Interface [Automation] is returned for VSHPROPID_BrowseObject for the item requested, and the environment wraps it into an ISelectionContainer (see the following step). If the call fails, the environment makes a second call to IVsHierarchy::GetProperty, passing it the selection container VSHPROPID_SelContainer that the hierarchy item or items supply.

    Your project VSPackage does not create ISelectionContainer because the environment-supplied window VSPackage that implements it (for example, Solution Explorer) constructs ISelectionContainer on its behalf.

  5. The environment invokes the methods of ISelectionContainer to get the objects based on the IDispatch interface to fill in the Properties window.

When a value in the Properties window is changed, VSPackages implement IVsTrackSelectionEx::OnElementValueChangeEx and IVsTrackSelectionEx::OnSelectionChangeEx to report the change to the element value. The environment then invokes IVsUIShell or IConnectionPointContainer to keep the information displayed in the Properties window synchronized with the property values. For more information, see How to: Update Property Values in the Properties Window.

In addition to selecting a different project item in Solution Explorer to display properties related to that item, you can also choose a different object from within a form or document window using the drop-down list available on the Properties window. For more information, see Properties Window Object List.

You can change the way information is displayed in the Properties window grid from alphabetical to categorical, and, if available, you can also open a property page for a selected object by clicking the appropriate buttons on the Properties window. For more information, see Properties Window Buttons and Property Pages.

Finally, the bottom of the Properties window also contains a description of the field selected in the Properties window grid. For more information, see How to: Retrieve Properties Window Field Descriptions.

See Also

Other Resources

Properties Window and Property Pages