Click here to Skip to main content
12,819,035 members (26,016 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ MFC WTL

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 -  - 2 * HOST_BORDER, yPerInch);

	if (fUpdateExtent 
		&& ( == lTestExt))
	{ = DXtoHimetricX((prc->bottom - prc->top) - 2 * HOST_BORDER, 
			xPerInch); = DYtoHimetricY((prc->right - prc->left) - 2 * HOST_BORDER,

	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};
		RECT rcNeedUpdate = rc;
			rcNeedUpdate = pPaintCenter->GetRectUpdate(rc);

		RECT *prc = NULL;

		//if (!m_pTwhost->GetActiveState())
			prc = &rc;

		// Remember wparam is actually the hdc and lparam is the update
		// rect because this message has been preprocessed by the window.
			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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 27 Feb 2013
Copyright © CodeProject, 1999-2017
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