Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi I am using VB 2010 express. I am developing an application to handle my wife's little business so it has timesheet tracking, invoicing, expenses and all the usual accounting parts.

I am trying to make this as modular as possible and one method I was trying was to have a separate application to generate each windows form that will be needed, on demand. I have a main Driver application. The first thing it does is call my form builder with a request ( a simple text string) to build the main menu form. Then I want to pass that empty form (with it's created controls) back to the Driver. It gets displayed and the user selects an option from it.
As an example, let's say they want to enter time-sheets for the week, the Driver calls the Time-sheet application. The first thing this application does is request the Form Builder to build it a form with a data grid and pass it back.

The Form Builder works really well and currently it builds 6 or 7 forms, all with identically laid out controls, so the buttons are the same and in the same place etc.

Now, the problem. I cannot find anyway to pass this generated form back to the caller.
I have looked at Memory files, etc, but apparently you cannot serialize a form.
I have looked into routing and that seems like overkill.

I have got the caller to find the process and I can get the window handle successfully but I cannot for the life of me find a way of saying "MyForm = Discovered window handle.MainForm"

Am I going about this all wrong or have I missed something ?

I have worked for over 35 years on old archaic mainframes and it seems that this should not be a difficult task, but I am struggling.

I would post some code, but I know you would all just start laughing :-)

Cheers for any help, and keep up this great work.
Posted
Comments
Sergey Alexandrovich Kryukov 5-Nov-12 14:46pm    
I don't think this is a good idea. You need to modularize, but the form is a pretty bad unit for it. There are better boundaries between modules.
--SA

1 solution

I think the major problem is that a Form is not just data - it is also an interaction with data in the form of events, properties and methods, without which it is useless.

It's not the way I would have done it - which isn't to say it's wrong, or that you won't get it to work, but I would have used DLLs rather than separate applications, as separate projects in a single solution (or multiple solutions if you really need them as separate applications, though you can do that with projects as well), and derived my forms from a base form in one of the DLLs - the base form would have handled the controls and their location, but would never have been instantiated itself - the derived forms would have been created instead.

If you are dealing with "normal" code in VB, you should never have to even consider window handles - that you are indicates that there is something very wrong to me.
 
Share this answer
 
Comments
Sandeep Mewara 5-Nov-12 15:44pm    
Comment from OP:
Ah that's a shame. The Form Builder works a charm.
Ok. Onto DLLs and that particular uncharted territory.

I guess that's why I got into this programming lark in the first place, to find out how they workSmile | :)

Cheers for answering so quickly.

If I get no other answers, I will come back and mark yours up as the solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900