|
-
Jan 13th, 2006, 10:07 AM
#1
Thread Starter
Junior Member
Howto call a form from a comclass
Hi,
I would like to develop a com-class which shows up a form, (e.g. an easy About-box, just to be very plain), and give the focus to that form. Now I have a project with a com-class and a about-class.
Somehow I cant show the about-form and give the focus to the form.
If someone could help me with an example I would be very pleased!
Roger
-
Jan 13th, 2006, 10:09 AM
#2
Re: Howto call a form from a comclass
can you explain what you mean by "com-class"
To me that sounds like a class dll written in a legacy language like VB6?
or do you mean something different?
-
Jan 13th, 2006, 10:23 AM
#3
Thread Starter
Junior Member
Re: Howto call a form from a comclass
I'm trying to understand VS2005
I've created a new project (ClassLibrary, so I can distribute the DLL) and added a COM-class (Project -> Add Class -> ComClass), so I could expose my code to other programming languages using ActiveX. By using a Sub in the COM-class I want to display a form with e.g. some buttons or just an ordinary about-box. Creating the com-class and access it from the outer world isn't the problem and is already working to call a function and return some values. However the problem is to show up the form and give the form the focus, so I could call a sub from the external application using active-x and do some stuff in VS2005 and than return to the external application.
-
Jan 13th, 2006, 10:37 AM
#4
Re: Howto call a form from a comclass
You would need to define this form class in the same assembly, or a referenced assembly, and then instantiate it from the COM class. This class may be visible to COM but it is still part of a .NET assembly so it is subject to the same rules and restrictions as any other .NET class. This is how you would do it in a fully .NET environment so it is still the way you must do it a mixed environment.
-
Jan 13th, 2006, 10:42 AM
#5
Thread Starter
Junior Member
Re: Howto call a form from a comclass
And how could I instantiate the form?
-
Jan 13th, 2006, 10:52 AM
#6
Re: Howto call a form from a comclass
The same way you create an instance of any form. I'm quite sure you've created forms before.
-
Jan 13th, 2006, 10:57 AM
#7
Re: Howto call a form from a comclass
E.g.
VB Code:
Dim myForm As New MyFormClass
myForm.Show()
-
Jan 13th, 2006, 11:09 AM
#8
Thread Starter
Junior Member
Re: Howto call a form from a comclass
I haven't got the show in the functionlist of form1, only:
.ActiveForm
.CheckForIllegalCrossThreadCalls
.DefaultBackColour
.DefaultForeColour
.DefaultFont
and some other... not the normal .show etc...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|