Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 22nd, 2003, 08:46 PM
roy roy is offline
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Define events in COM built in .NET

Hi everyone.
I built in .NET a 'class library' project , which then I
compiled with "Register for COM interop".
I also added some events.

I use this component in VB6, but I can't hook up to the
events.
Can someone please help?

In the .NET component's code, I tried to define events in
      2 different ways:
1."
  public delegate void ClickedEventHandler(string val);
  public event ClickedEventHandler Clicked;
  and then...
  if(Clicked!=null) Clicked(txt.value);
  "

2. [InterfaceTypeAttribute
(ComInterfaceType.InterfaceIsDual)]
    public interface IMonitorEvent
      {
         void HandleMonitorEvent(bool IsEmergency);
      }


Then, in order to hook up to those events in VB6:
1. I added a refernce in VB6 to the component.
2. I created instance
   "
    Dim MyObj As ContainerForIE.Form1
    Set MyObj = CreateObject("ContainerForIE.Form1")
    MyObj.Show
   "
3. I tried to use
   "Public WithEvents MyObj As ContainerForIE.Form1"
   But it raises an error "Object does not source
   automation events"

Can anyone help please?


Reply With Quote
  #2 (permalink)  
Old October 22nd, 2003, 11:07 PM
roy roy is offline
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need to basically declare an interface, provide a GUID to that
interface, make it IDispatch based and use ComSourceInterfaces() to
assign that interface as the event interface. Then use delegates to
point to the methods exposed by the interface.

If you did not understand what I am talking about, check out MSDN for
"Raising Events handled by COM Sink" topic. In VS.NET 2003 its in,
ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconraisingeventshandledbycomsink.htm
HTH.



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fire events of a Active X dll in ASP.NET Brijendra Pandey ASP.NET 3.5 Professionals 1 October 4th, 2008 05:44 PM
reg: built in classes in dot net framework m_kali2000 General .NET 1 October 10th, 2004 11:13 AM
events module in Building an asp.net intranet nickm All Other Wrox Books 1 August 25th, 2004 01:07 PM
VS.net Question : Protected with Events shahchi1 VS.NET 2002/2003 2 May 23rd, 2004 08:06 AM



All times are GMT -4. The time now is 05:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.