IVsFindTarget.SetFindState(Object) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the state of a find operation.
public:
int SetFindState(System::Object ^ pUnk);
public:
int SetFindState(Platform::Object ^ pUnk);
int SetFindState(winrt::Windows::Foundation::IInspectable const & pUnk);
public int SetFindState (object pUnk);
abstract member SetFindState : obj -> int
Public Function SetFindState (pUnk As Object) As Integer
- pUnk
- Object
[in] The state of the find operation.
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
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;
}
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.