Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / January 2007

Tip: Looking for answers? Try searching our database.

Referencing an managed class from an unmanaged class?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bruce - 30 Dec 2006 03:47 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?

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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.