473,503 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.dll and forms

Hi, how've you been?

I'm trying to do a .dll that would be able to manage forms from an
independient project. The dll has a method that receive a parameter which is
the form I want to manage. The problem is that I have to pass the instancied
form as parameter instead of its name. When I have to manage many forms, it
will be necessary to instance all forms, and it minus the performance of my
project.

What I do is:

myclass.mymethod(new form1).
myclass.mymethod(new form2).
myclass.mymethod(new form3).
....
myclass.mymethod(new formN).

How can I do to prevent this and pass as a parameter only the form name
instead of the instanced form? If I pass the class name I have an error.

I hope you understand my problem and my english.

Thanks.

Jaime Lucci
ja********@hotmail.com
Salta, Argentina
Nov 21 '05 #1
3 966
why don't you pass the form type as a string and use reflection to create
the instance of the form.

HTH

Ollie Riches

"Jaime Lucci" <ja********@hotmail.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
Hi, how've you been?

I'm trying to do a .dll that would be able to manage forms from an
independient project. The dll has a method that receive a parameter which
is
the form I want to manage. The problem is that I have to pass the
instancied
form as parameter instead of its name. When I have to manage many forms,
it
will be necessary to instance all forms, and it minus the performance of
my
project.

What I do is:

myclass.mymethod(new form1).
myclass.mymethod(new form2).
myclass.mymethod(new form3).
...
myclass.mymethod(new formN).

How can I do to prevent this and pass as a parameter only the form name
instead of the instanced form? If I pass the class name I have an error.

I hope you understand my problem and my english.

Thanks.

Jaime Lucci
ja********@hotmail.com
Salta, Argentina

Nov 21 '05 #2
Thanks a lot.
"Ollie Riches" <ol**********@phoneanalyser.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
why don't you pass the form type as a string and use reflection to create
the instance of the form.

HTH

Ollie Riches

"Jaime Lucci" <ja********@hotmail.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
Hi, how've you been?

I'm trying to do a .dll that would be able to manage forms from an
independient project. The dll has a method that receive a parameter which is
the form I want to manage. The problem is that I have to pass the
instancied
form as parameter instead of its name. When I have to manage many forms,
it
will be necessary to instance all forms, and it minus the performance of
my
project.

What I do is:

myclass.mymethod(new form1).
myclass.mymethod(new form2).
myclass.mymethod(new form3).
...
myclass.mymethod(new formN).

How can I do to prevent this and pass as a parameter only the form name
instead of the instanced form? If I pass the class name I have an error.

I hope you understand my problem and my english.

Thanks.

Jaime Lucci
ja********@hotmail.com
Salta, Argentina


Nov 21 '05 #3
Jaime Lucci wrote:
Hi, how've you been?
Not particularly happy, but that's irrelevant here
I'm trying to do a .dll that would be able to manage forms from an
independient project. The dll has a method that receive a parameter
which is the form I want to manage. The problem is that I have to
pass the instancied form as parameter instead of its name. When I
have to manage many forms, it will be necessary to instance all
forms, and it minus the performance of my project.


Have you tested this out?

You see, when you create a form with new, you don't actually create the
window. All you do is create the form object and hence any objects it
has as fields. The actual window (and any controls it contains) is not
created until the form is first made visible. If you do not make the
form visible before passing it to your method then the window will not
be created. Note that Visual Studio designers use InitializeComponent to
do most of the initialization. If you move that out of the constructor
to a public method then when you create the form object the fields will
not be initialized, so you do not get that overhead. Your method can
simply call the public initialization method before it makes the form
visible.

The alternative, using reflection, is likely to have fairly poor
performance because every access to the form object will require a call
through reflection.

Given the choice I would *not* use reflection in this situation, instead
I would pass the uninitialized, not-yet-made-visible form object.

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
4065
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
2267
by: Joshua Russell | last post by:
Hi, Both the methods below open up a windows form called MasterForm. However, one works better than the other. Method 1 opens the form correctly but I don't have any reference to the instance of...
7
2454
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
13
5547
by: MD | last post by:
I have been converting a program from VB6 to VB.Net and enhancing it as well. All has been progressing OK although its been hard work. Now, all of a sudden, when I try to execute a ShowDialog()...
15
2029
by: Joshua Kendall | last post by:
I have a script in which it keeps opening the same form instead of only one instance. I also need help with a form that has a password. Where do I put the actual password? can I use a database for...
3
1628
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. ...
8
2702
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
3
2357
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes...
6
2554
by: dbuchanan | last post by:
I have a Windows Forms application that accesses SQL Server 2k from a small local network. The application has been used for weeks on other systmes but a new install on a new machine retruns...
21
3287
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.