home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / CURSOR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  1.8 KB  |  70 lines

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