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

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