如何创建OCX(此OCX有两个用户控件)? [英] How do I Create OCX (this OCX have two user control)?

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

问题描述

如何创建OCX(此OCX有两个用户控件)?

How do I Create OCX (this OCX have two user control)?

推荐答案

从C ++开始,两种传统方法是使用ATL或MFC。两者都将提供用于创建可嵌入其他应用程序的OCX / COM组件的等效框架。



CP上有很多示例。这是一个。



Hex Editor( OCX控制) [ ^ ]



...和另一个。



EAN-13条形码ActiveX控件抽屉 [ ^ ]



在Visual Studio中你可以使用向导从模板创建空控件。从那里你可以编辑以添加功能。



文件 - >新项目 - > Visual C ++ - > MFC - > MFC ActiveX控件



文件 - >新项目 - > Visual C ++ - > ATL - > ATL项目
From C++, the two traditional approaches are to use ATL or MFC. Both will provide equivalent frameworks for creating OCX / COM components that can be embedded into other applications.

There are lots of examples on CP. Here's one.

Hex Editor (OCX Control)[^]

... and another.

EAN-13 BarCode ActiveX Control Drawer[^]

In Visual Studio you can use the wizard to create an empty control from a template. From there you can edit away to add functionality.

File -> New Project -> Visual C++ -> MFC -> MFC ActiveX Control

File -> New Project -> Visual C++ -> ATL -> ATL Project


如果你的问题是在一个OCX中组合两个控件,试试这个。



我们将这两个控件命名Bob和Sue。



使用项目模板为Bob创建一个带有一个Active-X控件的OCX项目。



在IDL文件中将是两个接口和一个同类。



复制此文本并将其粘贴到IDL文件的底部。将Bob重命名为Sue并更改GUID。如果你很懒 - 只需编辑每个GUID的最后一位数。



转到头文件......你会看到BobCtrl.h和BobPropPage。 H。复制这些文件并将副本重命名为Sue.h,SueCtrl.h和SuePropPage.h。



对CPP文件执行相同操作。完成后你应该有SueCtrl.cpp和SuePropPage.cpp。



暂时离开Bob.cpp和Bob.h.



将新的Sue文件添加到项目中。



重建项目。



还有一些编辑,但这应该可以让你开始。
If your problem is combining two control inside one OCX, try this.

We'll name the two controls Bob and Sue.

Use the project template to create an OCX project with one Active-X control for Bob.

Inside the IDL file will be two interfaces and a co-class.

Make a copy of this text and paste it to the bottom of the IDL file. Rename "Bob" to "Sue" and change the GUIDs. If you're lazy - just edit the last digit of each GUID.

Moving on to the header files ... you'll see BobCtrl.h and BobPropPage.h. Copy those files and rename the copies to Sue.h, SueCtrl.h and SuePropPage.h.

Do the same for the CPP files. You should have SueCtrl.cpp and SuePropPage.cpp when you're done.

Leave Bob.cpp and Bob.h alone for now.

Add the new "Sue" files to the project.

Rebuild the project.

There are a few more edits but this should get you started.


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

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