| View previous topic :: View next topic |
| Author |
Message |
Bob Piskac Guest
|
Posted: Sun Oct 15, 2006 7:39 am Post subject: Calling .Net code |
|
|
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
|
Posted: Mon Oct 16, 2006 10:31 pm Post subject: Re: Calling .Net code |
|
|
"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
|
Posted: Wed Oct 25, 2006 1:12 am Post subject: Re: Calling .Net code |
|
|
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.
No, I will read it. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Oct 25, 2006 1:44 am Post subject: Re: Calling .Net code |
|
|
"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
|
Posted: Wed Oct 25, 2006 5:45 pm Post subject: Re: Calling .Net code |
|
|
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
|
Posted: Wed Oct 25, 2006 10:14 pm Post subject: Re: Calling .Net code |
|
|
"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 |
|
 |
|