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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // (C) Copyright 1992, 1994 by Borland International, All Rights Reserved
  4. //
  5. //   Implementation of TGdiBase, base abstract GDI object class
  6. //----------------------------------------------------------------------------
  7. #include <owl/owlpch.h>
  8. #include <owl/gdibase.h>
  9.  
  10. //
  11. // TGdiBase constructors
  12. //
  13. TGdiBase::TGdiBase()
  14. :
  15.   Handle(0),
  16.   ShouldDelete(true)
  17. {
  18.   // Handle must be set by derived class
  19. }
  20.  
  21. TGdiBase::TGdiBase(HANDLE handle, TAutoDelete autoDelete)
  22. :
  23.   Handle(handle),
  24.   ShouldDelete(autoDelete==AutoDelete)
  25. {
  26.   PRECONDITION(handle);
  27. }
  28.  
  29. #pragma warn -par   // resId is never used in small model
  30. void
  31. TGdiBase::CheckValid(uint resId)
  32. {
  33.   CheckValid(Handle, resId);
  34. }
  35.  
  36. void
  37. TGdiBase::CheckValid(HANDLE handle, uint resId)
  38. {
  39.   if (!handle)
  40.     THROW( TXGdi(resId) );
  41. }
  42. #pragma warn .par
  43.  
  44. string
  45. TGdiBase::TXGdi::Msg(unsigned resId, HANDLE handle)
  46. {
  47.   bool   found;  // did we locate the string
  48.   string rscMsg = ResourceIdToString(&found, resId);
  49.  
  50.   if (found) {
  51.     char buf[255];
  52.  
  53.     // supply Handle of gdi object if we have one
  54.     //
  55.     wsprintf(buf, rscMsg.c_str(), handle);
  56.     return string(buf);
  57.   }
  58.   else
  59.     return rscMsg;
  60. }
  61.  
  62. TGdiBase::TXGdi::TXGdi(unsigned resId, HANDLE handle)
  63. :
  64.   TXOwl(Msg(resId, handle), resId)
  65. {
  66. }
  67.  
  68. TXOwl*
  69. TGdiBase::TXGdi::Clone()
  70. {
  71.   return new TXGdi(*this);
  72. }
  73.  
  74. void
  75. TGdiBase::TXGdi::Throw()
  76. {
  77.   THROW( *this ); 
  78. }
  79.