BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Calling .Net code

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Bob Piskac
Guest





PostPosted: Sun Oct 15, 2006 7:39 am    Post subject: Calling .Net code Reply with quote



I wrote a simple C++ application to call a .NET c# assembly that ruturned a
c# string. Is it possible to have a .NET control work on my win32 window?
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Oct 16, 2006 10:31 pm    Post subject: Re: Calling .Net code Reply with quote



"Bob Piskac" <bob (AT) pbsoftware (DOT) com> wrote in message
news:45319f54$1 (AT) newsgroups (DOT) borland.com...

Quote:
I wrote a simple C++ application to call a .NET c# assembly that ruturned
a c# string. Is it possible to have a .NET control work on my win32
window?


In what way exactly? Please be more specific.

Have you read the MSDN documentation yet about hosting the .NET runtime in
your application?

Hosting the Common Language Runtime

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhostingcommonlanguageruntime.asp


Gambit
Back to top
Bob Piskac
Guest





PostPosted: Wed Oct 25, 2006 1:12 am    Post subject: Re: Calling .Net code Reply with quote



Remy Lebeau (TeamB) wrote:
Quote:

In what way exactly? Please be more specific.


Simple example. I want to display a managed code button in my unmanaged
CPP application.


Quote:
Have you read the MSDN documentation yet about hosting the .NET runtime in
your application?

Hosting the Common Language Runtime

http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhostingcommonlanguageruntime.asp


Gambit



No, I will read it.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Oct 25, 2006 1:44 am    Post subject: Re: Calling .Net code Reply with quote

"Bob Piskac" <bob (AT) pbsoftware (DOT) com> wrote in message
news:453e737f$1 (AT) newsgroups (DOT) borland.com...

Quote:
I want to display a managed code button in my unmanaged CPP application.

Managed controls can only (officially) appear inside of other managed
controls and managed windows. There is no direct access available to
specify an unmanaged owner window for a managed control. So you will need
to either have your unmanaged application tell the assembly to show its own
managed window, or else you will have to use PInvoke to call the Win32 API
SetParent() function to reparent the managed control's Handle to an
unmanaged parent window.


Gambit
Back to top
Bob Piskac
Guest





PostPosted: Wed Oct 25, 2006 5:45 pm    Post subject: Re: Calling .Net code Reply with quote

Let me see if I understand correctly....

1) From my unmanaged CPP application I call PInvoke and pass my window
handle.
2) In my .NET class function I get the handle as a parameter and call
the win32 API SetParent().

It's that easy?

Remy Lebeau (TeamB) wrote:
Quote:
"Bob Piskac" <bob (AT) pbsoftware (DOT) com> wrote in message
news:453e737f$1 (AT) newsgroups (DOT) borland.com...

I want to display a managed code button in my unmanaged CPP application.

Managed controls can only (officially) appear inside of other managed
controls and managed windows. There is no direct access available to
specify an unmanaged owner window for a managed control. So you will need
to either have your unmanaged application tell the assembly to show its own
managed window, or else you will have to use PInvoke to call the Win32 API
SetParent() function to reparent the managed control's Handle to an
unmanaged parent window.


Gambit

Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Oct 25, 2006 10:14 pm    Post subject: Re: Calling .Net code Reply with quote

"Bob Piskac" <bob (AT) pbsoftware (DOT) com> wrote in message
news:453f5c29$1 (AT) newsgroups (DOT) borland.com...

Quote:
From my unmanaged CPP application I call PInvoke and pass
my window handle.

PInvoke is a .NET function for calling unmanaged APIs. The .NET code will
have to use PInvoke in order to call SetParent() from the managed
environment. Your unmanaged environment has direct access to SetParent().
Your .NET code will have to export its own function that the unmanaged code
can call. Unless you have access to the .NET Control object in your
unmanaged code, in which case the unmanaged code can access the
Control.Handle property and then make the call to SetParent().


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.