home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / C++-7 / DISK8 / MFC / SAMPLES / TESTCLNT / TESTCLNT.CP$ / testclnt
Encoding:
Text File  |  1992-03-19  |  15.8 KB  |  652 lines

  1. // testclnt.cpp : This is the main file for the AFXOLE Test Client.  The
  2. //               test client is mean to be an API, stress, and usability
  3. //               test of the AFX OLE implementation.
  4. //
  5. // This is a part of the Microsoft Foundation Classes C++ library.
  6. // Copyright (C) 1992 Microsoft Corporation
  7. // All rights reserved.
  8. //
  9. // This source code is only intended as a supplement to the
  10. // Microsoft Foundation Classes Reference and Microsoft
  11. // QuickHelp documentation provided with the library.
  12. // See these sources for detailed information regarding the
  13. // Microsoft Foundation Classes product.
  14.  
  15. #include "testclnt.h"
  16. #include "resource.h"
  17. #include "defs.h"
  18.  
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21.  
  22. IMPLEMENT_DYNAMIC(CTestClient,CFrameWnd)
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // GLOBALS
  26. //
  27. UINT GLOBAL_uNativeFormat, GLOBAL_uOwnerFormat, GLOBAL_uObjectFormat;
  28. CString GLOBAL_szFile;
  29. CStdioFile *pOleDump;
  30. static char szBuffer[80];
  31. CTheApp theApp;
  32.  
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CTestClient constructor:
  36. //
  37. CTestClient::CTestClient()
  38. {
  39.     VERIFY(m_title.LoadString(IDS_APPNAME));
  40.     VERIFY(LoadAccelTable(MAKEINTRESOURCE(ID_APPLICATION)));
  41.     
  42.     VERIFY(Create(NULL, m_title, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
  43.         rectDefault, NULL, MAKEINTRESOURCE(ID_APPLICATION)));
  44.  
  45.     ASSERT(m_hWnd != NULL);
  46.  
  47.     m_pDoc = new CNewClientDoc(this);
  48.     VERIFY(m_pDoc->Register(AfxGetApp()->m_pszAppName, 
  49.         "Document 1") != 0);
  50.  
  51.     m_pClient = new CNewClient(this, m_pDoc);
  52.  
  53.     m_pBorder = NULL;
  54.     m_bRevertAvailable = FALSE;
  55.     m_bLogging = FALSE;
  56.     m_bUntitled = TRUE;
  57.  
  58.     m_hWndNextView = NULL;
  59.     m_hWndNextView = SetClipboardViewer();
  60.     m_bDirty = FALSE;
  61. }
  62.  
  63.  
  64.  
  65.  
  66. /////////////////////////////////////////////////////////////////////////////
  67. // CTestClient::OnCreate(LPCREATESTRUCT p)
  68. //
  69. int CTestClient::OnCreate(LPCREATESTRUCT p)
  70. {
  71.     CRect nullRect(0,0,0,0);
  72.     m_pObjectFormat = new CListBox();
  73.     m_pObjectFormat->Create( LBS_USETABSTOPS | WS_CHILD | 
  74.         WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL, nullRect,
  75.         this, IDC_OBJECTFORMAT);
  76.  
  77.     m_pClipFormat = new CListBox();
  78.     m_pClipFormat->Create( LBS_USETABSTOPS | WS_CHILD | 
  79.         WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL, nullRect, 
  80.         this, IDC_CLIPFORMAT);
  81.  
  82.     m_pInfoTitle = new CStatic();
  83.     m_pInfoTitle->Create("Information Bar", WS_VISIBLE | WS_CHILD |
  84.         SS_CENTER, nullRect, this, IDC_INFOTITLE);
  85.  
  86.     m_pItemTitle = new CStatic();
  87.     m_pItemTitle->Create("None", WS_VISIBLE | WS_CHILD |
  88.         SS_CENTER, nullRect, this, IDC_INFOITEM);
  89.  
  90.     m_pClipTitle = new CStatic();
  91.     m_pClipTitle->Create("Clipboard Formats:", WS_VISIBLE | WS_CHILD |
  92.         SS_LEFT, nullRect, this, IDC_INFOCLIPFORMAT);
  93.  
  94.     m_pObjectTitle = new CStatic();
  95.     m_pObjectTitle->Create("Object Formats:", WS_VISIBLE | WS_CHILD |
  96.         SS_LEFT, nullRect, this, IDC_INFOOBJECTFORMAT);
  97.  
  98.     m_pNameTitle = new CStatic();
  99.     m_pNameTitle->Create("Name:", WS_VISIBLE | WS_CHILD |
  100.         SS_LEFT, nullRect, this, IDC_INFONAME);
  101.  
  102.     return CFrameWnd::OnCreate(p);
  103. }
  104.  
  105.  
  106.  
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CTestClient::OnInitMenu(CMenu* pMenu)
  109. //
  110. void CTestClient::OnInitMenu(CMenu* pMenu)
  111. {
  112.     CMenu *myMenu;
  113.     BOOL bCanLink, bCanPaste;
  114.  
  115.     myMenu = GetMenu();
  116.  
  117.     if ((myMenu != pMenu) || (m_pClient == NULL))
  118.     {
  119.         // just return on weird cases, we don't want to assert here.
  120.         return;
  121.     }
  122.  
  123.  
  124.     // Set up file and object menus
  125.     if (m_pClient->m_lpObject != NULL)
  126.     {
  127.         pMenu->EnableMenuItem(IDM_SAVE, MF_ENABLED);
  128.         pMenu->EnableMenuItem(IDM_SAVEAS, MF_ENABLED);
  129.         pMenu->EnableMenuItem(IDM_COPY, MF_ENABLED);
  130.  
  131.     }
  132.     else
  133.     {
  134.         pMenu->EnableMenuItem(IDM_SAVE, MF_DISABLED | MF_GRAYED);
  135.         pMenu->EnableMenuItem(IDM_SAVEAS, MF_DISABLED | MF_GRAYED);
  136.         pMenu->EnableMenuItem(IDM_COPY, MF_DISABLED | MF_GRAYED);
  137.     }
  138.  
  139.  
  140.     if (m_bRevertAvailable)
  141.     {
  142.         pMenu->EnableMenuItem(IDM_REVERT, MF_ENABLED);
  143.     }
  144.     else
  145.     {
  146.         pMenu->EnableMenuItem(IDM_REVERT, MF_DISABLED | MF_GRAYED);
  147.     }
  148.  
  149.  
  150.     
  151.     TRY
  152.     {
  153.         // Generate the EDIT menus
  154.         ASSERT (m_pClient != NULL);
  155.         bCanPaste = m_pClient->CanPaste();
  156.         bCanLink = m_pClient->CanPasteLink();
  157.  
  158.         if (bCanLink)
  159.         {
  160.             pMenu->EnableMenuItem(IDM_PASTELINK, MF_ENABLED);
  161.         }
  162.         else
  163.         {
  164.             pMenu->EnableMenuItem(IDM_PASTELINK, MF_DISABLED | MF_GRAYED);
  165.         }
  166.  
  167.  
  168.         if (bCanPaste)
  169.         {
  170.             pMenu->EnableMenuItem(IDM_PASTE, MF_ENABLED);
  171.         }
  172.         else
  173.         {
  174.             pMenu->EnableMenuItem(IDM_PASTE, MF_DISABLED | MF_GRAYED);
  175.         }
  176.  
  177.  
  178.         if ((m_pClient->m_lpObject != NULL) &&
  179.             (m_pClient->GetType() == OT_LINK))
  180.         {
  181.             pMenu->EnableMenuItem(IDM_LINKS, MF_ENABLED);
  182.             pMenu->EnableMenuItem(IDM_RECONNECT, MF_ENABLED);
  183.             pMenu->EnableMenuItem(IDM_UPDATE, MF_ENABLED);
  184.         }
  185.         else
  186.         {
  187.             pMenu->EnableMenuItem(IDM_LINKS, MF_DISABLED | MF_GRAYED);
  188.             pMenu->EnableMenuItem(IDM_RECONNECT, MF_DISABLED | MF_GRAYED);
  189.             pMenu->EnableMenuItem(IDM_UPDATE, MF_DISABLED | MF_GRAYED);
  190.         }
  191.  
  192.  
  193.         // if it is a picture don't allow any calls to the API menus
  194.         if ((m_pClient->m_lpObject != NULL) &&
  195.             (m_pClient->GetType() == OT_STATIC))
  196.         {
  197.             pMenu->EnableMenuItem(IDM_CLOSE, MF_DISABLED | MF_GRAYED);
  198.             pMenu->EnableMenuItem(IDM_UPDATE, MF_DISABLED | MF_GRAYED);
  199.             pMenu->EnableMenuItem(IDM_RELEASE, MF_DISABLED | MF_GRAYED);
  200.             pMenu->EnableMenuItem(IDM_DELETE, MF_DISABLED | MF_GRAYED);
  201.             pMenu->EnableMenuItem(IDM_RECONNECT, MF_DISABLED | MF_GRAYED);
  202.             pMenu->EnableMenuItem(IDM_REVERTDOC, MF_DISABLED | MF_GRAYED);
  203.             pMenu->EnableMenuItem(IDM_SAVED, MF_DISABLED | MF_GRAYED);
  204.         }
  205.             
  206.  
  207.         // add the object verb menus on the end of the object sub-menu
  208.         CMenu *pObjectMenu;
  209.  
  210.         pObjectMenu = pMenu->GetSubMenu(2);
  211.         static int iItemObjectVerb = -1;    // position on the Edit menu
  212.  
  213.         if (iItemObjectVerb == -1)
  214.         {
  215.             // one-time init - find the position of the "Object ?" menuitem
  216.             int nItems = pObjectMenu->GetMenuItemCount();
  217.             for (int iItem = 0; iItem < nItems; iItem++)
  218.             {
  219.                 if (pObjectMenu->GetMenuItemID(iItem) == IDM_OBJECT_VERB_MIN)
  220.                 {
  221.                     iItemObjectVerb = iItem;
  222.                     break;
  223.                 }
  224.             }
  225.         }
  226.         ASSERT(iItemObjectVerb != -1);
  227.         // MUST BE IN THE MENU TEMPLATE ON INIT !
  228.  
  229.         AfxOleSetEditMenu(m_pClient->m_lpObject == NULL ? NULL : m_pClient, 
  230.             pObjectMenu, iItemObjectVerb, IDM_OBJECT_VERB_MIN);
  231.     }
  232.     CATCH(CException, e)
  233.     {
  234.         return;
  235.     }
  236.     END_CATCH
  237. }
  238.  
  239.  
  240.  
  241. /////////////////////////////////////////////////////////////////////////////
  242. // CTestClient::OnCommand(UINT wParam, LONG lParam)
  243. //
  244. BOOL CTestClient::OnCommand(UINT wParam, LONG lParam)
  245. {
  246.     if (!m_pClient)
  247.     {
  248.         return CFrameWnd::OnCommand(wParam, lParam);
  249.     }
  250.  
  251.     // if we are waiting for release - ignore all commands
  252.     if (COleClientItem::InWaitForRelease())
  253.     {
  254.         return TRUE;        // handled
  255.     }
  256.  
  257.     if (LOWORD(lParam) == 0 && wParam >= IDM_OBJECT_VERB_MIN &&
  258.         wParam <= IDM_OBJECT_VERB_MAX && m_pClient != NULL)
  259.     {
  260.         DoVerb(wParam - IDM_OBJECT_VERB_MIN);
  261.         return TRUE;        // handled
  262.     }
  263.     return CFrameWnd::OnCommand(wParam, lParam);
  264. }
  265.  
  266.  
  267.  
  268. /////////////////////////////////////////////////////////////////////////////
  269. // CTestClient OnAbout()
  270. //
  271. void CTestClient::OnAbout()
  272. {
  273.     CModalDialog about(MAKEINTRESOURCE(IDDT_ABOUT), this);
  274.     about.DoModal();
  275. }
  276.  
  277.  
  278.  
  279.  
  280. /////////////////////////////////////////////////////////////////////////////
  281. // CTestClient OnDestroy()
  282. //
  283. void CTestClient::OnDestroy()
  284. {
  285.     if (IsWindow(m_hWndNextView))
  286.     {
  287.         ChangeClipboardChain(m_hWndNextView);
  288.     }
  289.  
  290.     TRY
  291.     {
  292.         if (m_pClient->m_lpObject)
  293.         {
  294.             m_pClient->Delete();// Go ahead and destroy the item
  295.         }
  296.         m_pDoc->Revoke();           // Revoke Document
  297.     }
  298.     CATCH(COleException, e)
  299.     {
  300.         // There is not much we can do here to clean up.  The TRY/CATCH
  301.         // is only provided to prevent an assertion in the message pump.
  302.     }
  303.     END_CATCH
  304.  
  305.     CFrameWnd::OnDestroy();
  306. }
  307.  
  308.  
  309.  
  310. /////////////////////////////////////////////////////////////////////////////
  311. // CTestClient::OnSize(UNIT nType, int cx, int cy)
  312. //
  313. void CTestClient::OnSize (UINT nType, int cx, int cy)
  314. {
  315.     int iRegion;
  316.     CRect clipRect, objectClipRect, objectTitleRect, infoRect, 
  317.         itemRect, nameRect, cpTitleRect;
  318.     CClientDC dc(this);
  319.  
  320.     // Divide screen region into two regions: object and information bar.
  321.     // information bar takes up right hand 1/3rd of screen.
  322.     iRegion = cx/3;
  323.  
  324.     // Set up left borders
  325.     clipRect.left = objectClipRect.left = infoRect.left = cx - iRegion;
  326.     itemRect.left = nameRect.left = cpTitleRect.left = cx - iRegion;
  327.     objectTitleRect.left = cx - iRegion;
  328.  
  329.     // set up right borders
  330.     clipRect.right = objectClipRect.right = infoRect.right = cx;
  331.     itemRect.right = nameRect.right = cpTitleRect.right = cx;
  332.     objectTitleRect.right = cx;
  333.  
  334.     // setup Information Bar (infoRect) top and bottom
  335.     infoRect.top = 0;
  336.     m_pInfoTitle->GetWindowText(szBuffer, sizeof(szBuffer));
  337.     infoRect.bottom = (dc.GetTextExtent(szBuffer, strlen(szBuffer))).cy;
  338.  
  339.     // setup name top and bottom
  340.     nameRect.top = infoRect.bottom;
  341.     m_pNameTitle->GetWindowText(szBuffer,sizeof(szBuffer));
  342.     nameRect.bottom = nameRect.top + 
  343.         (dc.GetTextExtent(szBuffer, strlen(szBuffer))).cy;
  344.  
  345.     // setup object tile top and bottom
  346.     itemRect.top = nameRect.bottom;
  347.     m_pItemTitle->GetWindowText(szBuffer,sizeof(szBuffer));
  348.     itemRect.bottom = itemRect.top + 
  349.         (dc.GetTextExtent(szBuffer, strlen(szBuffer))).cy;
  350.  
  351.     // setup clipboard format title top and bottom
  352.     cpTitleRect.top = itemRect.bottom;
  353.     m_pClipTitle->GetWindowText(szBuffer,sizeof(szBuffer));
  354.     cpTitleRect.bottom = cpTitleRect.top +
  355.         (dc.GetTextExtent(szBuffer, strlen(szBuffer))).cy;
  356.  
  357.  
  358.     // setup clipboard area
  359.     clipRect.top = cpTitleRect.bottom;
  360.     m_pObjectTitle->GetWindowText(szBuffer,sizeof(szBuffer));
  361.     clipRect.bottom = cy/2 + 
  362.         ((dc.GetTextExtent(szBuffer, strlen(szBuffer))).cy/2);
  363.  
  364.     // setup object format title area
  365.     objectTitleRect.top = clipRect.bottom;
  366.     m_pObjectTitle->GetWindowText(szBuffer,sizeof(szBuffer));
  367.     objectTitleRect.bottom = objectTitleRect.top + 
  368.         (dc.GetTextExtent(szBuffer, strlen(szBuffer))).cy;
  369.  
  370.     // setup object clipboard format area
  371.     objectClipRect.top = objectTitleRect.bottom;
  372.     objectClipRect.bottom = cy;
  373.  
  374.     m_pClipFormat->MoveWindow(clipRect);
  375.     m_pObjectFormat->MoveWindow(objectClipRect);
  376.     m_pItemTitle->MoveWindow(itemRect);
  377.     m_pObjectTitle->MoveWindow(objectTitleRect);
  378.     m_pInfoTitle->MoveWindow(infoRect);
  379.     m_pClipTitle->MoveWindow(cpTitleRect);
  380.     m_pNameTitle->MoveWindow(nameRect);
  381.  
  382.     CFrameWnd::OnSize (nType, cx, cy);
  383. }
  384.  
  385.  
  386.  
  387.  
  388. /////////////////////////////////////////////////////////////////////////////
  389. // CTestClient::QuerySaveChanges()
  390. //
  391. BOOL CTestClient::QuerySaveChanges()
  392. {
  393.     if (!m_bDirty)
  394.     {
  395.         return TRUE;
  396.     }
  397.  
  398.     int fResponse;
  399.     fResponse = MessageBox("Save file before proceeding?", "Test Client",
  400.         MB_YESNOCANCEL | MB_ICONQUESTION);
  401.  
  402.     if (fResponse == IDCANCEL)
  403.     {
  404.         return FALSE;
  405.     }
  406.     
  407.     if (fResponse == IDYES)
  408.     {
  409.         SaveFile(m_bUntitled);
  410.     }
  411.  
  412.     return TRUE;
  413. }
  414.  
  415.  
  416.  
  417. /////////////////////////////////////////////////////////////////////////////
  418. // CTestClient OnClose
  419. //
  420. void CTestClient::OnClose()
  421. {
  422.  
  423.     if (COleClientItem::InWaitForRelease())
  424.     {
  425.         MessageBox("Server still busy or dead", "Test Client",
  426.             MB_ICONEXCLAMATION);
  427.         return;
  428.     }
  429.  
  430.     if (!QuerySaveChanges())
  431.     {
  432.         return;
  433.     }
  434.     DestroyWindow();
  435. }
  436.  
  437.  
  438.  
  439.  
  440. /////////////////////////////////////////////////////////////////////////////
  441. // CTestClient PrepareDC
  442. //
  443. void CTestClient::PrepareDC(CDC* pDC)
  444. {
  445.     pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
  446.     pDC->SetBkColor(::GetSysColor(COLOR_WINDOW));
  447. }
  448.  
  449. /////////////////////////////////////////////////////////////////////////////
  450. // CTestClient OnPaint
  451. //
  452. void CTestClient::OnPaint()
  453. {
  454.     CPaintDC dc(this);
  455.     CRect rect;
  456.  
  457.     PrepareDC(&dc);
  458.     GetClientRect(rect);
  459.  
  460.     // Object uses left hand 2/3rds of screen to draw on.
  461.     rect.right = (int)((2 * rect.right) / 3);
  462.  
  463.     if (m_pClient->m_lpObject != NULL)
  464.     {
  465.         TRY
  466.         {
  467.             if (!m_pClient->Draw(&dc, &rect, NULL, &dc))
  468.             {
  469.  
  470.                 if (m_pClient->GetLastStatus() == OLE_ERROR_BLANK)
  471.                 {
  472.                     // It's blank, just return
  473.                     return;
  474.                 }
  475.  
  476.                 MessageBox ("Couldn't Paint Object!", "Test Client",
  477.                     MB_ICONEXCLAMATION);
  478.             }
  479.         }
  480.         CATCH (COleException, e)
  481.         {
  482.             MessageBox("An OleException was Thrown in CTestClient::OnPaint", "Test Client",
  483.                     MB_ICONEXCLAMATION);    
  484.             if (m_bLogging)
  485.             {
  486.                 LogError (THIS_FILE, e->m_status);
  487.             }
  488.         }
  489.         END_CATCH
  490.     }
  491. }
  492.  
  493.  
  494.  
  495. /////////////////////////////////////////////////////////////////////////////
  496. // CTestClient::OnLinks()
  497. //
  498. void CTestClient::OnLinks()
  499. {
  500.     ASSERT(m_pDoc != NULL);
  501.     AfxOleLinksDialog(m_pDoc);
  502.     Invalidate(TRUE);
  503. }
  504.  
  505.  
  506.  
  507.  
  508. /////////////////////////////////////////////////////////////////////////////
  509. // CTestClient::OnExit()
  510. //
  511. void CTestClient::OnMenuExit()
  512. {
  513.     PostMessage(WM_CLOSE);
  514. }
  515.  
  516.  
  517.  
  518. /////////////////////////////////////////////////////////////////////////////
  519. // CTestClient::~CTestClient()
  520. //
  521. CTestClient::~CTestClient()
  522. {
  523.     if (m_pClipFormat != NULL)
  524.     {
  525.         delete m_pClipFormat;
  526.     }
  527.  
  528.     if (m_pObjectFormat != NULL)
  529.     {
  530.         delete m_pObjectFormat;
  531.     }
  532.  
  533.     if (m_pInfoTitle != NULL)
  534.     {
  535.         delete m_pInfoTitle;
  536.     }
  537.     
  538.     if (m_pItemTitle != NULL)
  539.     {
  540.         delete m_pItemTitle;
  541.     }
  542.  
  543.     if (m_pClipTitle != NULL)
  544.     {
  545.         delete m_pClipTitle;
  546.     }
  547.  
  548.     if (m_pObjectTitle != NULL)
  549.     {
  550.         delete m_pObjectTitle;
  551.     }
  552.  
  553.     if (m_pNameTitle != NULL)
  554.     {
  555.         delete m_pNameTitle;
  556.     }
  557.  
  558.     if (pOleDump != NULL)
  559.     {
  560.         pOleDump->Flush();
  561.         pOleDump->Close();
  562.         delete pOleDump;
  563.     }
  564.     
  565.     if (m_pClient != NULL)
  566.     {
  567.         delete m_pClient;
  568.     }
  569.  
  570. }
  571.  
  572.  
  573. // CTestClient message map:
  574. // Associate messages with member functions.
  575. BEGIN_MESSAGE_MAP( CTestClient, CFrameWnd )
  576.     ON_COMMAND(IDM_ABOUT, OnAbout)
  577.     ON_COMMAND(IDM_PASTELINK, OnPasteLink)
  578.     ON_COMMAND(IDM_INSERT_OBJECT, OnInsertObject)
  579.     ON_COMMAND(IDM_REVERT, OnRevert)
  580.     ON_COMMAND(IDM_LINKS, OnLinks)
  581.     ON_COMMAND(IDM_PASTE, OnPaste)
  582.     ON_COMMAND(IDM_COPY, OnCopy)
  583.     ON_COMMAND(IDM_OPEN, OnFileOpen)
  584.     ON_COMMAND(IDM_SAVE, OnFileSave)
  585.     ON_COMMAND(IDM_SAVEAS, OnFileSaveAs)
  586.     ON_COMMAND(IDM_EXIT, OnMenuExit)
  587.     ON_COMMAND(IDM_LOGGING, OnLogging)
  588.     ON_COMMAND(IDM_CLOSE, OnCloseApi)
  589.     ON_COMMAND(IDM_UPDATE, OnUpdateApi)
  590.     ON_COMMAND(IDM_RELEASE, OnReleaseApi)
  591.     ON_COMMAND(IDM_DELETE, OnDeleteApi)
  592.     ON_COMMAND(IDM_RECONNECT, OnReconnectApi)
  593.     ON_COMMAND(IDM_REVERTDOC, OnRevertApi)
  594.     ON_COMMAND(IDM_SAVED, OnSavedApi)
  595.     ON_WM_DRAWCLIPBOARD()
  596.     ON_WM_CHANGECBCHAIN()
  597.     ON_WM_INITMENU()
  598.     ON_WM_PAINT()
  599.     ON_WM_SIZE()
  600.     ON_WM_CREATE()
  601.     ON_WM_CLOSE()
  602.     ON_WM_DESTROY()
  603. END_MESSAGE_MAP()
  604.  
  605.  
  606.  
  607. /////////////////////////////////////////////////////////////////////////////
  608. // CTheApp InitInstance:
  609. // 
  610. BOOL CTheApp::InitInstance()
  611. {
  612.     m_pMainWnd = new CTestClient();
  613.  
  614.     ASSERT (m_pMainWnd != NULL);
  615.     m_pMainWnd->ShowWindow( m_nCmdShow );
  616.     m_pMainWnd->UpdateWindow();
  617.  
  618.     
  619.     // Following the OLE V1.0 SDK, the clipboard formats are registered.
  620.     // Note the stream, document, and client are all created in testclnt.h.
  621.     GLOBAL_uNativeFormat = RegisterClipboardFormat("Native");
  622.     GLOBAL_uOwnerFormat = RegisterClipboardFormat("OwnerLink");
  623.     GLOBAL_uObjectFormat = RegisterClipboardFormat("ObjectLink");
  624.  
  625.     // A check is performed on each value returned by the register
  626.     // operation.
  627.  
  628.     if ((GLOBAL_uNativeFormat < 0xC000) && (GLOBAL_uNativeFormat > 0xFFFF))
  629.     {
  630.         MessageBox(m_pMainWnd->m_hWnd, "Native Data Clipboard Format Not Registered!",
  631.             "Test Client", MB_ICONEXCLAMATION);
  632.         return FALSE;
  633.     }
  634.  
  635.  
  636.     if ((GLOBAL_uOwnerFormat < 0xC000) && (GLOBAL_uOwnerFormat > 0xFFFF))
  637.     {
  638.         MessageBox(m_pMainWnd->m_hWnd, "Native Data Clipboard Format Not Registered!",
  639.             "Test Client", MB_ICONEXCLAMATION);
  640.         return FALSE;
  641.     }
  642.  
  643.  
  644.     if ((GLOBAL_uObjectFormat < 0xC000) && (GLOBAL_uObjectFormat > 0xFFFF))
  645.     {
  646.         MessageBox(m_pMainWnd->m_hWnd, "Native Data Clipboard Format Not Registered!",
  647.             "Test Client", MB_ICONEXCLAMATION);
  648.         return FALSE;
  649.     }
  650.     return TRUE;
  651. }
  652.