FIX: Hatch Marks in MFC DRAWCLI Print Preview

Last reviewed: September 18, 1997
Article ID: Q123162
1.50 WINDOWS kbprint kbfixlist kbbuglist

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), included with

        - Microsoft Visual C++ for Windows, version 1.5
    

SYMPTOMS

Although hatching should never appear when using a print DC, under the conditions outlined in the "Steps to Reproduce Problem" section of this article, the active embedded item is represented with hatch marks across it in the print preview.

CAUSE

This is a bug in the DRAWCLI sample. The function CDrawOleObj::Draw draws the hatch marks across the item. The Draw function should check to see whether or not the DC passed to is a printer DC or a screen DC. Then based on the type of DC, the sample should either draw or not draw hatch marks. Presently, any item that is currently open (active) has hatching drawn across it regardless of the type of DC.

RESOLUTION

The code to draw the rectangle tracker and the hatching over the item begins on line 1024 of DRAWOBJ.CPP. It can be found in the MSVC\MFC\SAMPLES\DRAWCLI directory. The code is the following:

   // use a CRectTracker to draw the standard effects
   CRectTracker tracker;
   tracker.m_rect = m_position;
   pDC->LPtoDP(tracker.m_rect);

   if (c_bShowItems)
   {
      // put correct border depending on item type
      if (pItem->GetType() == OT_LINK)
        tracker.m_nStyle |= CRectTracker::dottedLine;
      else
        tracker.m_nStyle |= CRectTracker::solidLine;
   }

   // put hatching over the item if it is currently open
   if (pItem->GetItemState() == COleClientItem::openState ||
   pItem->GetItemState() == COleClientItem::activeUIState)
   {
      tracker.m_nStyle |= CRectTracker::hatchInside;
   }
   tracker.Draw(pDC);

Change the code to this:

// don't draw tracker in print preview or on printer
if (!pDC->IsPrinting()) {
   // use a CRectTracker to draw the standard effects
   CRectTracker tracker;
   tracker.m_rect = m_position;
   pDC->LPtoDP(tracker.m_rect);

   if (c_bShowItems)
   {
      // put correct border depending on item type
      if (pItem->GetType() == OT_LINK)
        tracker.m_nStyle |= CRectTracker::dottedLine;
      else
        tracker.m_nStyle |= CRectTracker::solidLine;
   }

   // put hatching over the item if it is currently open
   if (pItem->GetItemState() == COleClientItem::openState ||
   pItem->GetItemState() == COleClientItem::activeUIState)
   {
      tracker.m_nStyle |= CRectTracker::hatchInside;
   }
   tracker.Draw(pDC);
}

STATUS

Microsoft has confirmed this to be a bug in the products listed at the beginning of this article. This bug was corrected in The Microsoft Foundation Classes, version 2.51, included with Visual C++ version 1.51.

MORE INFORMATION

Steps to Reproduce Problem

  1. Run the DRAWCLI sample (MSVC\MFC\SAMPLE\DRAWCLI\DRAWCLI.EXE).

  2. Choose Insert New Object from the Edit menu.

  3. Insert a new object in the Drawcli application.

  4. Choose Print Preview from the File menu, or choose Print from the File menu.


Additional reference words: 1.50 2.50
KBCategory: kbprint kbfixlist kbbuglist
KBSubcategory: CodeSam MfcPrinting MfcOLE
Keywords : CodeSam kb16bitonly MfcOLE MfcPrinting kbbuglist kbfixlist kbprint
Technology : kbMfc
Version : 1.50
Platform : WINDOWS
Solution Type : kbfix


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: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.