home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / ba / tvxsamp / tvxsamp.cpp < prev    next >
C/C++ Source or Header  |  1997-09-15  |  4KB  |  139 lines

  1. //---------------------------------------------------------------------------------
  2. // TVXSampDlg.cpp : TV Viewer sample application
  3. //---------------------------------------------------------------------------------
  4. // Copyright (C) 1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Broadcast Architecture Programmer's Reference.
  9. // For more information about writing applications that interact
  10. // with TV Viewer, see `` Creating TV Viewer Controls ``
  11. // in the Broadcast Architecture Programmer's Reference.
  12. //
  13. //
  14.  
  15. #include "stdafx.h"
  16. #include "TVXSamp.h"
  17. #include "TVXSampDlg.h"
  18. #include "Tvdisp.h"
  19. #include <initguid.h>
  20.  
  21. DEFINE_GUID(IID_ITVViewer,0x3F8A2EA1L,0xC171,0x11CF,0x86,0x8C,0x00,0x80,0x5F,0x2C,0x11,0xCE);
  22. DEFINE_GUID(IID_ITVDisp, 0x3F8A2EA1L, 0xC171,0x11cf,0x86,0x8C,0x00,0x80,0x5F,0x2C,0x11,0xCE);
  23. DEFINE_GUID(CLSID_TVViewer,0x5543DD10L,0xB41D,0x11CF,0x86,0x82,0x00,0x80,0x5F,0x2C,0x11,0xCE);
  24.  
  25. extern ITVViewer *TVX;
  26.  
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CTVXSampApp
  35.  
  36. BEGIN_MESSAGE_MAP(CTVXSampApp, CWinApp)
  37.     //{{AFX_MSG_MAP(CTVXSampApp)
  38.         // NOTE - the ClassWizard will add and remove mapping macros here.
  39.         //    DO NOT EDIT what you see in these blocks of generated code!
  40.     //}}AFX_MSG
  41.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  42. END_MESSAGE_MAP()
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CTVXSampApp construction
  46.  
  47. CTVXSampApp::CTVXSampApp()
  48. {
  49.     // TODO: add construction code here,
  50.     // Place all significant initialization in InitInstance
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // The one and only CTVXSampApp object
  55.  
  56. CTVXSampApp theApp;
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CTVXSampApp initialization
  60.  
  61. BOOL CTVXSampApp::InitInstance()
  62. {
  63.     // Initialize OLE libraries
  64.     if (!AfxOleInit())
  65.     {
  66.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  67.         return FALSE;
  68.     }
  69.  
  70.     AfxEnableControlContainer();
  71.  
  72.     //--------------< code that gets a reference to TV Viewer >-------------
  73. //---------------------------------------------------------------------------------
  74.     /* 
  75.     The following code gets a reference to TV Viewer which
  76.     TVXSamp uses to call the ITVViewer methods.
  77.     This is implemented during TVXSamp's initialization 
  78.     to ensure that it connects to TV Viewer before 
  79.     calling the ITVViewer methods.
  80.  
  81.     TV Viewer must be running or else the following code will fail.
  82.     */
  83.     HRESULT hr = 0;
  84.     IUnknown *punk;
  85.     IDispatch *dispatch;
  86.  
  87.     hr = GetActiveObject(CLSID_TVViewer,NULL,&punk);
  88.     if (SUCCEEDED(hr))
  89.     {
  90.         hr=punk->QueryInterface(IID_IDispatch,(void**) &dispatch);
  91.         punk->Release();
  92.         if (SUCCEEDED(hr))
  93.         {
  94.             TVX=new ITVViewer(dispatch);
  95.         }
  96.     }
  97.  
  98.  
  99.     // Standard initialization
  100.     // If you are not using these features and wish to reduce the size
  101.     //  of your final executable, you should remove from the following
  102.     //  the specific initialization routines you do not need.
  103.  
  104.     // Parse the command line to see if launched as OLE server
  105.     if (RunEmbedded() || RunAutomated())
  106.     {
  107.         // Register all OLE server (factories) as running.  This enables the
  108.         //  OLE libraries to create objects from other applications.
  109.         COleTemplateServer::RegisterAll();
  110.     }
  111.     else
  112.     {
  113.         // When a server application is launched stand-alone, it is a good idea
  114.         //  to update the system registry in case it has been damaged.
  115.         COleObjectFactory::UpdateRegistryAll();
  116.     }
  117.  
  118.     CTVXSampDlg dlg;
  119.     m_pMainWnd = &dlg;
  120.     int nResponse = dlg.DoModal();
  121.     if (nResponse == IDOK)
  122.     {
  123.         // TODO: Place code here to handle when the dialog is
  124.         //  dismissed with OK
  125.  
  126.  
  127.     }
  128.     else if (nResponse == IDCANCEL)
  129.     {
  130.         // TODO: Place code here to handle when the dialog is
  131.         //  dismissed with Cancel
  132.  
  133.     }
  134.  
  135.     // Since the dialog has been closed, return FALSE so that we exit the
  136.     //  application, rather than start the application's message pump.
  137.     return FALSE;
  138. }
  139.