home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / chplus / cpp / 5 / Komponety.exe / ibctrls.h < prev    next >
C/C++ Source or Header  |  1998-02-09  |  5KB  |  140 lines

  1. //---------------------------------------------------------------------------
  2. // Borland C++Builder
  3. // Copyright (c) 1987, 1998 Borland International Inc.  All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. #ifndef IbctrlsH
  6. #define IbctrlsH
  7. //----------------------------------------------------------------------------
  8. #include <Bde.hpp>
  9. #include <DBtables.hpp>
  10. #include <Dialogs.hpp>
  11. #include <Forms.hpp>
  12. #include <Controls.hpp>
  13. #include <Graphics.hpp>
  14. #include <Classes.hpp>
  15. #include <Messages.hpp>
  16. #include <Windows.hpp>
  17. #include <SysUtils.hpp>
  18. #include <System.hpp>
  19. #include  "ibproc32.h"
  20.  
  21. namespace Ibctrls
  22. {
  23. //-- type declarations -------------------------------------------------------
  24. class TIBComponent : public Classes::TComponent
  25. {
  26. private:
  27.     TDatabase *FDatabase;
  28.     void __fastcall SetDatabase(TDatabase *value);
  29.  
  30. protected:
  31.     void __fastcall ValidateDatabase(TDatabase *Database);
  32.     System::Pointer __fastcall GetNativeHandle(void);
  33.     void __fastcall HandleIBErrors(Ibproc32::pstatus_vector status);
  34.     bool __fastcall IsInterbaseDatabase(TDatabase *Database);
  35.  
  36. __published:
  37.     __property TDatabase * Database = {read=FDatabase, write=SetDatabase, nodefault};
  38. public:
  39.     __fastcall virtual TIBComponent(Classes::TComponent *AOwner) : Classes::TComponent(
  40.         AOwner) { }
  41.     __fastcall virtual ~TIBComponent(void) { }
  42. };
  43.  
  44. typedef void __fastcall (__closure *TEventAlert)(System::TObject *Sender,  System::AnsiString EventName,
  45.           long EventCount, bool &CancelAlerts);
  46.  
  47. typedef char TEventBuffer[15][64];
  48.  
  49. class TIBEventAlerter : public TIBComponent
  50. {
  51. private:
  52. public:
  53.     int LibHandle;
  54.     Classes::TStrings *FEvents;
  55.     TEventAlert FOnEventAlert;
  56.     bool FQueued;
  57.     bool FRegistered;
  58.     char Buffer[15][64];
  59.     bool Changing;
  60.     Windows::TRTLCriticalSection CS;
  61.     char *EventBuffer;
  62.     int EventBufferLen;
  63.     long EventID;
  64.     int EventThreadID;
  65.     bool ProcessingEvents;
  66.     bool RegisteredState;
  67.     char * ResultBuffer;
  68.     void __fastcall DoQueueEvents(void);
  69.     void __fastcall EventChange(System::TObject *sender);
  70.     void __fastcall UpdateResultBuffer( int length, System::PChar updated);
  71.  
  72. protected:
  73. public:
  74.     void __fastcall HandleEvent(void);
  75.     virtual void __fastcall Loaded(void);
  76.     virtual void __fastcall Notification(Classes::TComponent *AComponent, Classes::TOperation Operation
  77.         );
  78.     void __fastcall SetEvents(Classes::TStrings *value);
  79.     void __fastcall SetDatabase(TDatabase *value);
  80.     void __fastcall SetRegistered(bool value);
  81.  
  82. public:
  83.     __fastcall virtual TIBEventAlerter(Classes::TComponent *AOwner);
  84.     __fastcall virtual ~TIBEventAlerter(void);
  85.     void __fastcall CancelEvents(void);
  86.     void __fastcall QueueEvents(void);
  87.     void __fastcall RegisterEvents(void);
  88.     void __fastcall UnRegisterEvents(void);
  89.     __property bool Queued = {read=FQueued, nodefault};
  90.  
  91. __published:
  92.     __property Classes::TStrings * Events = {read=FEvents, write=SetEvents, nodefault};
  93.     __property bool Registered = {read=FRegistered, write=SetRegistered, nodefault};
  94.     __property TEventAlert OnEventAlert = {read=FOnEventAlert, write=FOnEventAlert};
  95. };
  96.  
  97. class EIBError : public Sysutils::Exception
  98. {
  99. public:
  100.     __fastcall EIBError(const System::AnsiString Msg) : Sysutils::Exception(Msg
  101.         ) { }
  102.     __fastcall EIBError(const System::AnsiString Msg, const TVarRec *Args,
  103.         const int Args_Size) : Sysutils::Exception(Msg, Args, Args_Size) { }
  104.     __fastcall EIBError(int Ident) : Sysutils::Exception(Ident
  105.         ) { }
  106.     __fastcall EIBError(int Ident, const TVarRec *Args, const
  107.         int Args_Size) : Sysutils::Exception(Ident, Args, Args_Size) { }
  108.     __fastcall EIBError(const System::AnsiString Msg, int AHelpContext
  109.         ) : Sysutils::Exception(Msg, AHelpContext) { }
  110.     __fastcall EIBError(const System::AnsiString Msg, const TVarRec *Args
  111.         , const int Args_Size, int AHelpContext) : Sysutils::Exception(Msg, Args,
  112.         Args_Size, AHelpContext) { }
  113.     __fastcall EIBError( int Ident, int AHelpContext
  114.         ) : Sysutils::Exception(Ident, AHelpContext) { }
  115.     __fastcall EIBError( int Ident, const TVarRec *Args,
  116.         const int Args_Size, int AHelpContext) : Sysutils::Exception(Ident, Args,
  117.         Args_Size, AHelpContext) { }
  118.  
  119.     __fastcall virtual ~EIBError(void) { }
  120. };
  121.  
  122. //-- var, const, procedure ---------------------------------------------------
  123. #define  MaxEvents             15
  124. #define  EventLength           64
  125. #define  SIBMessageBase        57800
  126. #define  SNoEventsRegistered   SIBMessageBase + 0
  127. #define  SInvalidDBConnection  SIBMessageBase + 1
  128. #define  SInvalidDatabase      SIBMessageBase + 2
  129. #define  SInvalidCancellation  SIBMessageBase + 3
  130. #define  SInvalidEvent         SIBMessageBase + 4
  131. #define  SInvalidQueueing      SIBMessageBase + 5
  132. #define  SInvalidRegistration  SIBMessageBase + 6
  133. #define  SMaximumEvents        SIBMessageBase + 7
  134. }       /* namespace Ibctrls */
  135. #if !defined(NO_IMPLICIT_NAMESPACE_USE)
  136. using namespace Ibctrls;
  137. #endif
  138. //-- end unit ----------------------------------------------------------------
  139. #endif  // IBCtrls
  140.