[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Creating ActiveX control dynamically (on the fly)

Posted on 1999-12-22
7
Medium Priority
?
315 Views
Last Modified: 2013-11-20
I'm creating an ActiveX control - ComboBox. I must use an EditBox control inside it. The EditBox is a visual ActiveX control also.

How to create the EditBox ActiveX control object on the fly and draw it inside the ComboBox control?

I must create the EditBox ActiveX control in the OnDraw(CDC* pDC, ...) method of my ComboBox control.

Any similar example or article in MSDN would be cool. Thanks.
0
Comment
Question by:Mindo
  • 4
  • 3
7 Comments
 
LVL 2

Author Comment

by:Mindo
ID: 2299971
Edited text of question.
0
 
LVL 8

Expert Comment

by:Vinayak Kumbar
ID: 2299988
Hi,

I am not sure of this. But take a look at it.
Insert the actveX control of edit box into the combo box's aciveX project. Include edit controls .h file into combo box's ctl.h file and have a object of the editX init. Then use that object to create that control on OnDraw of comboX.

Try it out.
0
 
LVL 2

Author Comment

by:Mindo
ID: 2300256
Yes, i did it. The VC++ 6.0 added classes to my project. I try to create the ActiveX control object in the OnDraw() method like this:

m_NMEdit.Create(NULL, WS_VISIBLE, CRect(10, 10, 20, 20), this, 0);

Unfortunately, my program crashes exactly on the above line.

I declared the member of the control as follows:

CNMEdit m_NMEdit;

I wonder, why it crashes? Should i perform initialisation routines?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:Vinayak Kumbar
ID: 2300337
Hi,

I have not tried it. Try that one and let me know the results.
Thanks

VinExpert
0
 
LVL 2

Author Comment

by:Mindo
ID: 2300365
The results are:

My program crashes at the Create(...) function call.

There's a problem with the Create(...) function call. Maybe i pass wrong parameters or maybe i should initialize control data the other way?

Did anybody have the same problems with the Create(...) function call?
0
 
LVL 8

Accepted Solution

by:
Vinayak Kumbar earned 200 total points
ID: 2300385
Hi,
Ok, I tell u the procedure as I solved the crash.
In the ctrl.h I have other activeX 's pointer say
CEditX *edit;

In the constructor
edit = NULL;

Then in OnDraw()
CRect rect(10,10,50,50);
      edit = new CEditX;
      AfxEnableControlContainer();
      edit->Create(NULL, NULL, WS_VISIBLE, rect, this, 4545, NULL);
      edit->ShowWindow(SW_SHOW);

here AfxEnableControlContainer(); is the extra call that we have to make.

Try it out.
VinExpert
0
 
LVL 2

Author Comment

by:Mindo
ID: 2300726
Cool, it works. Thanks man. I didn't find any good example in MSDN. Why is Microsoft so obscure about giving good examples and explanations?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question