Microsoft KB Archive/242291

= INFO: GetResultView Event Does Not Fire As Expected =

Article ID: 242291

Article Last Modified on 3/20/2004

-

APPLIES TO


 * Microsoft Management Console 1.1
 * Microsoft Management Console 1.2
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q242291



SUMMARY
The documentation for the MMC SnapIn Designer for Visual Basic states that if the GetResultViewInfo event is not implemented, then the GetResultView event fires to allow the SnapIn to reuse a cached result view. However, the GetResultView event only fires if a result view for the selected scope pane item has been cached through the ResultView_Deactivate event.



MORE INFORMATION
The following sample demonstrates the event sequence for the following three events:


 * 1) ResultView_Deactivate
 * 2) ScopePaneItems_GetResultView
 * 3) ScopePaneItems_GetResultViewInfo

Steps To Reproduce
 Start Visual Basic and select a new SnapIn project from the New Project dialog box. Open the Snapin1 Designer and add a new URL view under the static node. By default this new URL view is named URLView1. View the properties of URL view1, and set the URL field to a valid address (http://example.microsoft.com/) and click Ok. View the properties of the static node and set the default view to URLView1 and click Ok.  Open the code window for the Snapin1 Designer, and then paste in the following code: Private Sub ResultViews_Deactivate(ByVal ResultView As SnapInLib.ResultView, Keep As Boolean) Keep = True End Sub

Private Sub ScopePaneItems_GetResultView(ByVal ScopePaneItem As SnapInLib.ScopePaneItem, Index As Variant) ScopePaneItem.ResultView = ScopePaneItem.ResultViews(1) End Sub

Private Sub ScopePaneItems_GetResultViewInfo(ByVal ScopePaneItem As SnapInLib.ScopePaneItem, ViewType As SnapInLib.SnapInResultViewTypeConstants, DisplayString As String) ScopePaneItem.ResultViewType = siURLView End Sub  Set breakpoints in all three events and start the project in the debugger. Load the SnapIn into MMC. When the SnapIn loads, select the SnapIn1 scope item. The debugger breaks in the ScopePaneItems_GetResultViewInfo event handler. Press F5 to continue code execution.</li> Click off the SnapIn1 scope item, and the debugger breaks in the ResultViews_Deactivate event handler. Note that the keep property is set to True. This indicates that this result view will be cached, and the ScopePaneItems_GetResultView will be fired the next time the Result View is needed. Press F5 to continue code execution</li> Click back on the SnapIn1 scope item, the debugger breaks in the ScopePaneItems_GetResultViewInfo event handler again. This time step through the code using the F8 key, and note that the ScopePaneItems_GetResultView event is handled.</li> Stop the SnapIn and comment out the ResultViews_Deactivate event handler.</li> Run the project again, and follow the above steps. Note that the ScopePaneItems_GetResultView event is never fired.</li></ol>

<div class="references_section">