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?

Signature
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
Bruce - 30 Dec 2006 03:54 GMT
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
}
};

Signature
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com
raylopez99 - 30 Dec 2006 09:34 GMT
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
> 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 "
[quoted text clipped - 7 lines]
> GarXface OCX and C++ Class Library for the Garmin GPS
> www.stempsoft.com
Ben Voigt - 01 Jan 2007 16:50 GMT
> 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*>
Ben Voigt - 01 Jan 2007 16:58 GMT
>> 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 "
[quoted text clipped - 4 lines]
>
> gcroot<mngd_class*>
Sorry, meant gcroot<mngd_class^>
Bruce - 01 Jan 2007 19:13 GMT
> "Ben Voigt" <rbv@nospam.nospam> wrote 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
Tamas Demjen - 04 Jan 2007 19:38 GMT
> 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