home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WEVENTSP.HPP < prev    next >
C/C++ Source or Header  |  1996-12-03  |  4KB  |  130 lines

  1. /*************************************************************************
  2.  *
  3.  * WEventGeneratorSpy
  4.  *
  5.  *************************************************************************/
  6.  
  7. #ifndef _WEVENTSP_HPP_INCLUDED
  8. #define _WEVENTSP_HPP_INCLUDED
  9.  
  10. #ifndef _WNO_PRAGMA_PUSH
  11. #pragma pack(push,8);
  12. #pragma enum int;
  13. #endif
  14.  
  15. #ifndef _WEVENT_HPP_INCLUDED
  16. #include "wevent.hpp"
  17. #endif
  18.  
  19. #define WSpyEvent WNotifyEvent
  20.  
  21. struct WCMCLASS WSpyEventData : public WEventData {
  22.     WBool       isBefore;   // set to TRUE before event is called, FALSE after
  23.     WBool       wasHandled; // after event is called, indicates if was handled
  24.     WBool       eatEvent;   // before event is called, set to TRUE to cancel
  25.     WEventData *eventData;  // actual event data that is being passed
  26. };
  27.  
  28. class WCMCLASS WEventGeneratorSpy : public WEventGenerator {
  29.  
  30.     friend class WEventGenerator;
  31.  
  32.     public:
  33.         static WEventGeneratorSpy *GetSpy();
  34.         static WBool               CanSpy( const WObject *o );
  35.         static const WChar        *EventName( WEventID id, const WChar *unknownName=NULL );
  36.  
  37.     protected:
  38.         WEventGeneratorSpy();
  39.  
  40.         virtual void EventNotice( WEventID id, WEventNotice type );
  41.  
  42.     public:
  43.         virtual ~WEventGeneratorSpy();
  44.  
  45.     private:
  46.         static WEventGeneratorSpy _spy;
  47.         static WBool              _canSpy;
  48. };
  49.  
  50.  
  51. struct WSpyDLLParameters {
  52.     WWindow *   window;         // Window that the spy message was sent to
  53.     WMessage    message;
  54. };
  55.  
  56. /*************************************************************************
  57.  *
  58.  * WSpyDLL -- provides a mechanism to load .dll's into running Optima++
  59.  *            applications.
  60.  *
  61.  *
  62.  * A Spy DLL should have an entry point of the form
  63.  *
  64.  *     extern "C" __declspec(dllexport)
  65.  *         WLong __stdcall WSpyDLLEntryPoint( WSpyDLLParameters & );
  66.  *
  67.  * The WLong that this entry point returns is the return value of
  68.  * SendSpyLoadDLLMessage.
  69.  *
  70.  *************************************************************************/
  71.  
  72. typedef WLong __stdcall (*WSpyDLLEntryPointFN)( WSpyDLLParameters & parameters );
  73. #define WSPYDLLENTRYPOINT   WTEXT("_WSpyDLLEntryPoint@4")
  74.  
  75. class WCMCLASS WSpyDLL : public WObject {
  76.     public:
  77.         /**************************************************************
  78.          * Properties
  79.          **************************************************************/
  80.  
  81.         //
  82.         // AllowSpyDLLLoad
  83.         //
  84.         //   If TRUE, this allows other applications to load a .dll
  85.         //   into
  86.  
  87.         static WBool    GetAllowSpyDLLLoad();
  88.         static WBool    SetAllowSpyDLLLoad( WBool allow );
  89.  
  90.         /**************************************************************
  91.          * Methods
  92.          **************************************************************/
  93.  
  94.         //
  95.         // BroadcastSpyLoadDLLMessage
  96.         //
  97.         //  Request that a dll specified by 'dll' be loaded into all
  98.         //  Optima++ windowed applications.  The WSpyDLLEntryPoint
  99.         //  function will be called once for each top-level window
  100.         //  in each Optima++ application.
  101.  
  102.         static WLong    BroadcastSpyLoadDLLMessage( const WString & dll );
  103.  
  104.         //
  105.         // SendSpyLoadDLLMessage
  106.         //
  107.         //  Send a message to a particular window to load a spy dll.
  108.         //  Call the WSpyDLLEntryPoint function in the remote process,
  109.         //  and return the WLong result.
  110.  
  111.         static WLong    SendSpyLoadDLLMessage( WWindowHandle win, const WString & dll );
  112.  
  113.     public:
  114.         /**************************************************************
  115.          * Internal
  116.          **************************************************************/
  117.  
  118.         static WLong    ExecuteSpyMessage( WWindow *, const WMessage & );
  119.     private:
  120.         static WBool    _allowSpyDLLLoad;
  121. };
  122.  
  123.  
  124. #ifndef _WNO_PRAGMA_PUSH
  125. #pragma enum pop;
  126. #pragma pack(pop);
  127. #endif
  128.  
  129. #endif // _WEVENTSP_HPP_INCLUDED
  130.