home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / CURSOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  1.8 KB  |  71 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Implementation of GDI Cursor object class
  6. //----------------------------------------------------------------------------
  7. #include <owl/owlpch.h>
  8. #include <owl/gdiobjec.h>
  9.  
  10. DIAG_DECLARE_GROUP(OwlGDI);        // General GDI diagnostic group
  11.  
  12. TCursor::TCursor(HCURSOR handle, TAutoDelete autoDelete)
  13. :
  14.   TGdiBase(handle, autoDelete)
  15. {
  16. }
  17.  
  18. #if defined(BI_PLAT_WIN32)
  19. TCursor::TCursor(HINSTANCE, const TCursor& cursor)
  20. {
  21.   Handle = (HCURSOR)::CopyIcon((HICON)(HCURSOR)cursor);
  22.   CheckValid();
  23. }
  24. #else
  25. TCursor::TCursor(HINSTANCE instance, const TCursor& cursor)
  26. {
  27.   Handle = ::CopyCursor(instance, cursor);
  28.   CheckValid();
  29. }
  30. #endif
  31.  
  32. TCursor::TCursor(HINSTANCE instance, TResId resId)
  33. {
  34.   PRECONDITION(resId);
  35.   Handle = ::LoadCursor(instance, resId);
  36.   ShouldDelete = (instance != 0);
  37.   CheckValid();
  38. }
  39.  
  40. TCursor::TCursor(HINSTANCE instance, const TPoint& hotSpot, const TSize& size,
  41.                  void far* andBits, void far* xorBits)
  42. {
  43.   PRECONDITION(andBits && xorBits);
  44.   Handle = ::CreateCursor(instance, hotSpot.x, hotSpot.y, size.cx, size.cy,
  45.                           andBits, xorBits);
  46.   CheckValid();
  47. }
  48.  
  49. #if defined(BI_PLAT_WIN32)
  50. TCursor::TCursor(const void* resBits, uint32 resSize)
  51. {
  52.   PRECONDITION(resBits && resSize);
  53.   Handle = ::CreateIconFromResource((PBYTE)resBits, resSize, false, 0x00030000);
  54.   CheckValid();
  55. }
  56.  
  57. TCursor::TCursor(const ICONINFO* iconInfo)
  58. {
  59.   PRECONDITION(iconInfo);
  60.   //iconInfo->fIcon = false;
  61.   Handle = ::CreateIconIndirect((PICONINFO)iconInfo);
  62.   CheckValid();
  63. }
  64. #endif
  65.  
  66. TCursor::~TCursor()
  67. {
  68.   if (ShouldDelete)
  69.     ::DestroyCursor((HCURSOR)Handle);
  70. }
  71.