Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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"
C++
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"

C++
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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900