IVsFindTarget.SetFindState Method

Determines the state of a find operation.

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop (in Microsoft.VisualStudio.TextManager.Interop.dll)

Syntax

声明
Function SetFindState ( _
    pUnk As Object _
) As Integer
用法
Dim instance As IVsFindTarget
Dim pUnk As Object
Dim returnValue As Integer

returnValue = instance.SetFindState(pUnk)
int SetFindState(
    Object pUnk
)
int SetFindState(
    [InAttribute] Object^ pUnk
)
abstract SetFindState : 
        pUnk:Object -> int 
function SetFindState(
    pUnk : Object
) : int

Parameters

Return Value

Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsFindTarget::SetFindState(
   [in] IUnknown * punk
);

Find state is an opaque object held on behalf of the find engine. A C++ class in Visual Studio can use a smart pointer, or use the following code to manage the find state.

Examples

A C++ class in VS can use a smart pointer, or use the following code to manage the find state

// Declare the following member

IUnknown * m_pUnkFindState;

// In constructor's member-initialization-list:

m_pUnkFindState(NULL)

// In destructor or ATL FinalRelease():

if (m_pUnkFindState)

{

m_pUnkFindState->Release();

m_pUnkFindState = NULL;

}

//

// method implementations

//

HRESULT MyClass::SetFindState (IUnknown * punk)

{

if (m_pUnkFindState)

{

m_pUnkFindState->Release();

m_pUnkFindState = NULL;

}

if (punk)

{

punk->AddRef();

m_pUnkFindState = punk;

}

return S_OK;

}

HRESULT MyClass::GetFindState (IUnknown **ppunk)

{

*ppunk = m_pUnkFindState;

if (m_pUnkFindState)

m_pUnkFindState->AddRef();

return S_OK;

}

.NET Framework Security

See Also

Reference

IVsFindTarget Interface

IVsFindTarget Members

Microsoft.VisualStudio.TextManager.Interop Namespace