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

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