BUG: Contain Sample Draws Incorrectly with In-place Server

Last reviewed: July 22, 1997
Article ID: Q110801

The information in this article applies to:
  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++ for Windows, version 1.5
    

SYMPTOMS

The Contain sample step 2, which is included with Visual C++ version 1.5 for Windows, has a bug that causes incorrect drawing of the OLE object when the server is in-place activated (not when it is out-of-place activated).

The problem is apparent after the embedded OLE object is shrunk and then reactivated. When the user starts drawing in the embedded object again, a shaded region will be drawn with a sizing rectangle which is the size and location of the embedded object before it was resized.

CAUSE

Step 2 of the Contain sample is intended to show how to do efficient redrawing and repainting with an OLE Container application. The cause of the problem is in the code which has been implemented to resize the OLE object properly when an out-of-place server has resized the view.

Step 2 correctly implements this for an out-of-place server. The Contain tutorial in the OLE 2 Classes Manual mentions HIERSVR as an example. However, if an in-place activated server is used to embed an OLE object then the resizing code is incorrect.

If the server is in-place activated then there is no need to resize the OLE object. The current implementation will again resize the OLE object by retrieving the extents from the server. In the case of an in-place activated server, the extents are not likely to change and the object will be drawn with its old size.

RESOLUTION

To fix the problem, make the following code change:

On Page 37 of "OLE 2 Classes" or in the file CNTRITEM.CPP change:

      void CCntrItem::UpdateFromServerExtent()
      {
        ...
   >>>      if (size != m_rect.Size())
     ...

   -to-

      if (size != m_rect.Size() && !IsInPlaceActive())

STATUS

Microsoft has confirmed this to be a problem in the Contain sample of the Microsoft Foundation Classes version 2.5. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Additional query words: shaded re-size sizing
Keywords : kb16bitonly MfcOLE
Technology : kbole kbmfc
Version : 1.5
Issue type : kbbug


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.