Alaska Software Inc. - Publishing COM Events
Username: Password:
AuthorTopic: Publishing COM Events
Roger DonnayPublishing COM Events
on Sun, 20 Jan 2008 13:47:19 -0700
I'm not sure what is the correct terminology for this in C#, but what I am 
trying to do is "publish" or "expose" events on .NET controls to the Xbase++ 
program when I create an ActiveX control.

I have been successful at creating ActiveX controls in C#, making the 
controls public so I can read and write their iVars and methods, but I have 
not been successful at getting the events to be visible to the Xbase++ 
program.

For example, I would like the MonthCalendar control to send it's 
DateSelected event to Xbase++, so I can use it as follows:

oControl:dateSelected := {||DoSomething()}

It is very confusing in all the C# documentation I have read on how to 
accomplish this.

Any help?

on

on

on

on

on

on

on

on
Roger DonnayRe: Publishing COM Events
on Mon, 21 Jan 2008 11:48:16 -0700
> perhaps i will help you that OLAF870 did have made a
> .NET Sample working with Xbase++. Search in Newsgroup.

I looked at his sample program.

It doesn't use any events.
Olaf870Re: Publishing COM Events
on Sat, 26 Jan 2008 13:45:55 +0100
Hi,
> It doesn't use any events.
For good reason: I tried a long time to do exacly this, but I dont suceed. 
It seems that it is not possible, to subscibe to events in .Net-assemblies 
from Xbase++.

But I have found another possibily to communicate with .Net-assemblies. 
Events can call C++-dlls, and from there it is possible to call every 
function in Xbase-programs. But I dont know, if this kind of program design 
is good for everybody.

If somebody has a better solution for the event-subscribe-problem, I would 
be glad to be informed too.

regards
Olaf870

PS:A really a good calendar has written J.A. Diego Kerejeta. Pure Xbase++ 
and 50 times as fast as ?_PopDate()
Roger DonnayRe: Publishing COM Events
on Mon, 28 Jan 2008 19:29:08 -0700
Olaf -

Till Warweg of Alaska helped me out with this, but I still don't quite have 
it working yet.
I will post a solution and a sample program when it is completed.

Roger

"Olaf870" <_RemoveThis_Olaf870 (at) yahoo.de> wrote in message 
news:342ac37a$59434b2e$38f2@news.alaska-software.com...
> Hi,
>> It doesn't use any events.
> For good reason: I tried a long time to do exacly this, but I dont 
> suceed. It seems that it is not possible, to subscibe to events in 
> .Net-assemblies from Xbase++.
>
> But I have found another possibily to communicate with .Net-assemblies. 
> Events can call C++-dlls, and from there it is possible to call every 
> function in Xbase-programs. But I dont know, if this kind of program 
> design is good for everybody.
>
> If somebody has a better solution for the event-subscribe-problem, I would 
> be glad to be informed too.
>
> regards
> Olaf870
>
> PS:A really a good calendar has written J.A. Diego Kerejeta. Pure Xbase++ 
> and 50 times as fast as ?_PopDate()
>
>
Olaf870Re: Publishing COM Events
on Wed, 30 Jan 2008 11:03:57 +0100
Roger,
thanks in advance. If you like you can forward me Tills informations, 
perhaps I can help.
regards
Olaf

"Roger Donnay" <rogerdonnay@donnay-software.com> schrieb im Newsbeitrag 
news:332fb893$7a89abae$118a@news.alaska-software.com...
> Olaf -
>
> Till Warweg of Alaska helped me out with this, but I still don't quite 
> have it working yet.
> I will post a solution and a sample program when it is completed.
>
> Roger
>
> "Olaf870" <_RemoveThis_Olaf870 (at) yahoo.de> wrote in message 
> news:342ac37a$59434b2e$38f2@news.alaska-software.com...
>> Hi,
>>> It doesn't use any events.
>> For good reason: I tried a long time to do exacly this, but I dont 
>> suceed. It seems that it is not possible, to subscibe to events in 
>> .Net-assemblies from Xbase++.
>>
>> But I have found another possibily to communicate with .Net-assemblies. 
>> Events can call C++-dlls, and from there it is possible to call every 
>> function in Xbase-programs. But I dont know, if this kind of program 
>> design is good for everybody.
>>
>> If somebody has a better solution for the event-subscribe-problem, I 
>> would be glad to be informed too.
>>
>> regards
>> Olaf870
>>
>> PS:A really a good calendar has written J.A. Diego Kerejeta. Pure Xbase++ 
>> and 50 times as fast as ?_PopDate()
>>
>>
>
>
Roger DonnayRe: Publishing COM Events
on Sat, 02 Feb 2008 11:50:52 -0700
Olaf -

Thru Till's efforts I have been successful at getting push button events to 
publish correctly and I can now interact perfectly in the Xbase++ program by 
catching pushbutton click events.

I am trying to determine why I can only make this work with pushbuttons and 
not other objects.

My form has 2 buttons, 1 label and 1 checkbox.

I would like to subscribe to events from the label and checkbox but have not 
beens successful.

The below code compiles perfectly and runs perfectly, however the 
CheckedChanged Event is not getting published.

oForm:isEventPublished('ButtonClick') returns a 1 as expected.
oForm:isEventPublished('CheckedChanged') returns a 0 instead of a 2.

I haven't been able to figure out why.

Roger

-----------------------------

Namespace DonnayTest1
{
[Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface UserControl1Events
{
[DispId(2)]
void CheckedChanged(int n, object o);
[DispId(1)]
void ButtonClick( int n, object o );
}
public delegate void ButtonClickDelegate( int n, object o );
public delegate void CheckedChangedDelegate( int n, object o );
[Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
ComSourceInterfaces(typeof(UserControl1Events)),
ClassInterface(ClassInterfaceType.AutoDual)]
public partial class UserControl1 : System.Windows.Forms.UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void UserControl1_Load(object sender, EventArgs e)
{
}
public event ButtonClickDelegate ButtonClick;
public event CheckedChangedDelegate CheckedChanged;

public void button1_Click(object sender, EventArgs e)
{
ButtonClick(1,this.button1);
}
public void label1_Click(object sender, EventArgs e)
{
}
public void button2_Click(object sender, EventArgs e)
{
ButtonClick(2,this.button2);
}
public void checkBox1_CheckedChanged(object sender, EventArgs e)
{
label1.Text = "Clicky";
CheckedChanged(1, this.checkBox1);
}
}
}
Roger DonnayRe: Publishing COM Events
on Sat, 02 Feb 2008 14:19:34 -0700
I think I figured it out.
It had to do with the way I registered the control with REGASM.

Everything seems to work ok when I use the /tlb option.

Now that I'm on the right track, I'm going to put together a small demo of 
using an ActiveX control written in C#
in an eXpress++ application.


"Roger Donnay" <rogerdonnay@donnay-software.com> wrote in message 
news:660e2e06$60b02696$1c7@news.alaska-software.com...
> Olaf -
>
> Thru Till's efforts I have been successful at getting push button events 
> to publish correctly and I can now interact perfectly in the Xbase++ 
> program by catching pushbutton click events.
>
> I am trying to determine why I can only make this work with pushbuttons 
> and not other objects.
>
> My form has 2 buttons, 1 label and 1 checkbox.
>
> I would like to subscribe to events from the label and checkbox but have 
> not beens successful.
>
> The below code compiles perfectly and runs perfectly, however the 
> CheckedChanged Event is not getting published.
>
> oForm:isEventPublished('ButtonClick') returns a 1 as expected.
> oForm:isEventPublished('CheckedChanged') returns a 0 instead of a 2.
>
> I haven't been able to figure out why.
>
> Roger
>
> -----------------------------
>
> Namespace DonnayTest1
> {
> [Guid("7BD20046-DF8C-44A6-8F6B-687FAA26FA71"),
> InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
> public interface UserControl1Events
> {
> [DispId(2)]
> void CheckedChanged(int n, object o);
> [DispId(1)]
> void ButtonClick( int n, object o );
> }
> public delegate void ButtonClickDelegate( int n, object o );
> public delegate void CheckedChangedDelegate( int n, object o );
> [Guid("0D53A3E8-E51A-49C7-944E-E72A2064F938"),
> ComSourceInterfaces(typeof(UserControl1Events)),
> ClassInterface(ClassInterfaceType.AutoDual)]
> public partial class UserControl1 : System.Windows.Forms.UserControl
> {
> public UserControl1()
> {
> InitializeComponent();
> }
> private void UserControl1_Load(object sender, EventArgs e)
> {
> }
> public event ButtonClickDelegate ButtonClick;
> public event CheckedChangedDelegate CheckedChanged;
>
> public void button1_Click(object sender, EventArgs e)
> {
> ButtonClick(1,this.button1);
> }
> public void label1_Click(object sender, EventArgs e)
> {
> }
> public void button2_Click(object sender, EventArgs e)
> {
> ButtonClick(2,this.button2);
> }
> public void checkBox1_CheckedChanged(object sender, EventArgs e)
> {
> label1.Text = "Clicky";
> CheckedChanged(1, this.checkBox1);
> }
> }
> }
>
Nestor GuidoRe: Publishing COM Events
on Tue, 22 Jan 2008 11:39:15 +0200
Roger,

Just shooting in the dark. If the name of the function that handles this 
event within c# is called monthCalendar1_DateSelected ..then shouldn't the 
method address it by the same name? Also it is being passed arguements. So 
maybe the code should be looking as follows:

oControl:monthCalendar1_DateSelected({|oSender, aDateRangeEventArgs| 
DoSomething(oSender,aDateRangeEventArgs )})

Kind Regards,
Nestor

"Roger Donnay" <rogerdonnay@donnay-software.com> wrote in message 
news:1d9da8fd$e631690$387@news.alaska-software.com...
>I still believe that the problem exists in the C# program.
> I don't know how to get an event to be COM visible.
> I tried every method of ActiveXControl() and AutomationObject() to try to 
> get the DISPID of the event but could not.
>
>
>
Hubert Brandel Re: Publishing COM Events
on Fri, 11 Apr 2008 13:58:59 +0200
Roger Donnay schrieb:
> I'm not sure what is the correct terminology for this in C#, but what I am 
> trying to do is "publish" or "expose" events on .NET controls to the Xbase++ 
> program when I create an ActiveX control.
> 
> I have been successful at creating ActiveX controls in C#, making the 
> controls public so I can read and write their iVars and methods, but I have 
> not been successful at getting the events to be visible to the Xbase++ 
> program.
> 
> For example, I would like the MonthCalendar control to send it's 
> DateSelected event to Xbase++, so I can use it as follows:
> 
> oControl:dateSelected := {||DoSomething()}
> 
> It is very confusing in all the C# documentation I have read on how to 
> accomplish this.
> 
> Any help?
> 
> 
> 


----------------

Ich empfehle:  www.xbaseforum.de  (in deutsch)

Homepage:

German  - www.familie-brandel.de/index.htm
English - www.familie-brandel.de/index_e.htm
mark carew Re: Publishing COM Events
on Sun, 13 Apr 2008 18:52:51 +1000
On Fri, 11 Apr 2008 13:58:59 +0200, Hubert Brandel wrote:

> Roger Donnay schrieb:
>> I'm not sure what is the correct terminology for this in C#, but what I am 
>> trying to do is "publish" or "expose" events on .NET controls to the Xbase++ 
>> program when I create an ActiveX control.
>> 
>> I have been successful at creating ActiveX controls in C#, making the 
>> controls public so I can read and write their iVars and methods, but I have 
>> not been successful at getting the events to be visible to the Xbase++ 
>> program.
>> 
>> For example, I would like the MonthCalendar control to send it's 
>> DateSelected event to Xbase++, so I can use it as follows:
>> 
>> oControl:dateSelected := {||DoSomething()}
>> 
>> It is very confusing in all the C# documentation I have read on how to 
>> accomplish this.
>> 
>> Any help?
>> 
>> 
>>

You have to place the attribute [ComVisible] above the class definition
that you wish to make com visible to xbase++
e.g.

---------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Tools.Applications.Runtime;

namespace ChildBatch
{
    [ComVisible(true)]
    public class webBatch
    {
         default constructor
        public webBatch()
        {
        }

         firstly send a request and get back a refid for later querying  
        public string webRequestId(string docType, string sCNumb, string
lang, string responseForm , string cUser , string cPass )
        {
            long retId;

            try
------------------------------------------
Then you xbase++ program must employ creatobject using the
namespace.class constructor that you require... and the rest is a project
that requires a budget

Mark
  
function doChildBookData(cEs4,cScnum)
  
  local oWebReference
  local cRetVal
  
  oWebReference := createObject( "childbatch.webbatch" )
  *
  cRetVal := oWebReference:getSC_SCSTATServices(cEs4,cScnum)
  *
  msgBox(cRetVal,"SC STAT Services for " + cEs4 + cScnum)
  *
  cRetVal := oWebReference:getSC_SCPRIMServices(cEs4,cScnum)
  *
  oWebReference:destroy()
  *
  msgBox(cRetVal,"SC PRIM Services for " + cEs4 + cScnum)
  *
return nil