Click here to Skip to main content
12,398,000 members (49,264 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ ATL COM event
I am doing an ATL Project in VC++ 2005 to use as ActiveX in VB6. I added methods, properties and events following the steps in this tutorial: A Beginner Tutorial for Writing Simple COM/ATL DLL and Using it with .NET [^]. Everything is working fine while I'm working inside the class. But now I need to call an event or method of the class but from a global method?

How can I do this?

Thanks.
Posted 28-Nov-11 0:31am
Updated 28-Nov-11 1:25am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

What language do you want to make the call from a global function?

If you mean VB6, you will need to reference your new COM object in your VB6 project, and create an instance of the COM object like this:


Dim objA as New YourATLComObjectName
 
objA.YourFunction()

If you mean C++, you will need to call ::CoCreateInstance with the GUID for your object.

The two things you will need in place to make sure your VB project can see the object:

1) The DLL needs to be registered which happens by default when VS compiles it. When you install it on a users machine you use regsvr32.
2) The DLL needs to be referenced as one of the resources that you bring into your project.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Please use the forum at the end of the article so the author can see it.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Use scope resolution operator ( :: ) to access the global variables
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 1 Dec 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100