Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
How do I Create OCX (this OCX have two user control)?
Posted

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
 
Share this answer
 
v2
Comments
Reason Jiang 10-Sep-14 12:35pm    
No, all example programe only have a user control in the every ocx file.
[no name] 10-Sep-14 12:38pm    
Is placing two controls inside the same OCX your only problem?
Reason Jiang 10-Sep-14 19:20pm    
Yes!Has not resolved!
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.
 
Share this answer
 
Comments
Reason Jiang 10-Sep-14 19:26pm    
Wow!Can not automatically generated template?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900