ActiveX Ctrl not displayed in printing!!!!!!!

A

Ahmad Jalil Qarshi

hi!

I have an ActiveX control for Word written in VC++7.1 using ATL. now when i
insert my control into Word document and print it. It just displays image
rendered on it but doesn't diplay the text displayed on the control. my
OnDraw function looks like that.

HRESULT CMyObj::OnDraw(ATL_DRAWINFO & di)
{
RECT& rc = *(RECT*)di.prcBounds;
RECT TextRect = {0,35,rc.right,rc.bottom/2};

m_CompLogoImg->get_Width(&lImgWidth);
m_CompLogoImg->get_Height(&lImgHeight);

HRESULT hres = m_CompLogoImg->Render(di.hdcDraw,rc.right*3/4,
rc.bottom/2, rc.right*1/4, rc.bottom/2, 0, lImgHeight,
lImgWidth, -(lImgHeight), &r);

CComBSTR bstrText = _T("Location");
ExtTextOut(di.hdcDraw,TextRect.left +2 , TextRect.top,ETO_CLIPPED,
&TextRect, OLE2T(bstrText.m_str), bstrText.Length(), NULL); return S_OK;
}

i found an article
http://www.codeguru.com/Cpp/COM-Tech/atl/printing/article.php/c3559/ but
couldn't understand it well. any body there to solve this problem

Thanks in advance.

Ahmad Jalil Qarshi
 
S

Simon Trew

Ahmad Jalil Qarshi said:
hi!

I have an ActiveX control for Word written in VC++7.1 using ATL. now when
i insert my control into Word document and print it. It just displays
image rendered on it but doesn't diplay the text displayed on the control.
my OnDraw function looks like that.

HRESULT CMyObj::OnDraw(ATL_DRAWINFO & di)
{
RECT& rc = *(RECT*)di.prcBounds;
RECT TextRect = {0,35,rc.right,rc.bottom/2};

Are you sure (0, 35) is within di.prcBounds? If not, you could well be
drawing outside the clipping region, and thus not drawing at all.

Also, make sure you have a suitable font selected. (If you created a font
yourself and selected the height in pixels then it could be very very tiny
when printed.)
ExtTextOut(di.hdcDraw,TextRect.left +2 , TextRect.top,ETO_CLIPPED,
&TextRect, OLE2T(bstrText.m_str), bstrText.Length(), NULL); return
S_OK;

You could just use ExtTextOutW and pass bstrText.m_str without the
conversion here, presuming you don't need to deal with embedded NULLs (which
using OLE2T won't help you with, anyway).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top