473,383 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Referencing an managed class from an unmanaged class?


I need to fire an event from an unmanaged class. If I declare a pointer
to the managed class within the unmanaged class I get a compile error "

"cannot declare a managed 'm_pGps' in an unmanaged 'MyProgressNotifier'"
Any idea how I can do this?
--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Dec 30 '06 #1
6 4648
Here is what I need to do? I need top pass a pointer to the
MyProgressNotifier class to an unmanaged function. So the
MyProgressNotifier class cannot be managed. The NotifyTotal function
will be called from the mentioned unmanaged function.
class MyProgressNotifier : public GarXface4::ProgressNotifier
{

public:

MyProgressNotifier() :ProgressNotifier()
{
}
void NotifyTotal(int nTotal)
{
ProgressNotifier::NotifyTotal(nTotal);
// Fire managed event here

}
};

--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Dec 30 '06 #2
I have no idea Bruce. Though I don't code for a living, I would not
even mix unmanaged with managed code. Just start from a Tabula Rasa.

But do check something as fundamental as you are compiling with the
/clr option rather than /clr:safe option.

RL

Bruce wrote:
I need to fire an event from an unmanaged class. If I declare a pointer
to the managed class within the unmanaged class I get a compile error "

"cannot declare a managed 'm_pGps' in an unmanaged 'MyProgressNotifier'"
Any idea how I can do this?
--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Dec 30 '06 #3

"Bruce" <Br***@nospam.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>
I need to fire an event from an unmanaged class. If I declare a pointer
to the managed class within the unmanaged class I get a compile error "

"cannot declare a managed 'm_pGps' in an unmanaged 'MyProgressNotifier'"
Any idea how I can do this?
gcroot<mngd_class*>
>

--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com

Jan 1 '07 #4

"Ben Voigt" <rb*@nospam.nospamwrote in message
news:uV**************@TK2MSFTNGP02.phx.gbl...
>
"Bruce" <Br***@nospam.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>
I need to fire an event from an unmanaged class. If I declare a pointer
to the managed class within the unmanaged class I get a compile error "

"cannot declare a managed 'm_pGps' in an unmanaged 'MyProgressNotifier'"
Any idea how I can do this?

gcroot<mngd_class*>
Sorry, meant gcroot<mngd_class^>
>
>>

--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com


Jan 1 '07 #5
Ben Voigt wrote:
"Ben Voigt" <rb*@nospam.nospamwrote in message
>>>
>gcroot<mngd_class*>

Sorry, meant gcroot<mngd_class^>
Yes I finally found this in a search. Thank you. It is working perfectly.

Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Jan 1 '07 #6
Bruce wrote:
I need to fire an event from an unmanaged class. If I declare a pointer
to the managed class within the unmanaged class I get a compile error "
I have examples for both ways:

http://tweakbits.com/ManagedToUnmanagedCallback.cpp
http://tweakbits.com/UnmanagedToManagedCallback.cpp

Tom
Jan 4 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: david chang via DotNetMonster.com | last post by:
Hi, guys I am trapped into a big trouble on how to use unmanaged class library code in a C# web application. Now, I am working on a project to develop a web interface for SPlus, a statistical...
0
by: | last post by:
I am trying to use my unmanaged c++ class library in managed classes. So far everything seems to be ok, just passing on the __events from unmanaged to managed code using the __hook functions is a...
5
by: Chris Kiechel | last post by:
I am writing a .NET Windows application and it needs to perform DDE calls to a legacy system. I created a C++ unmanaged class that performs the actual DDE connection and communication. However,...
2
by: Brett Styles | last post by:
Hi Guys, I am trying to access a class in an unmanaged dll. I have created a wrapper managed class to access the functions I need but no matter what I try from the MSDN samples I can not get it to...
1
by: Sasha Nikolic | last post by:
I have defined a managed class ( __gc ) and a unmanaged ( __nogc ) in a separate files (but in the same vc++ dotnet project). I have no problem of referencing the unmanaged class from the menaged...
2
by: Sasha Nikolic | last post by:
I have one unmanaged and one managed class in the same vc++ project. Managed object creates one instance of unmanaged class and needs to pass a callback reference so that unmanaged class can...
2
by: bonk | last post by:
Hello, I have a managed type that defines an Event as one of its public members. Is it possible for an unmanaged c++ class to register to that event ? How can an unmanaged classmethod be called...
3
by: Thorsten | last post by:
HI I'm a C# developer and unfortunately I have to write now some code in managed and unmanaged C++. In this area I'm Newbie and therefore please forgive me if this is a really simple...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.