home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK11 / MFC / SAMPLES / TESTSERV / TESTSERV.CP$ / testserv
Encoding:
Text File  |  1992-03-19  |  14.8 KB  |  718 lines

  1. // testserv.cpp : This file contains code which implements functions
  2. // specific to the Test Server application.
  3. //
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and Microsoft
  10. // QuickHelp documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14.  
  15. #include "testserv.h"
  16. #include "resource.h"
  17. #include "defs.h"
  18.  
  19. extern void OutputLog(const char *pText);
  20. extern LPSTR CreateNewUniqueName(LPSTR lpstr);
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. //  GLOBALS
  24. //
  25. BOOL GLOBAL_bRegisterDoc, GLOBAL_bNoDisplay, GLOBAL_bEmbedded;
  26. BOOL CTestServer::m_bCreationFailed = FALSE;
  27. UINT GLOBAL_uNativeFormat, GLOBAL_uOwnerFormat, GLOBAL_uObjectFormat;
  28. CString GLOBAL_szFileName;
  29. CStdioFile *pOleDump;
  30. CTestApp app;
  31. static CNewServer* GLOBAL_pServer;
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CTestServer::CTestServer()
  35. //
  36. CTestServer::CTestServer()
  37. {
  38.     m_bDirty = FALSE;
  39.     m_bLogging = FALSE;
  40.     m_bUntitled = TRUE;
  41.     m_pItem = NULL;
  42.  
  43.     VERIFY(Create(NULL, "Test Server",
  44.         WS_OVERLAPPEDWINDOW, rectDefault, NULL, "MainMenu"));
  45.  
  46.     if (m_bCreationFailed)
  47.     {
  48.         TRACE("CTestServer::CTestServer : OnCreate failed\n");
  49.         if (m_pDoc->IsOpen())
  50.         {
  51.             m_pDoc->BeginRevoke();
  52.         }
  53.         DestroyWindow();
  54.     }
  55. }
  56.  
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CTestServer::OnCreate(LPCREATESTRUCT p)
  60. //
  61. int CTestServer::OnCreate(LPCREATESTRUCT p)
  62. {
  63.     // suppress 'unused formal parameter' warnings
  64.  
  65.     (void) p;
  66.  
  67.     CRect rect;
  68.     GetClientRect(&rect);
  69.  
  70.     m_pList = new CListBox();
  71.     if (!m_pList->Create(WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_VSCROLL | 
  72.         LBS_STANDARD | LBS_USETABSTOPS, rect, this, IDC_LIST))
  73.     {
  74.         TRACE("Error creating listbox\n");
  75.         return -1;
  76.     }
  77.  
  78.     m_pList->SetTabStops(40);
  79.  
  80.     TRY
  81.     {
  82.  
  83.         m_pServer = GLOBAL_pServer;
  84.  
  85.         // if we are being instantiated directly, go ahead and create the
  86.         // document and register it as an untitled.
  87.  
  88.         m_pDoc = new CServDoc("Untitled");
  89.  
  90.         if (GLOBAL_bRegisterDoc)
  91.         {
  92.             if (!m_pDoc->Register(m_pServer, GLOBAL_szFileName))
  93.             {
  94.                 m_bCreationFailed = TRUE;
  95.                 return 0;
  96.             }
  97.             m_szFileName = GLOBAL_szFileName;
  98.  
  99.             if (!LoadFile(m_szFileName))
  100.             {
  101.                 TRACE("CTestServer::OnCreate : LoadFile failed.\n");
  102.                 m_bCreationFailed = TRUE;
  103.                 return 0;
  104.             }
  105.  
  106.             m_pItem->m_pOwner = this;
  107.             m_bUntitled = FALSE;
  108.         }
  109.  
  110.         if (!GLOBAL_bEmbedded)
  111.         {
  112.             TRACE("Registering Server for Non Embedded\n");
  113.             if (!m_pDoc->Register(m_pServer, "Untitled"))
  114.             {
  115.                 m_bCreationFailed = TRUE;
  116.                 return 0;
  117.             }
  118.         }
  119.     }
  120.     CATCH (COleException, e)
  121.     {
  122.         MessageBox ("Registrations Didn't Work","Test Server",
  123.             MB_ICONEXCLAMATION);
  124.     }
  125.     END_CATCH
  126.  
  127.     return 0;
  128. }
  129.  
  130.  
  131.  
  132. /////////////////////////////////////////////////////////////////////////////
  133. // CTestServer::OnInitMenu(CMenu* pMenu)
  134. //
  135.  
  136. void CTestServer::OnInitMenu(CMenu* pMenu)
  137. {
  138.     CMenu *myMenu;
  139.     myMenu = GetMenu();
  140.  
  141.     if (myMenu != pMenu)
  142.     {
  143.         return;
  144.     }
  145.  
  146.     // Set up file menus
  147.     if ((GLOBAL_bRegisterDoc) || (m_pItem != NULL))
  148.     {
  149.         pMenu->EnableMenuItem(IDM_SAVE, MF_ENABLED);
  150.         pMenu->EnableMenuItem(IDM_SAVEAS, MF_ENABLED);
  151.         pMenu->EnableMenuItem(IDM_COPYLINK, MF_ENABLED);
  152.         pMenu->EnableMenuItem(IDM_COPYOBJECT, MF_ENABLED);
  153.     }
  154.     else
  155.     {
  156.         pMenu->EnableMenuItem(IDM_SAVE, MF_DISABLED | MF_GRAYED);
  157.         pMenu->EnableMenuItem(IDM_SAVEAS, MF_DISABLED | MF_GRAYED);
  158.         pMenu->EnableMenuItem(IDM_COPYLINK, MF_DISABLED | MF_GRAYED);
  159.         pMenu->EnableMenuItem(IDM_COPYOBJECT, MF_DISABLED | MF_GRAYED);
  160.     }   
  161.  
  162.     if ((m_pItem != NULL) && (m_pItem->IsConnected()))
  163.     {
  164.         pMenu->EnableMenuItem(IDM_CLOSEDOC, MF_ENABLED);
  165.         pMenu->EnableMenuItem(IDM_CHANGEDOC, MF_ENABLED);
  166.         pMenu->EnableMenuItem(IDM_CHANGEITEM, MF_ENABLED);
  167.     }
  168.     else
  169.     {
  170.         pMenu->EnableMenuItem(IDM_CLOSEDOC, MF_DISABLED | MF_GRAYED);
  171.         pMenu->EnableMenuItem(IDM_CHANGEDOC, MF_DISABLED | MF_GRAYED);
  172.         pMenu->EnableMenuItem(IDM_CHANGEITEM, MF_DISABLED | MF_GRAYED);
  173.     }
  174.  
  175.  
  176.     // Don't allow copying links unless the file has been saved
  177.     if (!m_szFileName.IsEmpty())
  178.     {
  179.         pMenu->EnableMenuItem(IDM_COPYLINK, MF_ENABLED);
  180.     }
  181.     else
  182.     {
  183.         pMenu->EnableMenuItem(IDM_COPYLINK, MF_DISABLED | MF_GRAYED);
  184.     }
  185.  
  186.  
  187.     // Don't allow calling CloseDocApi if Embedded will cause problems.
  188.     // do it through the normal route.
  189.     if (GLOBAL_bEmbedded && !GLOBAL_bRegisterDoc)
  190.     {
  191.         pMenu->EnableMenuItem(IDM_CLOSEDOC, MF_DISABLED | MF_GRAYED);
  192.     }
  193.  
  194.     CMenu *pTestMenu;
  195.  
  196.     // pTestMenu is the Test submenu and should be position 2
  197.     pTestMenu = pMenu->GetSubMenu(2);
  198.     ASSERT (pTestMenu != NULL);
  199.  
  200.     // Disable/Enable Test/Document/Server API Popup Menu
  201.     if ((m_pDoc != NULL) && (m_pDoc->IsOpen()))
  202.     {
  203.         pTestMenu->EnableMenuItem(2, MF_ENABLED | MF_BYPOSITION);
  204.         pTestMenu->EnableMenuItem(3, MF_ENABLED | MF_BYPOSITION);
  205.  
  206.     }
  207.     else
  208.     {
  209.         pTestMenu->EnableMenuItem(2, MF_DISABLED | MF_GRAYED | MF_BYPOSITION);
  210.         pTestMenu->EnableMenuItem(3, MF_DISABLED | MF_GRAYED | MF_BYPOSITION);
  211.     }
  212. }
  213.  
  214.     
  215.  
  216.  
  217.  
  218.  
  219. /////////////////////////////////////////////////////////////////////////////
  220. // CTestServer::OnSize()
  221. //
  222. void CTestServer::OnSize(UINT nType, int cx, int cy)
  223. {
  224.     CRect listRect;
  225.     GetClientRect(&listRect);
  226.  
  227.     m_pList->MoveWindow(listRect,TRUE);
  228.     CFrameWnd::OnSize(nType, cx, cy);
  229. }
  230.  
  231.  
  232.  
  233. /////////////////////////////////////////////////////////////////////////////
  234. // CTestServer::OnNew()
  235. //
  236. void CTestServer::OnNew()
  237. {
  238.     char szBuf[80];
  239.     int nResponse;
  240.     ASSERT_VALID (this);
  241.  
  242.     // if any object is currently around, ask to save it
  243.  
  244.     if (m_bDirty)
  245.     {
  246.         nResponse = MessageBox("Save changes to file?","Test Server", 
  247.             MB_YESNOCANCEL | MB_ICONQUESTION);
  248.  
  249.         if (nResponse == IDCANCEL)
  250.         {
  251.             return;     // user selected CANCEL
  252.         }
  253.  
  254.         if (nResponse == IDYES)
  255.         {
  256.             SaveFile(m_bUntitled);
  257.         }
  258.     }
  259.  
  260.     TRY
  261.     {
  262.         if ((m_pDoc != NULL) && (m_pDoc->IsOpen()))
  263.         {
  264.             m_pDoc->Revoke();       // will revoke CServItem as well
  265.         }
  266.  
  267.         // delete off old objects as they are useless.  Deleting the
  268.         // document will also delete the item since it is embedded.
  269.         delete m_pDoc;
  270.  
  271.         // clean up pointers
  272.         m_pDoc = NULL;
  273.         m_pItem = NULL;
  274.  
  275.         m_pDoc = new CServDoc("Untitled");
  276.  
  277.         if (!m_pDoc->Register(m_pServer, "Untitled"))
  278.         {
  279.             AfxThrowOleException(OLE_ERROR_REGISTRATION);
  280.         }
  281.  
  282.         m_pItem = new CServItem(this, m_pDoc, "Untitled", 
  283.             CreateNewUniqueName(szBuf));
  284.         m_bUntitled = TRUE;
  285.         m_pDoc->m_pItem = m_pItem;      // set document's item to this one
  286.         m_pItem->m_pOwner = this;
  287.         CEditObjectDlg editObject(this, m_pItem->m_Text);
  288.  
  289.         if (editObject.DoModal() == IDOK)
  290.         {
  291.             m_pItem->m_Text = editObject.m_Text;
  292.         }
  293.         m_pList->ResetContent();
  294.         m_pList->AddString(m_pItem->m_Text);
  295.         SetWindowText((LPCSTR)AfxGetAppName());
  296.     }
  297.     CATCH(CException, e)
  298.     {
  299.         MessageBox("Unable to perform file new.  Please exit program.",
  300.             "Test Server", MB_ICONEXCLAMATION);
  301.  
  302.         if (m_pDoc)
  303.         {
  304.             delete m_pDoc;
  305.         }
  306.  
  307.         if (m_pItem)
  308.         {
  309.             delete m_pItem;
  310.         }
  311.     }
  312.     END_CATCH
  313. }
  314.  
  315.  
  316.  
  317. /////////////////////////////////////////////////////////////////////////////
  318. // CTestServer::OnUpdate()
  319. //
  320. void CTestServer::OnUpdate()
  321. {
  322.     ASSERT_VALID (this);
  323.  
  324.     TRACE("In OnUpdate\n");
  325.     m_pDoc->NotifySaved();
  326.     m_bDirty = FALSE;
  327. }
  328.  
  329.  
  330.  
  331. /////////////////////////////////////////////////////////////////////////////
  332. // CTestServer::OnClose()
  333. //
  334. void CTestServer::OnClose()
  335. {
  336.     ASSERT_VALID (this);
  337.  
  338.     if (GLOBAL_bEmbedded && !GLOBAL_bRegisterDoc)
  339.     {
  340.         if (!QueryUpdateClient())
  341.         {
  342.             return; // user selected cancel
  343.         }
  344.     }
  345.     else
  346.     {
  347.         if (!QuerySaveChanges())
  348.         {
  349.             return;     // user selected cancel
  350.         }
  351.     }
  352.     m_pServer->BeginRevoke();
  353. }
  354.  
  355.  
  356.  
  357.  
  358. /////////////////////////////////////////////////////////////////////////////
  359. // CTestServer::QueryUpdateClient()
  360. //
  361. BOOL CTestServer::QueryUpdateClient()
  362. {
  363.     ASSERT_VALID (this);
  364.     if (!m_bDirty)
  365.     {
  366.         return TRUE;
  367.     }
  368.  
  369.     int nResponse;
  370.     nResponse = MessageBox("Update client before exit?", "Test Server",
  371.         MB_YESNOCANCEL | MB_ICONQUESTION);
  372.  
  373.     if (nResponse == IDCANCEL)
  374.     {
  375.         return FALSE;
  376.     }
  377.     
  378.     if (nResponse == IDYES)
  379.     {
  380.         m_pDoc->NotifySaved();
  381.  
  382.         EnableWindow(FALSE);
  383.         MSG msg;
  384.  
  385.         for (int i=0; i<10000; i++)
  386.         {
  387.             if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
  388.             {   
  389.                 TranslateMessage(&msg);
  390.                 DispatchMessage(&msg);
  391.             }
  392.         }
  393.                 
  394.         EnableWindow(TRUE);
  395.     }
  396.     return TRUE;
  397. }
  398.  
  399.  
  400.  
  401.  
  402. /////////////////////////////////////////////////////////////////////////////
  403. // CTestServer::QuerySaveChanges()
  404. //
  405. BOOL CTestServer::QuerySaveChanges()
  406. {
  407.     ASSERT_VALID (this);
  408.     if (!m_bDirty)
  409.     {
  410.         return TRUE;
  411.     }
  412.      
  413.     int nResponse;
  414.     nResponse = MessageBox("Save file before exit?", "Test Server",
  415.         MB_YESNOCANCEL | MB_ICONQUESTION);
  416.  
  417.     if (nResponse == IDCANCEL)
  418.     {
  419.         return FALSE;
  420.     }
  421.     
  422.     if (nResponse == IDYES)
  423.     {
  424.         SaveFile(m_bUntitled);
  425.     }
  426.     return TRUE;
  427. }
  428.  
  429.  
  430.  
  431. /////////////////////////////////////////////////////////////////////////////
  432. // CTestServer::OnAbout()
  433. //
  434. void CTestServer::OnAbout()
  435. {
  436.     CModalDialog about(IDDT_ABOUT, this);
  437.     about.DoModal();
  438. }
  439.  
  440.  
  441.  
  442. /////////////////////////////////////////////////////////////////////////////
  443. // CTestServer::OnMenuExit()
  444. //
  445. void CTestServer::OnMenuExit()
  446. {
  447.     PostMessage(WM_CLOSE);
  448. }
  449.  
  450.  
  451.  
  452. /////////////////////////////////////////////////////////////////////////////
  453. // CTestServer::~CTestServer()
  454. //
  455. CTestServer::~CTestServer()
  456. {
  457.     if (m_pDoc)
  458.     {
  459.         TRACE("Now Deleting the document\n");
  460.         delete m_pDoc;
  461.         m_pDoc = NULL;
  462.     }
  463.  
  464.  
  465.     if (m_bLogging)
  466.     {   
  467.         if (pOleDump)
  468.         {
  469.             pOleDump->Flush();
  470.             pOleDump->Close();
  471.             delete pOleDump;
  472.             pOleDump = NULL;
  473.         }
  474.     }
  475.  
  476.     if (m_pList)
  477.     {
  478.         delete m_pList;
  479.         m_pList = NULL;
  480.     }
  481. }
  482.  
  483.  
  484.  
  485. #ifdef _DEBUG
  486. void CTestServer::AssertValid() const
  487. {
  488.     CFrameWnd::AssertValid();
  489.     ASSERT(m_pDoc != NULL);
  490.     ASSERT(m_pServer != NULL);
  491. }
  492.  
  493.  
  494. void CTestServer::Dump (CDumpContext &dc) const 
  495. {
  496.     dc << "\nCTestServer Dump Beginning\n";
  497.     CFrameWnd::Dump(dc);
  498.  
  499.     dc << "\nCurrent FileName is:  " << m_szFileName;
  500.  
  501.     if (m_pDoc)
  502.     {
  503.         m_pDoc->Dump(dc);
  504.         dc << "\n";
  505.     }
  506.     else
  507.     {
  508.         dc << "\nNo CServDoc is present\n";
  509.     }
  510.  
  511.     if (m_pServer)
  512.     {
  513.         m_pServer->Dump(dc);
  514.         dc << "\n";
  515.     }
  516.     else
  517.     {
  518.         dc << "\nNo CNewServer is present\n";
  519.     }
  520.  
  521.     if (!GLOBAL_bRegisterDoc)
  522.     {
  523.         if (m_pItem)
  524.         {
  525.             m_pItem->Dump(dc);
  526.             dc << "\n";
  527.         }
  528.         else
  529.         {
  530.             dc << "\nNo CServItem is present\n";
  531.         }
  532.     }
  533. }
  534. #endif  
  535.  
  536.  
  537.  
  538. BEGIN_MESSAGE_MAP(CTestServer, CFrameWnd)
  539.     ON_WM_CREATE()
  540.     ON_WM_CLOSE()
  541.     ON_WM_INITMENU()
  542.     ON_COMMAND(IDM_NEW, OnNew)
  543.     ON_COMMAND(IDM_OPEN, OnOpen)
  544.     ON_COMMAND(IDM_SAVE, OnSave)
  545.     ON_COMMAND(IDM_SAVEAS, OnSaveAs)
  546.     ON_COMMAND(IDM_UPDATE, OnUpdate)
  547.     ON_COMMAND(IDM_EXIT, OnMenuExit)
  548.     ON_COMMAND(IDM_COPYLINK, OnCopyLink)
  549.     ON_COMMAND(IDM_COPYOBJECT, OnCopyObject)
  550.     ON_COMMAND(IDM_LOGGING, OnLogging)
  551.     ON_COMMAND(IDM_REVOKESVR, OnRevokeServerApi)
  552.     ON_COMMAND(IDM_REVOKEDOC, OnRevokeDocApi)
  553.     ON_COMMAND(IDM_REVERTDOC, OnRevertDocApi)
  554.     ON_COMMAND(IDM_SAVEDOC, OnSaveDocApi)
  555.     ON_COMMAND(IDM_CLOSEDOC, OnCloseDocApi)
  556.     ON_COMMAND(IDM_CHANGEDOC, OnChangeDocApi)
  557.     ON_COMMAND(IDM_CHANGEITEM, OnChangeItemApi)
  558.     ON_COMMAND(IDM_ABOUT, OnAbout)
  559. END_MESSAGE_MAP()
  560.  
  561.  
  562. BOOL CTestApp::InitInstance()
  563. {
  564.     // Following the OLE V1.0 SDK, the clipboard formats are registered.
  565.     // Note the stream, document, and client are all created in testserv.h.
  566.     GLOBAL_uNativeFormat = RegisterClipboardFormat("Native");
  567.     GLOBAL_uOwnerFormat = RegisterClipboardFormat("OwnerLink");
  568.     GLOBAL_uObjectFormat = RegisterClipboardFormat("ObjectLink");
  569.  
  570.     // A check is performed on each value returned by the register
  571.     // operation.  
  572.  
  573.     if ((GLOBAL_uNativeFormat < 0xC000) && (GLOBAL_uNativeFormat > 0xFFFF))
  574.     {
  575.         MessageBox(m_pMainWnd->m_hWnd, "Native Data Clipboard Format Not Registered!",
  576.             "TestServ", MB_ICONEXCLAMATION);
  577.         return FALSE;
  578.     }
  579.  
  580.  
  581.     if ((GLOBAL_uOwnerFormat < 0xC000) && (GLOBAL_uOwnerFormat > 0xFFFF))
  582.     {
  583.         MessageBox(m_pMainWnd->m_hWnd, "OwnerLink Clipboard Format Not Registered!",
  584.             "TestServ", MB_ICONEXCLAMATION);
  585.         return FALSE;
  586.     }
  587.  
  588.  
  589.     if ((GLOBAL_uObjectFormat < 0xC000) && (GLOBAL_uObjectFormat > 0xFFFF))
  590.     {
  591.         MessageBox(m_pMainWnd->m_hWnd, "ObjectLink Clipboard Format Not Registered!",
  592.             "TestServ", MB_ICONEXCLAMATION);
  593.         return FALSE;
  594.     }
  595.  
  596.  
  597.     GLOBAL_bRegisterDoc = GLOBAL_bNoDisplay = GLOBAL_bEmbedded = FALSE;
  598.     // check if run with /Embedding
  599.     LPCSTR lpsz = m_lpCmdLine;
  600.  
  601.     while (*lpsz == ' ')
  602.         lpsz++;
  603.     if ((*lpsz == '-' || *lpsz == '/') &&
  604.         _fstrncmp("Embedding", lpsz+1, 9) == 0)
  605.     {
  606.         lpsz += 10;
  607.         TRACE("Embedding Detected\n");
  608.         GLOBAL_bNoDisplay = TRUE;
  609.         GLOBAL_bEmbedded = TRUE;
  610.     }
  611.     else
  612.     {
  613.         TRACE("Manual Startup Detected\n");
  614.     }
  615.  
  616.     while (*lpsz == ' ') 
  617.         lpsz++;
  618.  
  619.     if (*lpsz != '\0')
  620.     {
  621.         TRACE("Embedded Linking Detected\n");
  622.         TRACE("FileName is:  %Fs\n",lpsz);
  623.         GLOBAL_szFileName = lpsz;
  624.         GLOBAL_bRegisterDoc = TRUE;
  625.  
  626.         CFileStatus status;     // check to see if the file exists
  627.  
  628.         // If the file doesn't exist, get out quick.
  629.         if (!CFile::GetStatus(GLOBAL_szFileName, status))
  630.         {
  631.             return FALSE;
  632.         }
  633.     }
  634.     else
  635.     {
  636.         TRACE("No Linking Detected\n");
  637.     }
  638.  
  639.     GLOBAL_pServer = new CNewServer(GLOBAL_bEmbedded);
  640.  
  641.     // register name before server just in case
  642.     AfxOleRegisterServerName("TestServ", "AFX OLE Test Server");
  643.  
  644.     if (!(GLOBAL_pServer->Register("TestServ", TRUE)))  // multi-instance
  645.     {
  646.         MessageBox(NULL, "Couldn't register server", "Test Server", MB_OK);
  647.         return FALSE;
  648.     }
  649.  
  650.     CTestServer* pWnd = new CTestServer;
  651.     m_pMainWnd = pWnd;
  652.  
  653.     if (CTestServer::m_bCreationFailed)
  654.     {
  655.         // CTestServer::OnCreate failed because of OLE problems.  
  656.         // CTestServer has been deleted and shouldn't be used.
  657.         m_pMainWnd = pWnd = NULL;
  658.         return FALSE;
  659.     }
  660.  
  661.     if (GLOBAL_bEmbedded && !GLOBAL_bRegisterDoc)
  662.     {
  663.         pWnd->ShowWindow(SW_HIDE);
  664.  
  665.         CMenu *pMenu;
  666.         pMenu = pWnd->GetMenu();
  667.  
  668.         pMenu->EnableMenuItem(IDM_NEW, MF_DISABLED | MF_GRAYED);
  669.         pMenu->EnableMenuItem(IDM_OPEN, MF_DISABLED | MF_GRAYED);
  670.         if (!pMenu->ModifyMenu(IDM_SAVE, MF_BYCOMMAND, IDM_UPDATE,
  671.             "&Update"))
  672.         {
  673.             OutputLog("CTestServer::Didn't Change Save to Update in File Menu\n");
  674.         }
  675.  
  676.         if (!pMenu->ModifyMenu(IDM_EXIT, MF_BYCOMMAND, IDM_EXIT,
  677.             "E&xit and Return"))
  678.         {
  679.             OutputLog("CTestServer::Didn't Modify Exit in File Menu\n");
  680.         }
  681.     }
  682.     else
  683.     {
  684.         pWnd->ShowWindow(m_nCmdShow);
  685.     }
  686.     pWnd->UpdateWindow();
  687.  
  688.     return TRUE;
  689. }
  690.  
  691.  
  692.  
  693.  
  694.  
  695. int CTestApp::ExitInstance()
  696. {
  697.     ASSERT_VALID(this);
  698.  
  699.     int nRet;
  700.  
  701.     if (m_pMainWnd != NULL)
  702.     {
  703.         nRet = m_pMainWnd->DestroyWindow();
  704.     }
  705.  
  706.     if (nRet != 0)
  707.     {
  708.         return 0;
  709.     }
  710.     else
  711.     {
  712.         return 1;
  713.     }
  714. }
  715.  
  716.  
  717.  
  718.