Annotation of mstools/mfc/samples/minsvr/mainwnd.cpp, revision 1.1

1.1     ! root        1: // This is a part of the Microsoft Foundation Classes C++ library.
        !             2: // Copyright (C) 1992 Microsoft Corporation
        !             3: // All rights reserved.
        !             4: //
        !             5: // This source code is only intended as a supplement to the
        !             6: // Microsoft Foundation Classes Reference and Microsoft
        !             7: // QuickHelp documentation provided with the library.
        !             8: // See these sources for detailed information regarding the
        !             9: // Microsoft Foundation Classes product.
        !            10: 
        !            11: #include "minsvr.h"
        !            12: 
        !            13: /////////////////////////////////////////////////////////////////////////////
        !            14: 
        !            15: BEGIN_MESSAGE_MAP(CMainWnd, CFrameWnd)
        !            16:        // windows messages
        !            17:        ON_WM_CLOSE()
        !            18:        // menu commands
        !            19:        ON_COMMAND(IDM_UPDATE, OnUpdateClient)
        !            20:        ON_COMMAND(IDM_EXIT, OnClose)       // exit calls close
        !            21:        ON_COMMAND(IDM_CHANGESTRING, OnChangeString)
        !            22:        ON_COMMAND(IDM_ABOUT, OnAbout)
        !            23: END_MESSAGE_MAP()
        !            24: 
        !            25: /////////////////////////////////////////////////////////////////////////////
        !            26: // Basic creation etc
        !            27: 
        !            28: #pragma warning(disable:4355)   // this used in constructor
        !            29: 
        !            30: CMainWnd::CMainWnd() : m_server(this)
        !            31: {
        !            32:        CRect rect(0, 200, 200, 400);
        !            33: 
        !            34:        Create(NULL, SERVER_LOCAL_NAME,
        !            35:                WS_OVERLAPPEDWINDOW, rect, NULL, "MainMenu");
        !            36: }
        !            37: 
        !            38: /////////////////////////////////////////////////////////////////////////////
        !            39: 
        !            40: void CMainWnd::OnClose()
        !            41: {
        !            42:        // to shut-down, just revoke the server, OLE will terminate the app
        !            43:        m_server.BeginRevoke();
        !            44: }
        !            45: 
        !            46: /////////////////////////////////////////////////////////////////////////////
        !            47: // Edit menu commands
        !            48: 
        !            49: void CMainWnd::OnChangeString()
        !            50: {
        !            51:        if (m_server.m_doc.m_item.PromptChangeString())
        !            52:        {
        !            53:                // example of immediately updating client doc if open
        !            54:                // for more complicated data you shouldn't update until
        !            55:                //  the user selects the update menu
        !            56:                if (m_server.m_doc.IsOpen())
        !            57:                        OnUpdateClient();
        !            58:        }
        !            59: }
        !            60: 
        !            61: // Help menu commands
        !            62: void CMainWnd::OnAbout()
        !            63: {
        !            64:        CModalDialog dlg("AboutBox");
        !            65:        dlg.DoModal();
        !            66: }
        !            67: 
        !            68: 
        !            69: /////////////////////////////////////////////////////////////////////////////
        !            70: // Update Client
        !            71: 
        !            72: void CMainWnd::OnUpdateClient()
        !            73: {
        !            74:        TRY
        !            75:        {
        !            76:                m_server.m_doc.NotifySaved();
        !            77:        }
        !            78:        CATCH (CException, e)
        !            79:        {
        !            80:                MessageBox("Could not update client");
        !            81:        }
        !            82:        END_CATCH
        !            83: }
        !            84: 
        !            85: /////////////////////////////////////////////////////////////////////////////

unix.superglobalmegacorp.com

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