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

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1992, 1993 by Borland International
  3. //   source\owl\compat.cpp
  4. //----------------------------------------------------------------------------
  5. #include <owl\owldefs.h>
  6. #include <owl\compat.h>
  7. #include <owl\window.h>
  8.  
  9. struct TCurrentEvent {
  10.   TWindow*  Win;
  11.   UINT      Msg;
  12.   WPARAM    WParam;
  13.   LPARAM    LParam;
  14. };
  15.  
  16. extern TCurrentEvent  CurrentEvent;
  17.  
  18. TMessage _OWLFUNC
  19. __GetTMessage()
  20. {
  21.   TMessage  msg;
  22.  
  23.   msg.Receiver = CurrentEvent.Win->HWindow;
  24.   msg.Message = (WORD)CurrentEvent.Msg;
  25.   msg.WParam = (WORD)CurrentEvent.WParam;
  26.   msg.LParam = CurrentEvent.LParam;
  27.  
  28.   return msg;
  29. }
  30.  
  31. string
  32. TXCompatibility::MapStatusCodeToString(int statusCode)
  33. {
  34.   UINT resId;
  35.  
  36.   switch (statusCode) {
  37.     case EM_INVALIDCHILD:
  38.       resId = IDS_INVALIDCHILDWINDOW;
  39.       break;
  40.  
  41.     case EM_INVALIDCLIENT:
  42.       resId = IDS_INVALIDCLIENTWINDOW;
  43.       break;
  44.  
  45.     case EM_INVALIDMAINWINDOW:
  46.       resId = IDS_INVALIDMAINWINDOW;
  47.       break;
  48.  
  49.     case EM_INVALIDMODULE:
  50.       resId = IDS_INVALIDMODULE;
  51.       break;
  52.  
  53.     case EM_INVALIDWINDOW:
  54.       resId = IDS_INVALIDWINDOW;
  55.       break;
  56.  
  57.     default:
  58.       resId = IDS_UNKNOWNERROR;
  59.   }
  60.   return ResourceIdToString(0, resId);
  61. }
  62.  
  63. //
  64. // Constructor for exception signalled by setting TModule.Status or
  65. //   TWindow.Status to one of the EM_XXX values.
  66. //
  67. TXCompatibility::TXCompatibility(int statusCode)
  68.   : TXOwl(MapStatusCodeToString(statusCode)), Status(statusCode)
  69. {
  70. }
  71.  
  72. TXCompatibility::TXCompatibility(const TXCompatibility& src)
  73.   : TXOwl(src), Status(src.Status)
  74. {
  75. }
  76.  
  77. TXOwl*
  78. TXCompatibility::Clone()
  79. {
  80.   return new TXCompatibility(*this);
  81. }
  82.  
  83. int
  84. TXCompatibility::Unhandled(TModule*, unsigned)
  85. {
  86.   return Status;
  87. }
  88.  
  89. void
  90. TXCompatibility::Throw()
  91. {
  92.   THROW( *this );
  93. }
  94.  
  95. //
  96. // Internal function used to update the state of a TStatus.  Throw
  97. //   an exception if the updated status code is non-zero.
  98. //
  99. void
  100. TStatus::Set(int statusCode)
  101. {
  102.   if (StatusCode == 0)       // don't overwrite previous error code
  103.     StatusCode = statusCode;
  104.  
  105.   if (statusCode != 0)       // if non-zero, throw exception
  106.     THROW( TXCompatibility(statusCode) );
  107. }
  108.