1

我试图在TADOConnection. 我读过这篇那篇文章

我已经实现TEventDispatcher了这样的课程。

#include <utilcls.h>
#include <ADOInt.hpp>

class EventHandler : public TEventDispatcher<EventHandler,&DIID_ConnectionEvents>
{
private:
  bool connected;
  TForm1 *theform;
  _Connection* server;
protected:
  HRESULT InvokeEvent(DISPID id, TVariant *params);
public:
  EventHandler();
  ~EventHandler();
  void Connect(TForm1 *form, _Connection* srv);
  void Disconnect();
};

EventHandler::EventHandler()
{
  connected = false;
  theform = NULL;
}

EventHandler::~EventHandler()
{
  if (connected)
    Disconnect();
}

执行

EventHandler *handler = new EventHandler();

HRESULT EventHandler::InvokeEvent(DISPID id, TVariant *params)
{
 String data = WideString(*params);
 ShowMessage("InvokeEvent : "+IntToStr(id)+" "+data);
}

void EventHandler::Connect(TForm1 *form, _Connection* srv)
{
  theform = form;

  server = srv;
  server->AddRef();
  ConnectEvents(server);
}

void EventHandler::Disconnect()
{
  DisconnectEvents(server);
  server->Release();
}

我正在尝试使用这样的 EventHandler 类。

handler->Connect(this,ADOConnection1->ConnectionObject);

sql server 手动停止时为什么不调用类InvokeEvent的方法?EventHandler

4

0 回答 0