共用方式為


IDebugDocumentContext2::GetStatementRange

Gets the file statement range of the document context.

HRESULT GetStatementRange( 
   TEXT_POSITION* pBegPosition,
   TEXT_POSITION* pEndPosition
);
int GetStatementRange( 
   TEXT_POSITION[] pBegPosition,
   TEXT_POSITION[] pEndPosition
);

Parameters

  • pBegPosition
    [in, out] A TEXT_POSITION structure that is filled in with the starting position. Set this argument to a null value if this information is not needed.

  • pEndPosition
    [in, out] A TEXT_POSITION structure that is filled in with the ending position. Set this argument to a null value if this information is not needed.

Return Value

If successful, returns S_OK; otherwise, returns an error code.

Remarks

A statement range is the range of the lines that contributed the code to which this document context refers.

To obtain the range of source code (including comments) within this document context, call the IDebugDocumentContext2::GetSourceRange method.

Example

The following example shows how to implement this method for a simple CDebugContext object that exposes the IDebugDocumentContext2 interface. This example fills in the ending position only if the beginning position is not a null value.

HRESULT CDebugContext::GetStatementRange(TEXT_POSITION* pBegPosition,
                                         TEXT_POSITION* pEndPosition)  
{  
   HRESULT hr;  
  
   // Check for a valid beginning position argument pointer.  
   if (pBegPosition)  
   {  
      // Copy the member TEXT_POSITION into the local pBegPosition.  
      memcpy(pBegPosition, &m_pos, sizeof (TEXT_POSITION));  
        
      // Check for a valid ending position argument pointer. 
     if (pEndPosition)  
      {  
         // Copy the member TEXT_POSITION into the local pEndPosition.  
         memcpy(pEndPosition, &m_pos, sizeof (TEXT_POSITION));  
      }  
      hr = S_OK;  
   }  
   else  
   {  
      hr = E_INVALIDARG;  
   }  
  
   return hr;  
}  

See Also

Reference

IDebugDocumentContext2

IDebugDocumentContext2::GetSourceRange

TEXT_POSITION