如何在窗口中滚动固定文本的窗口 [英] how to scroll the window of fixed text in window

查看:77
本文介绍了如何在窗口中滚动固定文本的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生
对MFC来说是一个非常新的角色.
我在滚动具有固定文本的窗口时遇到困难.我无法水平和垂直滚动文本,请任何人帮助我提供示例或代码.





谢谢你
sarfaraz

sir
as am very new to the MFC just started working.
i am facing difficulties to scroll the window which has fixed text. i am not able to scroll the text both way horizontal and vertical please any one help me with example or code.





thanking you
sarfaraz

推荐答案

您需要使用
You need to use the CScrollView[^] class; try a Google search for examples.


如果您将CScrollView用于该应用程序,则只需
调用以下方法
If you used the CScrollView for the application then just
call following method
void CScrollBarDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	int CurPos = m_ScrollBar.GetScrollPos();
	// Determine the new position of scroll box.
	switch (nSBCode)
	{
	case SB_LEFT:      // Scroll to far left.
		CurPos = 0;
		break;
	case SB_RIGHT:      // Scroll to far right.
		CurPos = 122;
		break;
	case SB_ENDSCROLL:   // End scroll.
		break;
	case SB_LINELEFT:      // Scroll left.
		if (CurPos > 0)
			CurPos--;
		break;
	case SB_LINERIGHT:   // Scroll right.
		if (CurPos < 122)
			CurPos++;
		break;
	case SB_PAGELEFT:    // Scroll one page left.
		{
			// Get the page size. 
			SCROLLINFO   info;
			m_ScrollBar.GetScrollInfo(&info, SIF_ALL);
   
			if (CurPos > 0)
				CurPos = max(0, CurPos - (int) info.nPage);
		}
		break;
	case SB_PAGERIGHT:      // Scroll one page right
		{
			// Get the page size. 
			SCROLLINFO   info;
			m_ScrollBar.GetScrollInfo(&info, SIF_ALL);
			if (CurPos < 122)
				CurPos = min(122, CurPos + (int) info.nPage);
		}
		break;
	case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
		CurPos = nPos;      // of the scroll box at the end of the drag operation.
		break;
	case SB_THUMBTRACK:   // Drag scroll box to specified position. nPos is the
		CurPos = nPos;     // position that the scroll box has been dragged to.
		break;
	}
	// Set the new position of the thumb (scroll box).
	m_ScrollBar.SetScrollPos(CurPos);
	
	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}




///////bit you use CEditCntrl then Define the object of scrollview like CSrollbar and add following code in OnDraw() method

m_ScrollBar.SetScrollRange(0, 122);


这篇关于如何在窗口中滚动固定文本的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆