IDebugBoundBreakpoint2::Enable
启用或禁用断点。
语法
参数
fEnable
[in]设置为非零(TRUE
)以启用或设置为零(FALSE
)以禁用断点。
返回值
如果成功,则返回 S_OK
;否则,返回错误代码。 返回E_BP_DELETED
绑定断点对象的状态是否设置为BPS_DELETED
(BP_STATE 枚举的一部分)。
示例
以下示例演示如何为公开 IDebugBoundBreakpoint2 接口的简单CBoundBreakpoint
对象实现此方法。
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;
}