Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ ATL COM Events
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
Edited 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
0 OriginalGriff 534
1 Gihan Liyanage 298
2 RyanDev 260
3 Sergey Alexandrovich Kryukov 223
4 Richard Deeming 185
0 Sergey Alexandrovich Kryukov 8,936
1 OriginalGriff 7,891
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 1 Dec 2011
Copyright © CodeProject, 1999-2014
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