home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WEVENTSP.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  4KB  |  128 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.     public:
  31.         static WEventGeneratorSpy *GetSpy();
  32.         static WBool               CanSpy( const WObject *o );
  33.         static const WChar        *EventName( WEventID id, const WChar *unknownName=NULL );
  34.  
  35.     protected:
  36.         WEventGeneratorSpy();
  37.  
  38.         virtual void EventNotice( WEventID id, WEventNotice type );
  39.  
  40.     public:
  41.         virtual ~WEventGeneratorSpy();
  42.  
  43.     private:
  44.         static WEventGeneratorSpy _spy;
  45.         static WBool              _canSpy;
  46. };
  47.  
  48.  
  49. struct WSpyDLLParameters {
  50.     WWindow *   window;         // Window that the spy message was sent to
  51.     WMessage    message;
  52. };
  53.  
  54. /*************************************************************************
  55.  *
  56.  * WSpyDLL -- provides a mechanism to load .dll's into running Optima++
  57.  *            applications.
  58.  *
  59.  *
  60.  * A Spy DLL should have an entry point of the form
  61.  *
  62.  *     extern "C" __declspec(dllexport)
  63.  *         WLong __stdcall WSpyDLLEntryPoint( WSpyDLLParameters & );
  64.  *
  65.  * The WLong that this entry point returns is the return value of
  66.  * SendSpyLoadDLLMessage.
  67.  *
  68.  *************************************************************************/
  69.  
  70. typedef WLong __stdcall (*WSpyDLLEntryPointFN)( WSpyDLLParameters & parameters );
  71. #define WSPYDLLENTRYPOINT   WTEXT("_WSpyDLLEntryPoint@4")
  72.  
  73. class WCMCLASS WSpyDLL : public WObject {
  74.     public:
  75.         /**************************************************************
  76.          * Properties
  77.          **************************************************************/
  78.  
  79.         //
  80.         // AllowSpyDLLLoad
  81.         //
  82.         //   If TRUE, this allows other applications to load a .dll
  83.         //   into
  84.  
  85.         static WBool    GetAllowSpyDLLLoad();
  86.         static WBool    SetAllowSpyDLLLoad( WBool allow );
  87.  
  88.         /**************************************************************
  89.          * Methods
  90.          **************************************************************/
  91.  
  92.         //
  93.         // BroadcastSpyLoadDLLMessage
  94.         //
  95.         //  Request that a dll specified by 'dll' be loaded into all
  96.         //  Optima++ windowed applications.  The WSpyDLLEntryPoint
  97.         //  function will be called once for each top-level window
  98.         //  in each Optima++ application.
  99.  
  100.         static WLong    BroadcastSpyLoadDLLMessage( const WString & dll );
  101.  
  102.         //
  103.         // SendSpyLoadDLLMessage
  104.         //
  105.         //  Send a message to a particular window to load a spy dll.
  106.         //  Call the WSpyDLLEntryPoint function in the remote process,
  107.         //  and return the WLong result.
  108.  
  109.         static WLong    SendSpyLoadDLLMessage( WWindowHandle win, const WString & dll );
  110.  
  111.     public:
  112.         /**************************************************************
  113.          * Internal
  114.          **************************************************************/
  115.  
  116.         static WLong    ExecuteSpyMessage( WWindow *, const WMessage & );
  117.     private:
  118.         static WBool    _allowSpyDLLLoad;
  119. };
  120.  
  121.  
  122. #ifndef _WNO_PRAGMA_PUSH
  123. #pragma enum pop;
  124. #pragma pack(pop);
  125. #endif
  126.  
  127. #endif // _WEVENTSP_HPP_INCLUDED
  128.