Google Answers Logo
View Question
 
Q: Printing a Metafile ( No Answer,   0 Comments )
Question  
Subject: Printing a Metafile
Category: Computers
Asked by: victore-ga
List Price: $20.00
Posted: 13 Sep 2002 14:47 PDT
Expires: 13 Oct 2002 14:47 PDT
Question ID: 64792
I'm trying to print an IE CWebBrowser2 control to a Metafile.
I'm using IViewObject::Draw method.
In order to fit the IE control to the page size I'm using the
lprcBounds parameter of IViewObject::Draw.
Unfortunately, stretching don't work properly: only the top-left
corner is stretched and the e rest of the IE control is ignored by the
metafile.
Adjusting lprcWBounds has no effect.
Is it a bug in the Microsoft IE control?
I don't use StretchBlt method because it's distorting fonts.
How can I stretch and draw the whole IE control to a metafile?

Request for Question Clarification by spot_tippybuttons-ga on 14 Sep 2002 21:56 PDT
Would it be possible for you to post a short code snippet to look at?

Clarification of Question by victore-ga on 15 Sep 2002 07:58 PDT
Here you have some code  
if(!mpWeb) return; //mpWeb is a CDialog holding IE control
 CWebBrowser2* pWB = &mpWeb->m_web;
 IViewObject2* pViewObject = NULL;
 HRESULT   hr = pWB->GetDocument()->QueryInterface(IID_IViewObject2,
(void**)             &pViewObject);
 if (FAILED(hr)) return;
 //get size of control 
 CRect rect;
 pWB->GetWindowRect(&rect);
 int srcWidth = rect.Width(),  srcHeight = rect.Height();
 float factor = mStretch;//2;   //the  strectch factor is a member of
this class
 if(factor <= 0) factor = 1;
 
 RECTL rcOrig = { 0,0, srcWidth,srcHeight };
 RECTL rcBounds = { 0,0, (int)(srcWidth*factor),(int)(
srcHeight*factor)};
 RECTL rcWBounds = { 0,0, (int)(srcWidth*factor)*2,(int)(
srcHeight*factor)*2};
 
 // good quality but there is a bug: top-left corner only is stretched
 
      hr = pViewObject->Draw(DVASPECT_CONTENT, //DOCPRINT,
           -1, NULL, NULL,pWB->GetDC()->m_hDC ,
((CMetaFileDC*)pDC)->m_hDC, //hdcMem,
           &rcBounds, &rcWBounds, NULL, 0);
          if (!SUCCEEDED(hr)) ASSERT(0);
 
 
 pViewObject->Release();

Clarification of Question by victore-ga on 15 Sep 2002 08:02 PDT
///this code is collected from various functions, ignoring proper
deleting and releasing.
 if(!mpWeb) return; //mpWeb is a CDialog holding IE control
//create a metafile
 CMetaFileDC pDC = new CMetaFileDC();
 pDC->CreateEnhanced(printerDC,NULL,NULL, "temp");
        // printerDC is a CDC attached to GetPrinterDC()
pDC->SetAttribDC(printerDC->m_hAttribDC);//
 
//get the IViewObject interface
 CWebBrowser2* pWB = &mpWeb->m_web;
 IViewObject2* pViewObject = NULL;
 HRESULT   hr = pWB->GetDocument()->QueryInterface(IID_IViewObject2,
(void**)             &pViewObject);
 if (FAILED(hr)) return;
 //get size of control 
 CRect rect;
 pWB->GetWindowRect(&rect);
 int srcWidth = rect.Width(),  srcHeight = rect.Height();
 float factor = mStretch;//2;   //the  strectch factor is a member of
this class
 if(factor <= 0) factor = 1;
 
 RECTL rcOrig = { 0,0, srcWidth,srcHeight };
 RECTL rcBounds = { 0,0, (int)(srcWidth*factor),(int)(
srcHeight*factor)};
 RECTL rcWBounds = { 0,0, (int)(srcWidth*factor)*2,(int)(
srcHeight*factor)*2};
 
 //draw:  good quality but there is a bug: top-left corner only is
stretched
 
      hr = pViewObject->Draw(DVASPECT_CONTENT, //DOCPRINT,
           -1, NULL, NULL,pWB->GetDC()->m_hDC ,
((CMetaFileDC*)pDC)->m_hDC, //hdcMem,
           &rcBounds, &rcWBounds, NULL, 0);
          if (!SUCCEEDED(hr)) ASSERT(0);
 
 
 pViewObject

Clarification of Question by victore-ga on 15 Sep 2002 22:54 PDT
///this code is collected from various functions, ignoring proper
deleting and releasing.
 if(!mpWeb) return; //mpWeb is a CDialog holding IE control
//create a metafile
EPrinterDC* printerDC = new EPrinterDC();
 CMetaFileDC*  pDC = new CMetaFileDC();
 pDC->CreateEnhanced(printerDC,NULL,NULL, "temp"); 
        // printerDC is a CDC attached to GetPrinterDC() 
pDC->SetAttribDC(printerDC->m_hAttribDC);// 
 
//get the IViewObject interface
 CWebBrowser2* pWB = &mpWeb->m_web;
 IViewObject2* pViewObject = NULL;
 HRESULT   hr = pWB->GetDocument()->QueryInterface(IID_IViewObject2,
(void**)             &pViewObject);
 if (FAILED(hr)) return;
 //get size of control 
 CRect rect;
 pWB->GetWindowRect(&rect);
 int srcWidth = rect.Width(),  srcHeight = rect.Height();
 float factor = 3;//mStretch;//2;   //the mStrectch factor is a member
of this class
 if(factor <= 0) factor = 1;
 
 RECTL rcOrig = { 0,0, srcWidth,srcHeight };
 RECTL rcBounds = { 0,0, (int)(srcWidth*factor),(int)(
srcHeight*factor)};
 RECTL rcWBounds = { 0,0, (int)(srcWidth*factor)*2,(int)(
srcHeight*factor)*2};
 
 //draw:  good quality but there is a bug: top-left corner only is
stretched
 
      hr = pViewObject->Draw(DVASPECT_CONTENT, //DOCPRINT,
           -1, NULL, NULL,pWB->GetDC()->m_hDC ,
((CMetaFileDC*)pDC)->m_hDC, //hdcMem,
           &rcBounds, &rcWBounds, NULL, 0);
          if (!SUCCEEDED(hr)) ASSERT(0);
 
 pViewObject->Release();
 
//code for function until here
 
 
//Here is class EPrinterDC

class EPrinterDC : public CDC
{
public:
 EPrinterDC()
{
 mhDC = NULL;
 CPrintDialog pDi(FALSE);
 VERIFY(pDi.GetDefaults());
 mhDC = pDi.GetPrinterDC();
VERIFY(Attach(mhDC));
}
 ~EPrinterDC()
{
 Detach();
 DeleteDC();
 ::DeleteDC(mhDC);

}
 HDC mhDC;
};
 
#en
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy