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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.8  $
  6. //
  7. // Implementation of TGdiBase, base abstract class for all GDI objects that
  8. // have Handles.
  9. //----------------------------------------------------------------------------
  10. #include <owl/pch.h>
  11. #if !defined(OWL_GDIBASE_H)
  12. # include <owl/gdibase.h>
  13. #endif
  14. #include <stdio.h>
  15.  
  16. OWL_DIAGINFO;
  17.  
  18. //
  19. // TGdiBase constructors
  20. //
  21. TGdiBase::TGdiBase()
  22. :
  23.   Handle(0),
  24.   ShouldDelete(true)
  25. {
  26.   // Handle must be set by derived class
  27. }
  28.  
  29. //
  30. //
  31. //
  32. TGdiBase::TGdiBase(HANDLE handle, TAutoDelete autoDelete)
  33. :
  34.   Handle(handle),
  35.   ShouldDelete(autoDelete==AutoDelete)
  36. {
  37.   PRECONDITION(handle);
  38. }
  39.  
  40. #pragma warn -par   // resId is never used in small model
  41. //
  42. //
  43. //
  44. void
  45. TGdiBase::CheckValid(uint resId)
  46. {
  47.   CheckValid(Handle, resId);
  48. }
  49.  
  50. //
  51. //
  52. //
  53. void
  54. TGdiBase::CheckValid(HANDLE handle, uint resId)
  55. {
  56.   if (!handle)
  57.     TXGdi::Raise(resId);
  58. }
  59. #pragma warn .par
  60.  
  61. //----------------------------------------------------------------------------
  62.  
  63. //
  64. // For backward compatibility
  65. //
  66. string
  67. TXGdi::Msg(uint resId, HANDLE handle)
  68. {
  69.   return MakeMessage(resId, uint(handle));
  70. }
  71.  
  72. //
  73. // Construct the object with a string resource and the handle
  74. //
  75. TXGdi::TXGdi(uint resId, HANDLE handle)
  76. :
  77.   TXOwl(MakeMessage(resId, uint(handle)), resId)
  78. {
  79. }
  80.  
  81. //
  82. // Clone the exception object for safe-throwing across Windows.
  83. //
  84. #if defined(BI_NO_COVAR_RET)
  85. TXBase*
  86. #else
  87. TXGdi*
  88. #endif
  89. TXGdi::Clone()
  90. {
  91.   return new TXGdi(*this);
  92. }
  93.  
  94. //
  95. // Throw the exception.
  96. //
  97. void
  98. TXGdi::Throw()
  99. {
  100.   THROW( *this );
  101. }
  102.  
  103. //
  104. // Throw the exception.
  105. //
  106. void
  107. TXGdi::Raise(uint resId, HANDLE handle)
  108. {
  109.   TXGdi(resId, handle).Throw();
  110. }
  111.