Microsoft KB Archive/184820

= FIX: Apply Button on an ATL Control's Property Page Is Disabled =

Article ID: 184820

Article Last Modified on 12/8/2003

-

APPLIES TO

 Microsoft ActiveX Template Library 2.0, when used with:  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</li></ul> </li> Microsoft ActiveX Template Library 2.1, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition</li></ul>

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

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

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

-

<div class="notice_section">

This article was previously published under Q184820

<div class="symptoms_section">

SYMPTOMS
When embedding an ATL ActiveX control inside a container application written in Visual Basic (VB), the Apply button on the control's property page is never activated even though the property page's dirty flag is set [that is, calling SetDirty(TRUE)] to enable the button.

<div class="cause_section">

CAUSE
Below is the SetDirty function copied from the Atlctl.h file: void SetDirty(BOOL bDirty) {     T* pT = static_cast<T*>(this); if (!pT->m_bDirty && bDirty) pT->m_pPageSite->OnStatusChange(           PROPPAGESTATUS_DIRTY | PROPPAGESTATUS_VALIDATE); pT->m_bDirty = bDirty; } When OnStatusChange is called, Visual Basic in turn calls IsPageDirty, which returns S_OK if m_bDirty is set to TRUE; otherwise, S_FALSE.

However, as shown above, m_bDirty is not set until OnStatusChanged returns.

<div class="resolution_section">

RESOLUTION
Please note that m_bDirty must be set before OnStatusChanged is called in SetDirty.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected ATL version 3.0, which shipped with Visual C++ version 6.0 for Windows.

<div class="moreinformation_section">

MORE INFORMATION
The following are two workarounds:

<ol>  Add an additional call to OnStatusChanged right after SetDirty is called. Using the ATL Polygon sample code, the change is shown below: LRESULT OnSidesChange(WORD wNotify, WORD wID, HWND hWnd, BOOL&        bHandled) {        SetDirty(TRUE); m_pPageSite->OnStatusChange(           PROPPAGESTATUS_DIRTY | PROPPAGESTATUS_VALIDATE); return 0; }                           </li>  Change the SetDirty function in Atlctl.h to the following: void SetDirty(BOOL bDirty) {        T* pT = static_cast<T*>(this); if (pT->m_bDirty != bDirty) {           pT-.m_bDirty = bDirty; if (bDirty) pT->m_pPageSite->OnStatusChange(                 PROPPAGESTATUS_DIRTY | PROPPAGESTATUS_VALIDATE); }     }                            </li></ol>

Steps to Reproduce Behavior

 * 1) Place an ATL Polygon control on a Visual Basic Form.
 * 2) Display the Polygon control's Property Pages dialog box by selecting the (Custom) property from Visual Basic's Properties window.

NOTE: The Apply button on the Property Pages window is initially disabled.
 * 1) Enter an integer value in the Sides edit box.

NOTE: The Apply button remains disabled.

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Yeong- Kah Tam, Microsoft Corporation

Additional query words: ocx

Keywords: kbbug kbfix kbpropsheet kbvc600fix kbatl300fix kbcontainer kbctrl KB184820

-

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

© Microsoft Corporation. All rights reserved.