home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / DIAGXPRT.PAK / CBACK.CPP next >
Text File  |  1995-08-29  |  2KB  |  71 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1993 by Borland International
  3. //----------------------------------------------------------------------------
  4.  
  5. // Because we are called from toolhelp on another task data segment, it is
  6. // critical to overide the default entry code settings here in order to
  7. // force it to: ds!=ss and explicit export:
  8. //
  9. #pragma option  -WE
  10.  
  11. #include <owl\owlpch.h>
  12. #include  "diagxprt.h"
  13.  
  14. //
  15. // Callback is just used for correctly adjusting the data segment - this
  16. // function being MakeProcInstance'd by SetupWindow(). This is critical
  17. // because TOOLHELP calls this function on the other task data segment.
  18. // Then it calls TDiagClient::NotifyCallback thru the static "this" pointer.
  19. //
  20. BOOL FAR PASCAL __export
  21. Callback(WORD id, DWORD data) {
  22.   // Now that the data segment is correctly set to our task's, call it:
  23.   //
  24.   switch (id) {
  25.  
  26. #if 0  // This seems to be redundant
  27.     case NFY_LOGPARAMERROR: {
  28.       NFYLOGPARAMERROR FAR *param = (NFYLOGPARAMERROR FAR *)data;
  29.       TDispData* d = new TDispData;
  30.  
  31.       strcpy(d->ProcName, TDiagClient::pThis->GetProcName(param->lpfnErrorAddr));
  32.  
  33.       strcpy(d->ModuleName, TDiagClient::pThis->GetTaskName());
  34.  
  35.       d->ErrorCode = ((NFYLOGPARAMERROR FAR*)data)->wErrCode;
  36.       d->Param = ((NFYLOGPARAMERROR FAR*)data)->lpBadParam;
  37.  
  38.       TDiagClient::pThis->PostMessage(CM_LOGPARAMERROR,0,(LPARAM)d);
  39.       break;
  40.     }
  41. #endif
  42.  
  43.     case NFY_LOGERROR: {
  44.       TDispData *d = new TDispData;
  45.  
  46.       strcpy(d->ModuleName, TDiagClient::pThis->GetTaskName());
  47.       
  48.       d->ErrorCode = ((NFYLOGERROR FAR*)data)->wErrCode;
  49.       d->Data = (DWORD)((NFYLOGERROR FAR*)data)->lpInfo;
  50.       TDiagClient::pThis->PostMessage(CM_LOGERROR, 0, (LPARAM)d);
  51.       break;
  52.     }
  53.  
  54.     case NFY_OUTSTR: {
  55.       TDispData *d=new TDispData;
  56.  
  57.       char far *dStr = (LPSTR)data;
  58.       strcpy( d->ProcName, dStr);
  59.       TDiagClient::pThis->PostMessage(CM_OUTSTR, 0, (LPARAM)d);
  60.       break;
  61.     }
  62.  
  63.     default:
  64.       // Other toolhelp notifications can be handled.
  65.       // Make sure that diagxprt.cpp is updated to match
  66.       // TDiagClient::pThis->PostMessage(CM_DEFAULT, id, 0);
  67.       break;
  68.   }
  69.   return FALSE;
  70. }
  71.