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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.7  $
  6. //
  7. // OWL 1.0 compatibility structures & functions
  8. //----------------------------------------------------------------------------
  9. #include <owl/pch.h>
  10. #if !defined(OWL_COMPAT_H)
  11. # include <owl/compat.h>
  12. #endif
  13. #if !defined(OWL_WINDOW_H)
  14. # include <owl/window.h>
  15. #endif
  16.  
  17. OWL_DIAGINFO;
  18.  
  19. TMessage _OWLFUNC
  20. __GetTMessageWin(TWindow* win)
  21. {
  22.   TMessage  msg;
  23.   TCurrentEvent& currentEvent = win->GetCurrentEvent();
  24.  
  25.   msg.Receiver = currentEvent.Win->GetHandle();
  26.   msg.Message = (uint16)currentEvent.Message;
  27.   msg.WParam = (uint16)currentEvent.Param1;
  28.   msg.LParam = currentEvent.Param2;
  29.  
  30.   return msg;
  31. }
  32.  
  33. //
  34. //
  35. //
  36. string
  37. TXCompatibility::MapStatusCodeToString(int statusCode)
  38. {
  39.   uint resId;
  40.  
  41.   switch (statusCode) {
  42.     case EM_INVALIDCHILD:
  43.       resId = IDS_INVALIDCHILDWINDOW;
  44.       break;
  45.  
  46.     case EM_INVALIDCLIENT:
  47.       resId = IDS_INVALIDCLIENTWINDOW;
  48.       break;
  49.  
  50.     case EM_INVALIDMAINWINDOW:
  51.       resId = IDS_INVALIDMAINWINDOW;
  52.       break;
  53.  
  54.     case EM_INVALIDMODULE:
  55.       resId = IDS_INVALIDMODULE;
  56.       break;
  57.  
  58.     case EM_INVALIDWINDOW:
  59.       resId = IDS_INVALIDWINDOW;
  60.       break;
  61.  
  62.     default:
  63.       resId = IDS_UNKNOWNERROR;
  64.   }
  65.   return ResourceIdToString(0, resId);
  66. }
  67.  
  68. //
  69. // Constructor for exception signalled by setting TModule.Status or
  70. //   TWindow.Status to one of the EM_XXX values.
  71. //
  72. TXCompatibility::TXCompatibility(int statusCode)
  73. :
  74.   TXOwl(MapStatusCodeToString(statusCode)),
  75.   Status(statusCode)
  76. {
  77. }
  78.  
  79. //
  80. //
  81. //
  82. TXCompatibility::TXCompatibility(const TXCompatibility& src)
  83. :
  84.   TXOwl(src),
  85.   Status(src.Status)
  86. {
  87. }
  88.  
  89. #if defined(BI_NO_COVAR_RET)
  90. TXBase*
  91. #else
  92. TXCompatibility*
  93. #endif
  94. TXCompatibility::Clone()
  95. {
  96.   return new TXCompatibility(*this);
  97. }
  98.  
  99. //
  100. //
  101. //
  102. int
  103. TXCompatibility::Unhandled(TModule*, unsigned)
  104. {
  105.   return Status;
  106. }
  107.  
  108. //
  109. //
  110. //
  111. void
  112. TXCompatibility::Throw()
  113. {
  114.   THROW( *this );
  115. }
  116.  
  117. //
  118. // Internal function used to update the state of a TStatus.  Throw
  119. //   an exception if the updated status code is non-zero.
  120. //
  121. void
  122. TStatus::Set(int statusCode)
  123. {
  124.   if (StatusCode == 0)       // don't overwrite previous error code
  125.     StatusCode = statusCode;
  126.  
  127.   if (statusCode != 0)       // if non-zero, throw exception
  128.     THROW( TXCompatibility(statusCode) );
  129. }
  130.