mfc 枚举enum使用例子

enum EnAppState
{
ST_STARTING, ST_STARTED, ST_CONNECTING, ST_CONNECTED, ST_STOPPING, ST_STOPPED
};
SetAppState(ST_STOPPED);
void CServerDlg::SetAppState(EnAppState state)
{
m_enState = state;

if(this->GetSafeHwnd() == nullptr)
    return;

m_Start.EnableWindow(m_enState == ST_STOPPED);
m_Stop.EnableWindow(m_enState == ST_STARTED);
m_BindAddress.EnableWindow(m_enState == ST_STOPPED);
m_RejectAddress.EnableWindow(m_enState == ST_STOPPED);
m_DisConn.EnableWindow(m_enState == ST_STARTED && m_ConnID.GetWindowTextLength() > 0);

}

你可能感兴趣的:(MFC)