Class Library with form

Blake81

Well-known member
Joined
Feb 23, 2006
Messages
304
Location
Georgia, USA
Programming Experience
1-3
I'm trying to make a class library with a form that includes a Windows Media Encoder object. This is going to be another mIRC DLL. The DLL part probably won't have much to it. I'm just trying to add webcam support to mIRC, so the DLL just needs to send the person's IP address, and start/stop commands to the WME object. I can't set a startup object in a class library, so is there a way to have Form1 load when the right parameter is passed? Also, is there a way to reference the Windows Media Player control (used to view the other cam) from the class library? I need to do this because the URL for WMP to connect to will be the other person's IP. Thanks. I hope I explained that clearly. If you need any more explanation, let me know.
 
If you're creating a class library then your assembly will contain types that can be used by other assemblies. That means that some external assembly will have to create an instance of one of the types in your library. If you want this form to be displayed when that's done then you have to do that in the constructor of that type. Otherwise you'd have to do it in a method of that type that will be called by the external assembly. The class library knows nothing about the assembly that is using it unless that assembly chooses to tell it, which it would do by passing references into the objects that it creates from your types. Otherwise your assembly is completely in the dark about its environment.
 
I'm pretty new with working with class libraries, and I'm not sure exactly what you mean. The external application will be mIRC, which isn't capable of making Windows forms. Since the class library project let me add a form, it seems like there should be a way to load the form from the class, unless I'm mistaken and it's just so that the form can use the class library. The functions in the class library don't allow me to create Windows Media Encoder objects either, so I'm not sure how to handle it. Basically, I just want mIRC to pass an IP address to the DLL, and then at a later point, a string like "cam on" or "cam off". I'd then like the DLL to show a form which would have a Windows Media Player object showing the remote cam. Is this possible? Sorry for not understanding too well, and thanks for any help.

I just had an idea, but I need to ask to make sure it would work. Could I create a Windows application and be able to run it and call a function in it from another application? I'm thinking I could just create the form as a separate program that would run when the mIRC script is executed, and then to start the cam, I could pass an IP address to the app and have it show the video on the form.
 
Last edited:
I got this partly working, which leads me to believe that I'm on the right track and that it can be done. I have registered the forms application with COM and I can succesfully open a COM connection with mIRC. This is just a simple test, and what I'd like to do for the test is just change the text of a label in the open application. However, in mIRC, it's just echoing "hello" and not changing the label. Can anyone see where the problem is? Here's my code:
VB.NET:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2][COLOR=#000000] Form1[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Default[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property[/COLOR][/SIZE][SIZE=2] SetLabel([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] labeltext [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Set[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] value [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])
Label1.Text = labeltext
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Set
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Get
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Get
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Property
End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class
[/COLOR][/SIZE][/COLOR][/SIZE]
The mIRC help has four methods you can use when calling a COM object. You can use a combination of all four. I'm not sure which one(s) to use, or even if I'm writing the form code properly, since I've never used a property before. The mIRC script is returning a 0, I think meaning it isn't calling the form code properly. Any help would be appreciated. Here's the mIRC code.
/testcom {
var %a = hello
$com(test,SetLabel,8,bstr,%a)
echo -a $com(test).result
}

Oops, forgot to add the four methods:
method - Combination of the following values added together:
1 = DISPATCH_METHOD
2 = DISPATCH_PROPERTYGET
4 = DISPATCH_PROPERTYPUT
8 = DISPATCH_PROPERTYPUTREF
 
Back
Top