将表单从一个vb 2010应用程序传递到另一个vb 2010应用程序 [英] Passing forms from one vb 2010 application to another vb 2010 application

查看:96
本文介绍了将表单从一个vb 2010应用程序传递到另一个vb 2010应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在使用VB 2010 Express.我正在开发用于处理我妻子的小生意的应用程序,因此它具有时间表跟踪,发票,费用和所有常规会计部分.

我正在尝试使其尽可能模块化,而我尝试的一种方法是让一个单独的应用程序根据需要生成每个需要的Windows窗体.我有一个主要的驱动程序应用程序.它要做的第一件事是用一个请求(一个简单的文本字符串)调用我的表单生成器来构建主菜单表单.然后,我想将该空表格(及其创建的控件)传递回驱动程序.它会显示出来,用户可以从中选择一个选项.
例如,假设他们要输入一周的时间表,驱动程序将调用时间表应用程序.该应用程序要做的第一件事是请求表单生成器使用数据网格将其构建为表单并将其传递回去.

表单生成器工作得非常好,目前它可以构建6或7个表单,所有表单都具有相同的控件,因此按钮是相同的,并且位于相同的位置,等等.

现在,问题了.无论如何,我找不到将生成的表单传回给调用者的方法.
我查看过内存文件等,但是显然您无法序列化表格.
我已经研究过路由,这似乎有些过分.

我已经找到了调用者来查找进程,并且可以成功获取窗口句柄,但是我一生都找不到说"MyForm = Discovered window handle.MainForm"的方法.

我要解决所有这些问题还是错过了什么?

我在旧的老式大型机上工作了35年以上,这似乎不应该是一项艰巨的任务,但是我正在努力.

我会发布一些代码,但我知道你们都会开始大笑:-)

为任何帮助加油,并保持出色的工作.

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.

推荐答案

我认为主要的问题是表单不仅是数据-还是与数据的交互以事件,属性和方法的形式出现,没有它是没有用的.

这不是我会做的方式-并不是说这是错误的,或者您不会让它工作,但是我会使用DLL而不是单独的应用程序,例如在单个解决方案中将项目分开(如果您确实需要将多个项目作为单独的应用程序,则可以使用多个解决方案,尽管您也可以对项目进行处理),然后从其中一个DLL的基本表单派生我的表单-基本表单可以控件及其位置,但它们本身永远不会实例化-而是会创建派生的形式.

如果要在VB中处理常规"代码,则甚至不必考虑窗口句柄-表示您对我来说很不对劲.
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.


这篇关于将表单从一个vb 2010应用程序传递到另一个vb 2010应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆