0
votes

I added a activex control to my MFC project, I don't use the dialog editor to add the control, I just used MFC to generate a wrapper class for the control, and call the "create" member in the wrapper class to create the control programmatically, the code is more or less like:

class CMyView
{

CCalendar m_ctl;
//other members.....
}
int CMyView::OnCreate
{
  m_ctl.create("",WS_CHILD|WS_VISIBLE,this,CRect(50,50,100,100));
  //.....
}

But I found that the wrapper class provide no way for me to change the control's property, so if I want to change the control's property programmatically, what should I do? Can I achieve this through a wrapper class? Or can it be done programmatically at all? Or is it only can be done via a dialog editor? Thank you.

1
What property do you want to change? - i_am_jorf
Any custom or stock property, for example, if the Calendar control provide a "redSunday" property which can cause the sundays to be displayed red, I want to toggle this property on and off pragmatically. - wangshuaijie

1 Answers

0
votes

Yes, wrapper only includes functions, if you create it via class wizard.

To change properties, i.e. variables, you could instantiate ActiveX in a form or a dialog and you would have the ability to modify values of properties in properties window.

If you want to do it on-the-run, you can right click to activeX object and then click on add variable. You will see that it will also create wrapper class for the object. This class will automatically include getters and setters for the activex, visible in the newly generated header file. If you have already created a wrapper class for your activex, it may not work, try this in a fresh project. You can then copy generated .cpp and .h files to your own project afterwards.