如何在VB6用户控件中实现高级自定义属性? [英] How to implement advanced custom properties in VB6 usercontrols?

查看:85
本文介绍了如何在VB6用户控件中实现高级自定义属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抱歉,除了高级自定义属性"外,我不知道如何命名.如果知道的话,我会先搜索它.

Sorry I don't know how to name it other than "advanced custom properties". If I know, I would search it first.

我正在使用第三方控制来处理旧代码.

I am dealing with a legacy code using 3-rd party controls.

在VB6中,当将该控件拖到窗体上时,可以在属性"窗口中看到该控件支持的所有属性.例如MarginLeft,MarginRight等.

In VB6, When you drag that control onto the form, you can see all the properties supported by the control in the "Properties" window. Such as MarginLeft, MarginRight etc. etc.

没问题.

在属性"窗口中,最上面的属性通常是(名称)"字段,它是控件的名称.

In the "Property" window, the top-most property is generally the "(Name)" field, which is the name of the control.

但是我正在使用的第3方控件在(名称)"上方还有另外两个假属性",分别是(关于)"和(自定义)".

But the 3-rd party control I am using, has another two "fake properties" above "(Name)", which are "(About)" and "(Custom)".

当您单击(关于)"时,将出现一个对话框,显示公司信息.当您单击(自定义)"时,将出现另一个对话框,显示更多属性.这些对话框显示在VB6中.

When you click "(About)", there will be a dialog box showing the company info. When you click "(Custom)", there will be another dialog box showing more properties. These dialog boxes are shown in VB6.

在(自定义)"对话框中,您可以修改普通属性(与直接在属性"窗口中进行修改相同).您可以做更多.还有更多不是正常属性的属性(至少您无法在属性"窗口中找到任何内容).

In the "(Custom)" dialog box, you can modify normal properties (same as modifying directly in the Property window). You can do more. There are more properties that are not normal properties (at least you cannot find anything in the Property window).

保存此表单时,对于常规属性,所有内容均保存到.FRM文件中.例如

When you save this form, for normal properties, everything are saved into .FRM file. E.g.,

  Control1.MarginLeft = 5
  Control1.Text = "I am a control"

但是,对于在(自定义)对话框中编辑的高级属性",它们没有保存为.FRM,而是以二进制格式保存为.FRX.

However, for the "advanced properties" edited in the (Custom) dialog box, they are not saved in .FRM, they are saved in .FRX in binary format.

例如,在(自定义)对话框中,您可以编辑一个名为标题"的属性,其中包括该标题的文本,字体,粗细,显示样式以及许多类似的标题属性.在.FRM中,它类似于

E.g., in (Custom) dialog box, you can edit a property called "Caption", which includes text of this caption, the font, the weight, the display style, and a lot of similar properties for Caption. In .FRM, it is something like,

   Control1.Caption = "frmForm1.frx":013F

Caption的所有文本和相关属性都以二进制格式保存在.FRX文件中.

All the text and related properties of Caption are saved in binary format in .FRX file.

请注意,普通的属性"窗口中没有标题属性,只能在(自定义)"对话框中对其进行编辑.

Note that, there's no Caption property in the normal Property window, you can only edit it in the "(Custom)" dialog box.

我的问题如下,

  1. 如何实现可以在VB6中显示的(自定义)对话框?

  1. How to implement such a (Custom) dialog box that can be shown in VB6?

如何让VB6的属性"窗口显示关于"和自定义"?

How to let VB6's Property window display (About) and (Custom)?

如何告诉VB6 Caption属性不应显示在"Property"窗口中,但是您可以直接在代码中使用 Control1.Caption = xxxx.frx:offset ?

How to tell VB6 that Caption property shall not be displayed in Property window, but you can use directly in code as Control1.Caption = xxxx.frx:offset?

如何告诉VB6此Caption属性应保存在.FRX中,以及如何告诉VB6数据大小,以便VB6可以自动管理偏移量?

How to tell VB6 that this Caption property shall be saved in .FRX, and how to tell VB6 the size of the data, so that VB6 can manages the offset automatically?

如何通过VB6自动加载数据,以便在(自定义)对话框中显示正确的值?

How to load the data automatically via VB6 so that the correct values can be displayed in (Custom) dialog box?

据我所知,.frx格式是秘密,对于标准控件(例如Binary(images),List和Text),有很多ppl挖掘到各种.frx中.我很好奇第三方控件如何使用.frx,第三方控件应定义自己的.frx格式吗?例如,包括长度"前面有多少个字节(或根本没有长度字段,它是固定长度),样式1"有多少个字节,样式2"有多少个字节等.

As far as I know, .frx formats are secrets, there are a lot of ppl digging into various .frx for standard controls such as Binary(images), List, and Text. I am curious how can a 3-rd party control utilizing .frx, shall the 3-rd party control define its own .frx format? Including for example, how many bytes in front for Length (or no length field at all, it's fixed length), how many bytes for style1, how many bytes for style2, etc.

非常感谢.如果您知道此高级属性"的专有名称,请告诉我这个名称,我可以自己搜索.

Thanks a lot. If you know what proper name it is for this "advanced properties", just tell me the name and I can search myself.

我尝试搜索高级属性,但并没有真正得到我想知道的任何内容.

I tried to search for advanced properties but didn't really get anything I want to know.

推荐答案

frx文件适用于二进制或其他非基本数据类型.frm将存储简单属性.您需要做的是挂接到UserControl事件WriteProperties和ReadProperties.您不需要知道后备存储在哪里(frm vs frx).您只需要访问PropBag即可读取和写入数据.

The frx files are for binary or other non-basic data types. The frm will store the simple properties. What you need to do is to hook into the UserControl events WriteProperties and ReadProperties. You don't need to know where the backing storage is (frm vs frx)., you just need to access the PropBag to read and write your data.

Google是您查找文档的朋友:

Google is your friend to find the documentation:

https://msdn.microsoft.com/en-us/library/aa242140(v = vs.60).aspx

或有关该主题的其他信息:

Or additional information on the topic:

祝你好运!

这篇关于如何在VB6用户控件中实现高级自定义属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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