如何在 VB6 中最好地共享可嵌入表单?

发布于 2024-07-05 11:45:55 字数 343 浏览 4 评论 0原文

有没有一种好方法可以在 VB6 中创建一个可以轻松嵌入到其他表单中的表单?

最近有几次,我想设计和编码一个 Form 对象,我可以将其插入到其他几个“父”表单中。 我的目标是创建一段集中的代码,用于以特定方式管理多个 UI 组件,然后能够在多个地方使用该代码(UI 布局和逻辑)。 我当然愿意使用代码(而不是设计视图)来加载子表单。

到目前为止,我想到的最好的方法是将子窗体的所有有趣逻辑拉入类模块中,并让每个父窗体布置 UI(可能在 Picture 控件中)并将该 Picture 对象传递给类模块。 然后,类就知道如何对图片进行操作,并且假设所有预期的部分都已正确布置。 这种方法有几个缺点,我想要更优雅的方法。

Is there a good way to create a form in VB6 that can easily be embedded inside other forms?

On a few occasions recently, I've wanted to design and code a Form object that I could plug into several other "parent" forms. My goal is to create a centralized piece of code for managing several UI components in a particular way, and then be able to use that (both the UI layout and the logic) in more than one place. I'm certainly willing to use code (rather than the Design View) to load the child form.

The best I've come up with so far is to pull all of the interesting logic for the child form into a Class Module, and have each parent form lay out the UI (in a Picture control, perhaps) and pass that Picture object into the class module. The class then knows how to operate on the picture, and it assumes that all its expected pieces have been laid out appropriately. This approach has several downsides, and I'd like something a bit more elegant.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈甜 2024-07-12 11:45:55

看一下 VB6 UserControls; 我认为它们正是您所需要的。 您可以在项目中创建 UserControl,向该控件添加控件和代码,然后将其插入到窗体中,就像标准 VB6 控件一样。 我曾多次使用 UserControls 来共享 UI 布局,效果非常好。

Take a look at VB6 UserControls; I think they are exactly what you need. You can create a UserControl within your project, add controls and code to that control, and then insert it onto a form just like standard VB6 controls. I've used UserControls to share UI layouts on many occasions and it works great.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文