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 / .NET Framework / Interop / May 2006

Tip: Looking for answers? Try searching our database.

Is this possible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mitch@bmtmis.demon.co.uk - 02 May 2006 12:43 GMT
In a c# client I have the following:

double [] data = {1.0,2.0,3.0,4.0};

I have an OCX wriiten in c++ using dev studio 6.0.

Can I pass the array to the OCX? How would you do this?

I've looked and looked and failed so far. Is it possible?

Thanks,
Mitch.
yoga weazel - 10 May 2006 15:44 GMT
How are you using the OCX?  If you just use the IDE to import the COM control
into .NET it generates the aximp.exe output for you.  Once you have the
control instance you can invoke methods on it just like any other object.  
For example, say you OCX control is call MyControlLib.MyControl.  The wrapper
class would be AxMyControlLib.AxMyControl so when you dropped the OCX control
onto you form in the designer behind the scenes an instance of
AxMyControlLib.AxMyControl would have been instantiated in the codebehind and
added to the form just like any .NET control.  You can use this member
instance to call methods of your control.

Now if the method you want to call is not public you will have to either
modify the wrapper class generated by AxImp (you can request C# source code
generated for the wrapper by AxImp.exe at the command line manually) or use
System.Reflection to get the MethodInfo instance you want to call and then
use MethodInfo.Invoke.  For example,

Type ctrlType = myControlInstance.GetType();
MethodInfo method = ctrlType.GetMethod("MyMethod", BinderFlags.NonPublic);
method.Invoke(myControlInstance, BindingFlags.InvokeMethod, null, args, null);

where args is an Object[] of the arguments passed to the method being called.
Take a look at System.Reflection namespace and System.Type class for more
info.

Mike

> In a c# client I have the following:
>
[quoted text clipped - 8 lines]
> Thanks,
> Mitch.

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.