如何创建控件 [英] how to create controls

查看:67
本文介绍了如何创建控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
请问如何创建一些东西(我不知道确切的名字,但是像小部件一样),以便用户可以使用它们自定义他们的应用程序?
例如,我提供了10个小部件",包括摄影棚中的捕获,处理器,显示器和fileIO;用户可以将捕获,处理器和fileIO拖到图中,进行连接并设置其属性以使它们协同工作.
我以前见过这种情况,例如DirectShow.

但是我不知道该如何独自开始.
在我看来,我有一个提供受支持的小部件"的工作室.然后用户可以选择并配置选定的小部件",并使其成为工作室中的应用程序.
任何相关的提示和入门教程都将不胜感激.
非常感谢您的宝贵时间.
达蒙
//------------------------------------------------ -----------
感谢您的答复,克里斯蒂安.
对于我来说,这是一本设计模式的好书,因为每个窗口小部件"都需要设计.是一种模式.
但是目前,我的问题还比较肤浅:如何创建工作室.
我不知道这是否正确:
我为每个小部件"创建一个按钮;
一旦用户选择(或拖动)窗口小部件并将其放入工作空间,我便在工作空间中绘制该窗口小部件的实例.工作区中的每个小部件都有其形状,位置和其他属性;
一旦使用选定的将鼠标从一个小部件移动到工作区中的另一个小部件,
我在他们之间画了一支箭;
通过右键单击工作空间中的窗口小部件,用户可以设置该窗口小部件的属性;
...
我期望有一些成熟或标准的方法可以做到这一点.
还是有任何此类资源的开放源代码?
再次感谢您的时间和考虑.
达蒙
//------------------------------------------------ -----------
感谢您的提醒,克里斯蒂安.
如下清除我的项目可能会有所帮助:
假设在Visual Studio中,我有一个控件列表(按钮,列表...)
我可以将一个拖放到表单中并创建该控件的一个实例.我可以为该控件创建事件句柄并构建应用程序.

就我而言,这是相似的.假设我有一个控件列表,并且用户可以在表单中拖动和配置其中的一些控件;但无需编译和构建,用户已经拥有并可以运行其应用程序.

我的问题是如何实现控件,以便用户可以动态地以窗体的形式创建它的多个实例,而无需编译和构建?
你知道是否有一些样品吗?
非常感谢.
Damon

Hi, guys,
May I ask you how to create something (I do not know the exact name, but something like widgets) such that users can custom their applications with them?
For example, I provide 10 "widgets" including a capture, a processor, a display and a fileIO in a studio; Users can drag a capture, a processor and a fileIO into a diagram, connect them and set up their properties to make them work together.
I have seen such kind of scenario before such as DirectShow.

But I do not know how to start it by myself.
In my mind, I have a studio where supported "widgets" are provided; then users can select and configure the selected "widgets" and make it an application for them in the studio.
Any tips and starting tutorials related will be appreciated.
Thanks a lot for your time.
Damon
//-----------------------------------------------------------
Thanks for your reply, Christian.
That''s a great book for me to design patterns since each "widget" is a pattern.
But for the moment, my question is more superficial: how to create the studio.
I do not know if this is correct:
I create a button for each "widget";
Once user select(or drag) a widget and put it into the workspace, I draw that an instance of that widget in the workspace; each widget in the workspace has its shape, position and other properties;
Once use selected move mouse from one widget to another one in the workspace,
I draw an arrow between them;
By right-click a widget in the workspace, users can setup the properties of that widget;
...
I am expecting some maturer or standard approaches to do it.
Or are there any open-source for such kinds of stuff?
Thanks again for your time and consideration.
Damon
//-----------------------------------------------------------
Thanks for your reminding, Christian.
It may be helpful to clear my project as follows:
Let''s say, in visual studio, I have a list of controls(buttons, lists...)
I can drag one into my form and create an instance of that control; I can create event handles for that control and build the applications.

For my case, it is similar. Assume I have a list of controls and users can drag and configure some of them in the form; but without compile and build, user already has and can run its applications.

My question is how to implement a control such that users can create multiple-instances of it in a form dynamically without compiling and building?
Do you know if there are some samples related?
Thanks a lot.
Damon

推荐答案

我建​​议阅读本书设计模式".那里有许多模式描述了不同的实现方式.
I recommend reading the book ''design patterns''. There''s a number of patterns in there that describe different ways to impliment this.


您应该编辑您的帖子,而不是发布确实有更多问题的答案.

我这样做的方法是为所有小部件创建一个基类.基类可能存储诸如位置和大小之类的东西.派生的类会创建实际的小部件,您的表单最终会带有一组小部件,这些小部件可自行绘制或在绘画事件中绘制.

我假设每个Widget都是一个控件,例如,它将处理自己的右键单击事件.
You should edit your post, not post an answer that is really more questions.

The way I''d do this is to create a base class for all widgets. The base class probably stores things like a position and size. Derived classes create actual widgets, and your form ends up with a collection of widgets which either draw themselves or are drawn in your paint event.

I assume each Widget would be a control, which would then handle it''s own right click event, for example. Which means it would draw itself.


谢谢您的答复,克里斯蒂安.
对我来说,这是一本设计模式的好书,因为每个小部件"都是一个模式.
但是目前,我的问题还比较肤浅:如何创建工作室.
我不知道这是否正确:
我为每个小部件"创建一个按钮;
一旦用户选择(或拖动)窗口小部件并将其放入工作空间,我便在工作空间中绘制该窗口小部件的实例.工作区中的每个小部件都有其形状,位置和其他属性;
一旦使用选定的将鼠标从一个小部件移动到工作区中的另一个小部件,
我在他们之间画了一支箭;
通过右键单击工作空间中的窗口小部件,用户可以设置该窗口小部件的属性;
...
我期望有一些成熟或标准的方法可以做到这一点.
还是有任何此类资源的开放源代码?
再次感谢您的时间和考虑.
达蒙(Damon)
Thanks for your reply, Christian.
That''s a great book for me to design patterns since each "widget" is a pattern.
But for the moment, my question is more superficial: how to create the studio.
I do not know if this is correct:
I create a button for each "widget";
Once user select(or drag) a widget and put it into the workspace, I draw that an instance of that widget in the workspace; each widget in the workspace has its shape, position and other properties;
Once use selected move mouse from one widget to another one in the workspace,
I draw an arrow between them;
By right-click a widget in the workspace, users can setup the properties of that widget;
...
I am expecting some maturer or standard approaches to do it.
Or are there any open-source for such kinds of stuff?
Thanks again for your time and consideration.
Damon


这篇关于如何创建控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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