IDebugDocumentContext2::EnumCodeContexts
이 문서 컨텍스트와 관련 된 모든 코드 컨텍스트 목록을 검색 합니다.
HRESULT EnumCodeContexts(
IEnumDebugCodeContexts2** ppEnumCodeCxts
);
int EnumCodeContexts(
out IEnumDebugCodeContexts2 ppEnumCodeCxts
);
매개 변수
- ppEnumCodeCxts
[out] 반환 된 IEnumDebugCodeContexts2 코드 컨텍스트 목록을 포함 하는 개체입니다.
반환 값
성공 하면 반환 S_OK. 그렇지 않으면 오류 코드를 반환 합니다.
설명
단일 문서 컨텍스트 문서 서식 파일을 사용할 때 여러 코드 컨텍스트를 생성 하거나 파일을 포함할 수 있습니다.
예제
다음 예제에서는 단순에이 메서드를 구현 하는 방법을 보여 줍니다. CDebugContext 를 노출 하는 개체는 IDebugDocumentContext2 인터페이스입니다.
HRESULT CDebugContext::EnumCodeContexts(IEnumDebugCodeContexts2 **ppEnumCodeCxts)
{
HRESULT hr;
// Check for a valid IEnumDebugCodeContexts2 interface pointer.
if (ppEnumCodeCxts)
{
*ppEnumCodeCxts = NULL;
// Create a CEnumDebugCodeContexts object.
CComObject<CEnumDebugCodeContexts>* pEnum;
hr = CComObject<CEnumDebugCodeContexts>::CreateInstance(&pEnum);
assert(hr == S_OK);
if (hr == S_OK)
{
// Get an IID_IDebugCodeContext2 interface.
CComPtr<IDebugCodeContext2> spCodeCxt;
hr = QueryInterface(IID_IDebugCodeContext2,
(void**)&spCodeCxt);
assert(hr == S_OK);
if (hr == S_OK)
{
// Initialize the code context enumerator with the
// IDebugCodeContext2 information.
IDebugCodeContext2* rgpCodeContext[] = { spCodeCxt.p };
hr = pEnum->Init(rgpCodeContext,
&(rgpCodeContext[1]),
NULL,
AtlFlagCopy);
assert(hr == S_OK);
if (hr == S_OK)
{
// Set the passed IEnumDebugCodeContexts2 pointer equal to the pointer
// value of the created CEnumDebugCodeContexts object.
hr = pEnum->QueryInterface(ppEnumCodeCxts);
assert(hr == S_OK);
}
}
// Otherwise, delete the CEnumDebugCodeContexts object.
if (FAILED(hr))
{
delete pEnum;
}
}
}
else
{
hr = E_INVALIDARG;
}
return hr;
}