home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / ole / oleview / iviewers / dataobj.cpp next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.9 KB  |  115 lines

  1. // dataobj.cpp : implementation file
  2. //
  3.  
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1998 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 related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14. #include "stdafx.h"
  15. #include "iviewers.h"
  16. #include "iview.h"
  17. #include "dataobj.h"
  18. #include "util.h"
  19. #include "idataobj.h"
  20.  
  21. #ifdef _DEBUG
  22. #undef THIS_FILE
  23. static char BASED_CODE THIS_FILE[] = __FILE__;
  24. #endif
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CDataObjectViewer
  28.  
  29. IMPLEMENT_DYNCREATE(CDataObjectViewer, CInterfaceViewer)
  30.  
  31. CDataObjectViewer::CDataObjectViewer()
  32. {
  33. }
  34.  
  35. CDataObjectViewer::~CDataObjectViewer()
  36. {
  37. }
  38.  
  39. BEGIN_MESSAGE_MAP(CDataObjectViewer, CInterfaceViewer)
  40.     //{{AFX_MSG_MAP(CDataObjectViewer)
  41.         // NOTE - the ClassWizard will add and remove mapping macros here.
  42.     //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44.  
  45. IMPLEMENT_OLECREATE(CDataObjectViewer, "Ole2View.IDataObject.1", 0x28d8aba0, 0x4b78, 0x11ce, 0xb2, 0x7d, 0x0, 0xaa, 0x0, 0x1f, 0x73, 0xc1)
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDataObjectViewer View imp.
  49.  
  50. HRESULT CDataObjectViewer::OnView(HWND hwndParent, REFIID riid, LPUNKNOWN punk)
  51. {
  52.     SCODE sc = NOERROR ;
  53.  
  54.     ASSERT(hwndParent);
  55.     ASSERT(punk);
  56.  
  57.     if (riid != IID_IDataObject)
  58.     {
  59.         AfxMessageBox( _T("IDataObject interface viewer only supports IID_IDataObject") ) ;
  60.         return E_INVALIDARG ;
  61.     }
  62.  
  63.     IDataObject* pdataobj = NULL ;
  64.     sc = punk->QueryInterface( riid, (void**)&pdataobj ) ;
  65.     if (FAILED(sc))
  66.     {
  67.         AfxMessageBox( _T("Object does not support IDataObject") ) ;
  68.         return E_UNEXPECTED ;
  69.     }
  70.  
  71.     CIDataObjectDlg* pdlg ;
  72.     pdlg = new CIDataObjectDlg( hwndParent, pdataobj, riid, _T("") ) ;
  73.  
  74.     if (pdlg)
  75.     {
  76.         pdlg->DoModal() ;
  77.         delete pdlg ;
  78.     }
  79.  
  80.     pdataobj->Release() ;
  81.  
  82.     return sc ;
  83. }
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CDataObjectDlg dialog
  86.  
  87.  
  88. CDataObjectDlg::CDataObjectDlg(CWnd* pParent /*=NULL*/)
  89.     : CDialog(CDataObjectDlg::IDD, pParent)
  90. {
  91.     //{{AFX_DATA_INIT(CDataObjectDlg)
  92.         // NOTE: the ClassWizard will add member initialization here
  93.     //}}AFX_DATA_INIT
  94. }
  95.  
  96.  
  97. void CDataObjectDlg::DoDataExchange(CDataExchange* pDX)
  98. {
  99.     CDialog::DoDataExchange(pDX);
  100.     //{{AFX_DATA_MAP(CDataObjectDlg)
  101.         // NOTE: the ClassWizard will add DDX and DDV calls here
  102.     //}}AFX_DATA_MAP
  103. }
  104.  
  105.  
  106. BEGIN_MESSAGE_MAP(CDataObjectDlg, CDialog)
  107.     //{{AFX_MSG_MAP(CDataObjectDlg)
  108.         // NOTE: the ClassWizard will add message map macros here
  109.     //}}AFX_MSG_MAP
  110. END_MESSAGE_MAP()
  111.  
  112.  
  113. /////////////////////////////////////////////////////////////////////////////
  114. // CDataObjectDlg message handlers
  115.