Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC WTL
hi,
 
My English is not good, if the problem can not be Bunderstood please reply to me.
 

 
I ran into a problem.
 
I insert a picture into my richedit,than Scroll bars are displayed.
 
I move the scroll bar until Image the lower half of the display,
 
than i call the function "ITextHost::SetClientRect",i found that The scroll bar will automatically scroll to make sure the picture all visible.
 
if i do not call the function "ITextServices::TxDraw",Scroll bar does not automatically scroll.
 

 
Is there a way to disable the scrollbar rollback??
 

 
the function "ITextHost::SetClientRect"
void CTxtWinHost::SetClientRect(RECT *prc, BOOL fUpdateExtent) 
{
	// If the extent matches the client rect then we assume the extent should follow
	// the client rect.
	LONG lTestExt = DYtoHimetricY(
		(rcClient.bottom - rcClient.top)  - 2 * HOST_BORDER, yPerInch);
 
	if (fUpdateExtent 
		&& (sizelExtent.cy == lTestExt))
	{
		sizelExtent.cy = DXtoHimetricX((prc->bottom - prc->top) - 2 * HOST_BORDER, 
			xPerInch);
		sizelExtent.cx = DYtoHimetricY((prc->right - prc->left) - 2 * HOST_BORDER,
			yPerInch);
	}
 
	rcClient = *prc; 
}
 
 
the function "ITextServices::TxDraw"
 
void CxRichEdit::OnPaint(GDIPlus& gp, const CxRect& rcPaint)
{
	RECT rcTemp = { 0 };
	if( !::IntersectRect(&rcTemp, &rcPaint, &m_rcItem) ) return;
 
	if( m_pTwhost&&m_pTwhost->pserv ) 
	{
		RECT rc={0,0,0,0};
		m_pTwhost->GetControlRect(&rc);
		RECT rcNeedUpdate = rc;
		if(pPaintCenter)
			rcNeedUpdate = pPaintCenter->GetRectUpdate(rc);
		if(::IsRectEmpty(&rcNeedUpdate))return;
 

		RECT *prc = NULL;
		LONG lViewId = TXTVIEW_ACTIVE;
 
		//if (!m_pTwhost->GetActiveState())
		{
			prc = &rc;
			//lViewId = TXTVIEW_INACTIVE;
		}
 
		// Remember wparam is actually the hdc and lparam is the update
		// rect because this message has been preprocessed by the window.
		m_pTwhost->GetTextServices()->TxDraw(
			DVASPECT_CONTENT,  // Draw Aspect
			0,		// Lindex
			NULL,		// Info for drawing optimazation
			NULL,		// target device information
			gp.m_hDC,	// Draw device HDC
			NULL, 		// Target device HDC
			(RECTL *) prc,	// Bounding client rectangle
			NULL, 		// Clipping rectangle for metafiles
			(RECT*)&rcNeedUpdate,	// Update rectangle
			NULL, 	   	// Call back function
			NULL,		// Call back parameter
			lViewId);	// What view of the object			

	}
}
 
Posted 26-Feb-13 22:18pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 400
1 Maciej Los 217
2 OriginalGriff 213
3 BillWoodruff 130
4 Zoltán Zörgő 85
0 OriginalGriff 7,953
1 DamithSL 6,139
2 Sergey Alexandrovich Kryukov 5,449
3 Maciej Los 5,293
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100