共用方式為


IDebugBoundBreakpoint2::Enable

 

如需 Visual Studio 2017 的最新文件請參閱 Visual Studio 2017 文件

啟用或停用中斷點。

語法

HRESULT Enable(   
   BOOL fEnable  
);  
int Enable(   
   int fEnable  
);  

參數

fEnable
[in]設定為非零 (TRUE) 若要啟用,或為零 (FALSE) 若要停用中斷點。

傳回值

如果成功,傳回S_OK; 否則傳回錯誤碼。 傳回E_BP_DELETED如果繫結的中斷點物件的狀態設定為BPS_DELETED(屬於BP_STATE列舉型別)。

範例

下列範例示範如何實作這種簡單的方式CBoundBreakpoint公開物件IDebugBoundBreakpoint2介面。

HRESULT CBoundBreakpoint::Enable(BOOL fEnable)    
{    
   HRESULT hr;    
  
   // Verify that the bound breakpoint has not been deleted. If deleted,   
   // then return hr = E_BP_DELETED.    
   if (m_state != BPS_DELETED)    
   {    
      // Check the state of the bound breakpoint. If the breakpoint is  
      // supposed to be, but has not already been, enabled, then have the  
      // interpreter set the breakpoint.    
      if (fEnable && m_state != BPS_ENABLED)    
      {    
         hr = m_pInterp->SetBreakpoint(m_sbstrDoc, this);    
         if (hr == S_OK)    
         {    
            // Change the state of the breakpoint to BPS_ENABLED.    
            m_state = BPS_ENABLED;    
         }    
      }    
      // Check the state of the bound breakpoint. If the breakpoint is   
      // supposed to be, but has not already been, disabled, then have the   
      // interpreter remove the breakpoint.    
      else if (!fEnable && m_state != BPS_DISABLED)    
      {    
         hr = m_pInterp->RemoveBreakpoint(m_sbstrDoc, this);    
         if (hr == S_OK)    
         {    
            // Change the state of the breakpoint to BPS_DISABLED.    
            m_state = BPS_DISABLED;    
         }    
      }    
      else    
      {    
         hr = S_FALSE;    
      }    
   }    
   else    
   {    
      hr = E_BP_DELETED;    
   }    
  
   return hr;    
}    

另請參閱

IDebugBoundBreakpoint2
BP_STATE