Annotation of mstools/mfc/samples/tracer/tracer.cpp, revision 1.1

1.1     ! root        1: // tracer.cpp : MFC Windows trace control application
        !             2: //
        !             3: // This is a part of the Microsoft Foundation Classes C++ library.
        !             4: // Copyright (C) 1992 Microsoft Corporation
        !             5: // All rights reserved.
        !             6: //
        !             7: // This source code is only intended as a supplement to the
        !             8: // Microsoft Foundation Classes Reference and Microsoft
        !             9: // QuickHelp documentation provided with the library.
        !            10: // See these sources for detailed information regarding the
        !            11: // Microsoft Foundation Classes product.
        !            12: 
        !            13: #include <afxwin.h>
        !            14: 
        !            15: /////////////////////////////////////////////////////////////////////////////
        !            16: // Dialog class
        !            17: 
        !            18: class CPromptDlg : public CModalDialog
        !            19: {
        !            20:        BOOL    m_bEnabled;
        !            21:        UINT    m_flags;
        !            22: public:
        !            23:        CPromptDlg();
        !            24: 
        !            25:        void Save();
        !            26: 
        !            27:        BOOL OnInitDialog();
        !            28:        void OnOK();
        !            29: };
        !            30: 
        !            31: static char BASED_CODE szIniFile[] = "AFX.INI";
        !            32: static char BASED_CODE szDiagSection[] = "Diagnostics";
        !            33: 
        !            34: CPromptDlg::CPromptDlg()
        !            35:        : CModalDialog("PROMPT")
        !            36: {
        !            37:        m_bEnabled = ::GetPrivateProfileInt(szDiagSection, "TraceEnabled", 
        !            38:                FALSE, szIniFile);
        !            39:        m_flags = ::GetPrivateProfileInt(szDiagSection, "TraceFlags", 
        !            40:                0, szIniFile);
        !            41: }
        !            42: 
        !            43: void CPromptDlg::Save()
        !            44: {
        !            45:        char szT[32];
        !            46:        wsprintf(szT, "%d", m_bEnabled);
        !            47: 
        !            48:        if (!::WritePrivateProfileString(szDiagSection, "TraceEnabled", 
        !            49:                szT, szIniFile))
        !            50:        {
        !            51:                MessageBox("Unable to Write to Initialization File",
        !            52:                        "Tracer", MB_ICONEXCLAMATION);
        !            53:        }
        !            54: 
        !            55:        wsprintf(szT, "%d", m_flags);
        !            56:        if (!::WritePrivateProfileString(szDiagSection, "TraceFlags", szT, 
        !            57:                szIniFile))
        !            58:        {
        !            59:                MessageBox("Unable to Write to Initialization File",
        !            60:                        "Tracer", MB_ICONEXCLAMATION);
        !            61:        }    
        !            62: }
        !            63: 
        !            64: BOOL CPromptDlg::OnInitDialog()
        !            65: {
        !            66:        if (m_bEnabled)
        !            67:                ((CButton*)GetDlgItem(512))->SetCheck(TRUE);
        !            68: 
        !            69:        for (int i = 0; i < 5; i++)
        !            70:        {
        !            71:                CButton* pCheck = (CButton*)GetDlgItem(256 + i);
        !            72:                if (pCheck == NULL)
        !            73:                        break;      // no more checkboxes
        !            74:                if (m_flags & (1 << i))
        !            75:                        pCheck->SetCheck(TRUE);
        !            76:        }
        !            77:        return TRUE;
        !            78: }
        !            79: 
        !            80: void CPromptDlg::OnOK()
        !            81: {
        !            82:        m_bEnabled = ((CButton*)GetDlgItem(512))->GetCheck();
        !            83:        m_flags = 0;
        !            84: 
        !            85:        for (int i = 0; i < 5; i++)
        !            86:        {
        !            87:                CButton* pCheck = (CButton*)GetDlgItem(256 + i);
        !            88:                if (pCheck == NULL)
        !            89:                        break;      // no more checkboxes
        !            90:                if (pCheck->GetCheck())
        !            91:                        m_flags |= (1 << i);
        !            92:        }
        !            93:        EndDialog(IDOK);
        !            94: }
        !            95: 
        !            96: /////////////////////////////////////////////////////////////////////////////
        !            97: // Application class
        !            98: 
        !            99: class CTracerApp : public CWinApp
        !           100: {
        !           101: public:
        !           102:        virtual BOOL InitInstance();
        !           103: };
        !           104: 
        !           105: CTracerApp theTracerApp;
        !           106: 
        !           107: BOOL CTracerApp::InitInstance()
        !           108: {
        !           109:        CPromptDlg  dlg;
        !           110: 
        !           111:        if (dlg.DoModal() == IDOK)
        !           112:                dlg.Save();
        !           113: 
        !           114:        ::PostQuitMessage(0);       // Exit application
        !           115:        return TRUE;
        !           116: }
        !           117: 
        !           118: /////////////////////////////////////////////////////////////////////////////

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.