Microsoft KB Archive/246687

= BUG: DDX_ and DDP_ Functions Don't Work for ComboBoxEx in COlePropertyPage =

Article ID: 246687

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q246687

<div class="symptoms_section">

SYMPTOMS
If the user has an extended combo box in a COlePropertyPage class, and uses the DDX_ functions and the DDP_ functions to set a control property with the extended combo box control, the property is not persisted when the selection is changed in the extended combo box.

<div class="cause_section">

CAUSE
The problem is in the COlePropertyPage::OnCommand function in the Ctlppg.cpp file. This function calls the SetControlStatus and SetModifiedFlag functions in response to a CBN_EDITCHANGE notification message, but only if the class name of the window is "COMBOBOX".

The COlePropertyPage::OnCommand function also needs to call the SetControlStatus and SetModifiedFlag functions in response to a CBN_EDITCHANGE notification message for the class name "COMBOBOXEX32".

<div class="resolution_section">

RESOLUTION
To work around this problem, you can handle the CBN_EDITCHANGE notification and call SetControlStatus and SetModifiedFlag. The code for the message map and the handler function should resemble the following: BEGIN_MESSAGE_MAP(CTestPropPage, COlePropertyPage) //AFX_MSG_MAP END_MESSAGE_MAP

void CTestPropPage::OnEditchangeComboboxex1 {   SetControlStatus(IDC_COMBOBOXEX1, TRUE); SetModifiedFlag ; }

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> Use MFC ActiveX ControlWizard to generate an ActiveX control project called Test.</li> Add a custom property called MyProperty, the type is CString.</li> Add an extended combo box to the control property page resource.</li>  Associate the string value of the combo box with MyProperty. The following entries should be added to the DoDataExchange function if you define m_strMyProperty as the variable name: DDP_CBString(pDX, IDC_COMBOBOXEX1, m_strMyProperty, _T("MyProperty") ); DDX_CBString(pDX, IDC_COMBOBOXEX1, m_strMyProperty); </li> Build the ActiveX control.</li> Test the ActiveX control in the ActiveX Control Test Container. You should find that the property is not being persisted.</li></ol>

Additional query words: DDP_CBString DDX_CBString DoDataExchange SetControlStatus SetModifiedFlag

Keywords: kbbug kbcombobox kbdlg kbpersistst kbpropsheet KB246687

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.