Help and Support

A stock Text or Caption property is not added to an MFC ActiveX control which subclasses a Combo or List Box

Article ID:160910
Last Review:November 21, 2006
Revision:3.1
This article was previously published under Q160910

SYMPTOMS

When you add a stock Text or Caption property to an MFC ActiveX control that subclasses a Combo or List Box, it will not serialize properly.

Back to the top

CAUSE

When a container attempts to read the Text or Caption property for an MFC ActiveX control, the MFC framework calls COleControl::GetText. GetText calls COleControl::InternalGetText. InternalGetText may attempt to get the Text or Caption property from the control with the following call:
   if (DefWindowProc(WM_GETTEXT, (WPARAM)_cchUsual,
       (LPARAM)m_strText.GetBufferSetLength(_cchUsual)) >= _cchUsual - 1)
				
In the case of subclassed Combo or List Box control, this call will always return an empty buffer.

Back to the top

RESOLUTION

It is debatable whether it makes sense to have a Text or Caption property for a subclassed Combo or List Box. The native Combo and List Box controls do not respond to the WM_SETTEXT or WM_GETTEXT messages. Therefore, the problem described above occurs.

If it makes sense to do this in your application, it is easy to make this work: When adding the Text or Caption property to the ActiveX control, simply select the stock property and select Get / Set methods. This will give you the ability to handle the Text or Caption property as if it were a custom property.

Back to the top

STATUS

This behavior is by design.

Back to the top

MORE INFORMATION

The Text and Caption properties of an ActiveX control are synonymous.

Back to the top


APPLIES TO
Microsoft Foundation Class Library 4.2, when used with:
  Microsoft Visual C++ 4.0 Standard Edition
  Microsoft Visual C++ 4.1 Subscription
  Microsoft Visual C++ 4.2 Enterprise Edition
  Microsoft Visual C++ 4.2 Professional Edition
  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
  Microsoft Visual C++, 32-bit Learning Edition 6.0

Back to the top

Keywords: 
kbtshoot kblistbox kbprb kbcombobox kbctrl KB160910

Back to the top

Article Translations

 

Other Support Options

  • Contact Microsoft
    Phone Numbers, Support Options and Pricing, Online Help, and more.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.