home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / OWLSRC.PAK / CURSOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.7 KB  |  114 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.7  $
  6. //
  7. // Implementation of TCursor, a GDI Cursor object class
  8. //----------------------------------------------------------------------------
  9. #include <owl/pch.h>
  10. #if !defined(OWL_GDIOBJEC_H)
  11. # include <owl/gdiobjec.h>
  12. #endif
  13.  
  14. OWL_DIAGINFO;
  15. DIAG_DECLARE_GROUP(OwlGDI);        // General GDI diagnostic group
  16.  
  17. //
  18. //
  19. //
  20. TCursor::TCursor(HCURSOR handle, TAutoDelete autoDelete)
  21. :
  22.   TGdiBase(handle, autoDelete)
  23. {
  24.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor constructed @" << (void*)this <<
  25.     " from handle " << uint(handle));
  26. }
  27.  
  28. #if defined(BI_PLAT_WIN32)
  29. //
  30. //
  31. //
  32. TCursor::TCursor(HINSTANCE, const TCursor& cursor)
  33. {
  34.   Handle = (HCURSOR)::CopyIcon((HICON)(HCURSOR)cursor);
  35.   CheckValid();
  36.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor @" << (void*)this <<
  37.     " copied from TCursor " << (void*)&cursor);
  38. }
  39. #else
  40. //
  41. //
  42. //
  43. TCursor::TCursor(HINSTANCE instance, const TCursor& cursor)
  44. {
  45.   Handle = ::CopyCursor(instance, cursor);
  46.   CheckValid();
  47.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor @" << (void*)this <<
  48.     " copied from TCursor " << (void*)&cursor);
  49. }
  50. #endif
  51.  
  52. //
  53. //
  54. //
  55. TCursor::TCursor(HINSTANCE instance, TResId resId)
  56. {
  57.   PRECONDITION(resId);
  58.   Handle = ::LoadCursor(instance, resId);
  59.   ShouldDelete = (instance != 0);
  60.   CheckValid();
  61.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor @" << (void*)this <<
  62.     " loaded from resource " << resId);
  63. }
  64.  
  65. //
  66. //
  67. //
  68. TCursor::TCursor(HINSTANCE instance, const TPoint& hotSpot, const TSize& size,
  69.                  void far* andBits, void far* xorBits)
  70. {
  71.   PRECONDITION(andBits && xorBits);
  72.   Handle = ::CreateCursor(instance, hotSpot.x, hotSpot.y, size.cx, size.cy,
  73.                           andBits, xorBits);
  74.   CheckValid();
  75.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor @" << (void*)this << " created from bits ");
  76. }
  77.  
  78. #if defined(BI_PLAT_WIN32)
  79. //
  80. //
  81. //
  82. TCursor::TCursor(const void* resBits, uint32 resSize)
  83. {
  84.   PRECONDITION(resBits && resSize);
  85.   Handle = ::CreateIconFromResource((PBYTE)resBits, resSize, false, 0x00030000);
  86.   CheckValid();
  87.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor @" << (void*)this <<
  88.     " created from bits (32)");
  89. }
  90.  
  91. //
  92. //
  93. //
  94. TCursor::TCursor(const ICONINFO* iconInfo)
  95. {
  96.   PRECONDITION(iconInfo);
  97.   //iconInfo->fIcon = false;
  98.   Handle = ::CreateIconIndirect((PICONINFO)iconInfo);
  99.   CheckValid();
  100.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor constructed indirectly @" << (void*)this);
  101. }
  102.  
  103. #endif
  104.  
  105. //
  106. //
  107. //
  108. TCursor::~TCursor()
  109. {
  110.   if (ShouldDelete && Handle)
  111.     ::DestroyCursor((HCURSOR)Handle);
  112.   TRACEX(OwlGDI, OWL_CDLEVEL, "TCursor destructed @" << (void*)this);
  113. }
  114.