Bagikan melalui


IDebugBoundBreakpoint2::Enable

Mengaktifkan atau menonaktifkan titik henti.

Sintaks

int Enable( 
    int fEnable
);

Parameter

fEnable
[di] Atur ke bukan nol (TRUE) untuk mengaktifkan atau ke nol (FALSE) untuk menonaktifkan titik henti.

Tampilkan Nilai

Jika berhasil, mengembalikan S_OK; jika tidak, mengembalikan kode galat. Mengembalikan E_BP_DELETED jika status objek titik henti terikat diatur ke BPS_DELETED (bagian dari enumerasi BP_STATE ).

Contoh

Contoh berikut menunjukkan cara menerapkan metode ini untuk objek sederhana CBoundBreakpoint yang mengekspos antarmuka 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;
}

Baca juga