0

I have an OCX and I use it in a Service and There is no visible form. It needs a form as a parent otherwise it's events is not fired How can I make the ocx to process messages and fire the event ?

Here is my code :

public AxKylixSMS SMS;

SMS = new AxKylixSMS();            

SMS.CreateControl();

SMS.NewDeliveryReport += new   _DKylixSMSEvents_NewDeliveryReportEventHandler(OnDeliveryReport);

OnDeliveryReport Event is not fired. How can I solve this problem ?

  • Almost any ActiveX control needs a host window to come alive. A typical failure mode of not hosting it is that it refuses to raise events. The message loop started by Application.Run() is also crucial. You can hide the window it lives in, see http://stackoverflow.com/a/3742980/17034 – Hans Passant Aug 04 '12 at 15:10

2 Answers2

0

use this to reference your form try :

public AxKylixSMS SMS;

SMS = new AxKylixSMS();            

SMS.CreateControl();

SMS.NewDeliveryReport += new   _DKylixSMSEvents_NewDeliveryReportEventHandler(this.OnDeliveryReport);
Hassan Boutougha
  • 3,871
  • 1
  • 17
  • 17
0

Usually ocx are made to work on winform but in your context you can communicate between your windows service and your winform using EventLog which is accessible by both: here a sample http://www.codeproject.com/Articles/4857/A-realtime-event-log-monitoring-tool

Hassan Boutougha
  • 3,871
  • 1
  • 17
  • 17