Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2006, 11:28 AM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Implementing Callback Functions Via ConnectionPoin

I need to create a COM object and write some callback functions.. I can do it on VBScript but i need to do it in C#.

For example to do it on VBScript:

Set myVar = WScript.CreateObject("Company.Object", "Handle_");

After that I just need to write callback functions which have "Handle_" prefix. So how to this in C#?


 
Old September 11th, 2006, 01:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

A quick reply,

Is it a windowed control, that u could drop on a form?
If u can drop it on a form, you will get all the events
listed for the control and you can easily add a handler
for them.

Do write back if you r still stuck. Its solvable.

Regards
Ankur
 
Old September 11th, 2006, 01:31 PM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No, it's a console application. Let me say a little more about it. I have a SDK from some company which gives me some additional functions to operate with disks. In order to use it, i need to create a COM object. I have several samples writte in VBScript and JScript, and it also should work in C# but there is no any help about it. To create a COM object in C# i use the following code:
object myVar = Activator.CreateInstance(Type.GetTypeFromProgID("C ompany.Object"));

And it works. But now i also need to write some callback functions. I have a VBScript sample, where they create COM like that:
Set myVar = WScript.CreateObject("Company.Object", "Handle_");

So i just need to rewrite this line in C#, but i don't know how. It also written that i can implement callback functions via ConnectionPoint. Maybe i should create a COM object as always and the connect to it somehow?



 
Old September 14th, 2006, 03:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Well in C# its a bit easier. Just do one of the following

1) If its a windowed control, i.e. if the control has a UI, add it to your tool
box and than drop it on your application windows. Its events will be listed in
the property window, you can add a handler to those events from there.

2) If it is a simple object with no UI, just add the control dll as a reference
to your project. In the class view of Solution exlorer expend the referered
control lib till you get the object you want to use. You will see that as
you click the object you wanna use, its methods and events will be listed
in a box just under solution explorer. With that information you
can add a handler to the events in the code something like this.

        void CallBackHandler()
        {
            MessageBox.Show("Called Back");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            AnSimpCMLib.SimpOb ss = new AnSimpCMLib.SimpOb();
            ss.CallBzack += new AnSimpCMLib._ISimpObEvents_CallBzackEventHandler(t his.CallBackHandler);
            ss.CallMe();
        }

Do write back.

Regards
Ankur





Similar Threads
Thread Thread Starter Forum Replies Last Post
charpter 4 callback feature mlcy BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 4 July 10th, 2008 05:16 PM
callback implementation aranjan ASP.NET 2.0 Basics 1 August 20th, 2007 09:46 PM
Callback in 3 DropDownLists Paula222 ASP.NET 2.0 Professional 3 December 13th, 2006 08:53 AM
Remoting Callback Error maheshgv All Other Wrox Books 1 December 5th, 2005 03:33 PM
Worldpay Callback Script Countach1976 PHP Databases 3 January 1st, 2005 10:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.