Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
alejanecz Absent Member.
Absent Member.
1136 views

Mapping events in COM object

Hello,

(thank you very much for reply on my first question. It works.)

I have this problem. I've been creating COM object in Visual COBOL that should create some visual object in window originally created in Dialog-System tool. I've been creating the COM object following way. I downloaded some COM object written in C# (including sources). Then I created code in managed COBOL that defines my COBOL COM object with some methods. I call these methods from my native COBOL code and these COM object methods call the C# COM object functions with parameters specified by my native COBOL code. Until this point everything works fine and the visual object is successfully created just as I want. But I'm not pretty sure how to join my COBOL COM object with the events of the C# COM object I need. I have class of COM object, interface for calling from native code and - and here I'm not sure if it's right - interface for events. But I don't know how to map the selected events or how to join method in my COM object class with event defined in the C# COM object.

Could anyone help me ? Thnx

Tags (2)
0 Likes
2 Replies
Micro Focus Expert
Micro Focus Expert

RE: Mapping events in COM object

Can you please clarify what you mean by COM here?

Is the C# class really registered as COM or is it a .NET class that is instantiated and invoked from within the managed COBOL class? How do you call into the C# class from managed COBOL?

Do you wish to handle the events fired in the C# class from within the managed COBOL piece which can then callback into native or do you wish to handle the events directly in native code?

You mention Dialog System. Are you still using Dialog System in your native application?

There are some examples in the Samples Browser under the Dialog System category that show how some of this functionality can be used. For example there is a demo that has a DS Window that hosts a .NET grid control and its events are trapped in the native control program using native OO syntax for using ActiveX control. One of the other examples shows how you can pass a native entry point to a managed class thru COM Interop and then call back into this entry point directly from managed code.

The following is an article from Microsoft that might also help.

support.microsoft.com/.../811645

Thanks,

0 Likes
alejanecz Absent Member.
Absent Member.

RE: Mapping events in COM object

I read your answer, studied many various codes and try to make it by myself but I failed. So...

The problem is that I want to create the ribbon object instead of window menu and toolbar into my application windows created by Dialog-System. So as I mentioned in previous post I wrote a native COBOL class for my application that serves as an interface (here it's not meant as COM object interface!) between the application and my own COM object written in managed COBOL. So this native COBOL class calls methods in the managed COBOL COM object class and this COM class inherits from the C# class (the C# object is just a .NET class, not regularly registered COM) of the ribbon object. I don't know if it's the best way how to do it but the ribbon object is created correctly just as I want. So creation is ok. And here starts the problem because I don't know if or when to use delegates of events, how to join it with my "IInterfaceEvent" or if an event could be caught without the delegates etc. I certainly took a look at the examples you mentioned in the Samples Browser but I didn't find what I needed. May be I should mention that I cannot interfere into the already created Dialog-System screensets - everything must be processed outside these screensets. As for the question whether I want to handle the events within the managed COBOL code or directly outside into the native COBOL code, better way is the managed code. But I certainly want to learn both ways. While I was taking a look at the example with window hosting the grid control, I noticed that in the event interface were defined some numeric ID values for all the events and in the native code these IDs were used for mapping those events to entry-points using "SetEventToEntry" method. That's ok but I still don't understand how the delegates, the "Fire..." methods and the declarations in the event interface are connected and HOW IT WORKS. And finally, I don't want to use entry-points but methods and doesn't matter if overriden, using delegates etc.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.