?
Solved

ActiveX properties

Posted on 2006-04-28
11
Medium Priority
?
687 Views
Last Modified: 2013-11-20
Hi,

I just created a custom activex and I would like to set some properties like font colors, etc.  The properites I'm talking about is that properties menu when you right click on an activeX.  I would like to be able to add to this menu and be able to get the data out of this from my code.  I have no idea how to go about this?  Any ideas??

Thanks,
0
Comment
Question by:cophi
  • 5
  • 4
  • 2
11 Comments
 

Author Comment

by:cophi
ID: 16565083
I've seen the msdn answer on this and its a little to vague for me, any examples would be greatly appreciated
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 16566353
This article seems to cover ATL ActiveX property pages nicely:
    MSJ, Feb 1999
    Write ActiveX Controls Using Custom Interfaces Provided by ATL 3.0
    http://www.microsoft.com/msj/0299/atl3Activex/atl3Activex.aspx

If you start out by selecting the project type as
    MFC ActiveX ControlWizard
Then when you are done, just open the resources and you will have an empty property page to which you can add controls and that will be available in any environment that supports them (eg, in a form-designer in VB).

In the dialog editor, just select one of the controls and press Ctrl+W.  Switch to the Variables tab and add variables associated with the controls.  Use the CLassWizard to add properties to the control.   See:
       The ABCs of MFC ActiveX Controls
       http://msdn.microsoft.com/library/en-us/dnaxctrl/html/msdn_abcsmfc.asp

About 3/4 of the way down, it covers the Property Page stuff.

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 16566388
This appears to be an excellent tutorial, including specific handling of property pages:
    ActiveX Control Tutorial
    http://www.codeguru.com/Cpp/COM-Tech/activex/controls/article.php/c5517
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:mahesh1402
ID: 16567518
One way is OleCreatePropertyFrame OLE API. As alternative variant see Opropsheet MFC sample.

Q234545 "Opropsheet.exe Create a Modeless OLE Property Sheet Using MFC".

http://support.microsoft.com/kb/q234545/ <=== Refer this

-MAHESH

0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16567638
also

http://www.codeguru.com/cpp/com-tech/activex/controls/article.php/c2649/ <== 'Property Pages for ActiveX Controls'

-MAHESH
0
 

Author Comment

by:cophi
ID: 16576691
Ok, well these articles seem like they'd be good but I'm still confused.  I'm using Visual  C++ .Net 2003 to do my development so there is no Class Wizard.  When creating the project I did 'MFC ActiveX Control Wizard' with all the default options, so I have the the default propspage but I don't see how to get to the dialog for that page?  So my two questions is, whats the equivalent to the Class Wizard, and how do I get to see the default dialog for the props page.
0
 

Author Comment

by:cophi
ID: 16576831
Alright well I found how to get to the properties dialog, and I think I figured out the equivalent to the class wizard but I have another question.  So I added a textbox and then I added a class variable to the properties.cpp.  Now I want to access that control from my Ctrl.cpp file.  How do I do that?
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16577533
MFC ActiveX Controls: Property Pages  
http://msdn2.microsoft.com/en-US/library/8fb847t6.aspx#_core_adding_controls_to_a_property_page <==
Above Refer 'Adding Controls to a Property Page' section and Refer 'Customizing the DoDataExchange Function' section.

Your property page DoDataExchange function allows you to link property page values with the actual values of properties in the control. To establish links, you must map the appropriate property page fields to their respective control properties.

These mappings are implemented using the property page DDP_ functions. The DDP_ functions work like the DDX_ functions used in standard MFC dialogs, with one exception. In addition to the reference to a member variable, DDP_ functions take the name of the control property. The following is a typical entry in the DoDataExchange function for a property page.

e.g.
DDP_Text(pDX, IDC_CAPTION, m_caption, _T("Caption"));
This function associates the property page's m_caption member variable with the Caption, using the DDP_TEXT function.

http://msdn2.microsoft.com/en-US/library/y2y0fsk8.aspx

-MAHESH

0
 

Author Comment

by:cophi
ID: 16577582
I understand that MAHESH.  So lets say using your example, I have, DDP_Text(pDX, IDC_CAPTION, m_caption, _T("Caption")); in my PropPage.CPP.  Now I want to access the contents of m_caption from my Ctrl.CPP.  How do I get it in the ctrl.cpp file.  I'm sure its simple I just don't get it.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16577959
You can easily add header file PropPage.h in my Ctrl.CPP and then you may access that.......

-MAHESH
0
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 2000 total points
ID: 16578747
>>Now I want to access the contents of m_caption from my Ctrl.CPP.  How do I get it in the ctrl.cpp file.

You have lets say for "Caption" property
you have this in your PropPage.CPP file.......
DDP_Text(pDX, IDC_CAPTION, m_caption, _T("Caption"));

So in your myCtrl.cpp file you may use PX_XXXX family of functios...
for string PX_String() function to bind variable for property "Caption"

e.g
void CMyCtrl::DoPropExchange(CPropExchange* pPX)
{
      ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
      COleControl::DoPropExchange(pPX);

      // TODO: Call PX_ functions for each persistent custom property.
      PX_String( pPX, _T( "Caption" ), m_strCaption, STRDEFAULTCAPTION);

                ...
}

You may use PX_BOOL for bool,PX_LONG for long......etc

Refer this 'MFC ActiveX Controls: Serializing '
http://msdn2.microsoft.com/en-us/library/xxf9wx2c.aspx

-MAHESH
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

757 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