home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / connect / mdrive / driver.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  2KB  |  87 lines

  1. // Driver.cpp : Implementation of CDriveApp and DLL registration.
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12.  
  13. #include "premdriv.h"
  14. #include "..\connect.h"
  15. #include "Driver.h"
  16.  
  17. extern HDC hDrawDC;
  18. extern int nHeight;
  19. extern int nThreads;
  20.  
  21. /////////////////////////////////////////////////////////////////////////////
  22. //
  23.  
  24. STDMETHODIMP CDriver::Fire(long l)
  25. {
  26.     m_cs.Lock();
  27.     foo pos;
  28.     if (!m_mapPos.Lookup(l, pos))
  29.     {
  30.         m_mapPos[l] = foo();
  31.     }
  32.     COLORREF cr = RGB(255,255,255);
  33.     switch (l)
  34.     {
  35.     case 0:
  36.         cr = RGB(255,0,0);
  37.         break;
  38.     case 1:
  39.         cr = RGB(0,255,0);
  40.         break;
  41.     case 2:
  42.         cr = RGB(0,0,255);
  43.         break;
  44.     case 3:
  45.         cr = RGB(255,255,0);
  46.         break;
  47.     case 4:
  48.         cr = RGB(255,0,255);
  49.         break;
  50.     case 5:
  51.         cr = RGB(0,255,255);
  52.         break;
  53.     case 6:
  54.         cr = RGB(64,64,64);
  55.         break;
  56.     case 7:
  57.         cr = RGB(128,128,128);
  58.         break;
  59.     case 8:
  60.         cr = RGB(192,192,192);
  61.         break;
  62.     case 9:
  63.         cr = RGB(0,0,0);
  64.         break;
  65.     }
  66.     int nH = nHeight/nThreads;
  67.     if (pos.nDir == 1)
  68.         SetPixel(hDrawDC, m_nID, nH*l+pos.nPos, cr);
  69.     else
  70.         SetPixel(hDrawDC, m_nID, nH*l+pos.nPos, RGB(0,0,0));
  71.     pos.nPos += pos.nDir;
  72.     if (pos.nPos >= nH)
  73.     {
  74.         pos.nDir = -1;
  75.         pos.nPos = nH-1;
  76.     }
  77.     if (pos.nPos <= -1)
  78.     {
  79.         pos.nDir = 1;
  80.         pos.nPos = 0;
  81.     }
  82.     m_mapPos[l] = pos;
  83.     m_cs.Unlock();
  84.     GdiFlush();
  85.     return S_OK;
  86. }
  87.