home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / internet / stockticker / containermfc / _stocktickerctrl.cpp next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  3.8 KB  |  153 lines

  1. // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
  2.  
  3. // NOTE: Do not modify the contents of this file.  If this class is regenerated by
  4. //  Microsoft Visual C++, your modifications will be overwritten.
  5.  
  6.  
  7. #include "stdafx.h"
  8. #include "_stocktickerctrl.h"
  9.  
  10. // Dispatch interfaces referenced by this interface
  11. #include "Font.h"
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CStockTickerCtrl
  15.  
  16. IMPLEMENT_DYNCREATE(CStockTickerCtrl, CWnd)
  17.  
  18. void CStockTickerCtrl::Serialize(CArchive& ar)
  19. {
  20.     if (ar.IsStoring())
  21.         WriteControl(ar);
  22.     else
  23.         ASSERT(FALSE);  // never load this way!
  24. }
  25.  
  26. void CStockTickerCtrl::WriteControl(CArchive& ar)
  27. {
  28.     LPUNKNOWN lpUnk = GetControlUnknown();
  29.  
  30.     // create a storage to use temporarily
  31.  
  32.     LPLOCKBYTES lpLockBytes;
  33.     LPSTORAGE lpStorage;
  34.  
  35.     SCODE sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
  36.     if (sc != S_OK)
  37.         AfxThrowOleException(sc);
  38.     ASSERT(lpLockBytes != NULL);
  39.  
  40.     sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
  41.         STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &lpStorage);
  42.     if (sc != S_OK)
  43.     {
  44.         VERIFY(lpLockBytes->Release() == 0);
  45.         lpLockBytes = NULL;
  46.         AfxThrowOleException(sc);
  47.     }
  48.  
  49.     // store the darn thing!
  50.  
  51.     LPPERSISTSTORAGE lpPersistStorage;
  52.  
  53.     if (!SUCCEEDED(lpUnk->QueryInterface(IID_IPersistStorage, (void**) &lpPersistStorage)))
  54.         ASSERT(FALSE);
  55.     sc = ::OleSave(lpPersistStorage, lpStorage, FALSE);
  56.     lpPersistStorage->SaveCompleted(NULL);
  57.     lpPersistStorage->Release();
  58.     lpStorage->Commit(STGC_OVERWRITE);
  59.     ASSERT(::StgIsStorageILockBytes(lpLockBytes) == S_OK);
  60.  
  61.     // attempt to get the handle to the global memory
  62.     HGLOBAL hStorage;
  63.     sc = ::GetHGlobalFromILockBytes(lpLockBytes, &hStorage);
  64.     if (sc != S_OK)
  65.         AfxThrowOleException(sc);
  66.  
  67.     // first write a byte count
  68.     STATSTG statstg;
  69.     sc = lpLockBytes->Stat(&statstg, STATFLAG_NONAME);
  70.     if (sc != S_OK)
  71.         AfxThrowOleException(sc);
  72.     ASSERT(statstg.cbSize.HighPart == 0);   // don't support >4GB objects
  73.     DWORD dwBytes = statstg.cbSize.LowPart;
  74.     ar << dwBytes;
  75.  
  76.     // write the contents of the block
  77.     LPVOID lpBuf = GlobalLock(hStorage);
  78.     ASSERT(lpBuf != NULL);
  79.     ar.Write(lpBuf, (UINT)dwBytes);
  80.     ::GlobalUnlock(hStorage);
  81. }
  82.  
  83. /////////////////////////////////////////////////////////////////////////////
  84. // CStockTickerCtrl properties
  85.  
  86. OLE_COLOR CStockTickerCtrl::GetBackColor()
  87. {
  88.     OLE_COLOR result;
  89.     GetProperty(DISPID_BACKCOLOR, VT_I4, (void*)&result);
  90.     return result;
  91. }
  92.  
  93. void CStockTickerCtrl::SetBackColor(OLE_COLOR propVal)
  94. {
  95.     SetProperty(DISPID_BACKCOLOR, VT_I4, propVal);
  96. }
  97.  
  98. COleFont CStockTickerCtrl::GetFont()
  99. {
  100.     LPDISPATCH pDispatch;
  101.     GetProperty(DISPID_FONT, VT_DISPATCH, (void*)&pDispatch);
  102.     return COleFont(pDispatch);
  103. }
  104.  
  105. void CStockTickerCtrl::SetFont(LPDISPATCH propVal)
  106. {
  107.     SetProperty(DISPID_FONT, VT_DISPATCH, propVal);
  108. }
  109.  
  110. OLE_COLOR CStockTickerCtrl::GetForeColor()
  111. {
  112.     OLE_COLOR result;
  113.     GetProperty(DISPID_FORECOLOR, VT_I4, (void*)&result);
  114.     return result;
  115. }
  116.  
  117. void CStockTickerCtrl::SetForeColor(OLE_COLOR propVal)
  118. {
  119.     SetProperty(DISPID_FORECOLOR, VT_I4, propVal);
  120. }
  121.  
  122. short CStockTickerCtrl::GetUpdateInterval()
  123. {
  124.     short result;
  125.     GetProperty(0x1, VT_I2, (void*)&result);
  126.     return result;
  127. }
  128.  
  129. void CStockTickerCtrl::SetUpdateInterval(short propVal)
  130. {
  131.     SetProperty(0x1, VT_I2, propVal);
  132. }
  133.  
  134. short CStockTickerCtrl::GetTickerSpeed()
  135. {
  136.     short result;
  137.     GetProperty(0x2, VT_I2, (void*)&result);
  138.     return result;
  139. }
  140.  
  141. void CStockTickerCtrl::SetTickerSpeed(short propVal)
  142. {
  143.     SetProperty(0x2, VT_I2, propVal);
  144. }
  145.  
  146. /////////////////////////////////////////////////////////////////////////////
  147. // CStockTickerCtrl operations
  148.  
  149. void CStockTickerCtrl::AboutBox()
  150. {
  151.     InvokeHelper(0xfffffdd8, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
  152. }
  153.