🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Bob Piskac Sun, 15 Oct 2006 02:39
Calling .Net code
#3122
Author: Bob Piskac
Date: Sun, 15 Oct 2006 02:39
2 lines
1060 bytes
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? 
Re: Calling .Net code
#3128
Author: Remy Lebeau (TeamB)
Date: Mon, 16 Oct 2006 17:31
19 lines
1496 bytes
"Bob Piskac" <bob@pbsoftware.com> wrote in message
news:45319f54$1@newsgroups.borland.com...

> 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
Re: Calling .Net code
#2970
Author: Bob Piskac
Date: Tue, 24 Oct 2006 20:12
22 lines
1447 bytes
Remy Lebeau (TeamB) wrote:
> 
> In what way exactly?  Please be more specific.
> 

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


> 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.
Re: Calling .Net code
#2971
Author: Remy Lebeau (TeamB)
Date: Tue, 24 Oct 2006 20:44
16 lines
1600 bytes
"Bob Piskac" <bob@pbsoftware.com> wrote in message
news:453e737f$1@newsgroups.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
Re: Calling .Net code
#2972
Author: Bob Piskac
Date: Wed, 25 Oct 2006 12:45
27 lines
2006 bytes
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:
> "Bob Piskac" <bob@pbsoftware.com> wrote in message
> news:453e737f$1@newsgroups.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
> 
> 
Re: Calling .Net code
#2974
Author: Remy Lebeau (TeamB)
Date: Wed, 25 Oct 2006 17:14
17 lines
1721 bytes
"Bob Piskac" <bob@pbsoftware.com> wrote in message
news:453f5c29$1@newsgroups.borland.com...

> 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads