用MFC分页文档时出现问题困扰着我 [英] a problem bothered me when paging a document with MFC

查看:55
本文介绍了用MFC分页文档时出现问题困扰着我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试创建一个界面(如WORD软件)时,其中长文档正在分页到每一页.我是这样实现的:
根据文档的长度,我动态地计算出我必须生成多少个页面,每个页面只是一个RichEditCtrl.当页面小于43时似乎可以,但是,一旦超过43,就可以正确创建Control ,真是一团糟.我尝试了很多方法来解决它,但是失败了,有没有人可以帮助我,我将不胜感激.

RichEditCtrl代码的创建如下:
//创建RichEditCtrl的消息处理程序

when I try myself to make a interface Like the software of WORD,in which the long document is paging to every page.i realize it in this way:
Accord to the length of the document,I dynamically calculate how many page I have to generate,every page is just a RichEditCtrl .It seems ok when the page is less than 43 ,however,once it surpass 43,the Control can be createed correctly,just a mess.I have try a lot of methods to fixed it,but failed,is there any one to help me ,I will appreciate you grately.

the create of RichEditCtrl code is below:
//the message handlers of create RichEditCtrl

afx_msg LRESULT COLEView::CreatePageCtrl(WPARAM wParam, LPARAM lParam)
{
    DWORD dwStyle=ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER;
    long  pageindex=(long)wParam;
	//the CRichCtrObj Object contain RichEditCtrl
	CRichCtrObj* pRichCtrObj = new CRichCtrObj(pageindex);
	if(NULL==pRichCtrObj)
	{
		return -1;
	}
	m_ctrPageList.AddTail(pRichCtrObj);
	//accord to pageindex calculate the pos of the Control
	CRect rect(20,m_szPageSize.cy*pageindex+20,m_szPageSize.cx,(pageindex+1)*m_szPageSize.cy);
	//create the control  
	if(pRichCtrObj->m_ctrRichEdit.Create(dwStyle,rect,this,pageindex))
	{  
           //  get how many line one page can hold
	   if(0==pageindex)
	     m_lPageLineCnt=pRichCtrObj->m_ctrRichEdit.GetMaxLineCnt();
	}
   return 0;
}


滚动窗口时,超过43页的页面无法正常显示.
更重要的是:
我只想显示数据,而不需要编辑它,所以我希望进行分页,使阅读更加容易.


when Scroll the window ,the page more than 43,can not show normally .
what''s more:
i just want to show data,and needn''t to edit it,so i wish to do the paging,make reading more easy.

推荐答案

创建一个单独的RichEdit每个页面的控件可能不是要走的路.当用户在某处插入一行时,您将不得不重新调整所有页面控件.而是使用单个RichEdit控件,并使其显示用户想要查看的当前页面.

据我从上面的代码可以猜到的那样,您计划在视图中垂直排列N个这样的RichEdit控件,并让用户浏览该较长的排列.这是可能的,但在许多方面都很麻烦.例如,您将需要为每个用户编辑调整控件的数量及其显示的内容.

如果您必须实施一些所有者绘图以显示页面边界,我建议您只使用一个控件.
Creating a separate RichEdit control for every page is probably not the way to go. When the user inserts a line at some place you would have to readjust all your page controls. Use a single RichEdit control instead and let it display the current page the user wants to see.

As far as I can guess from the above code, you are planning to arrange N of such RichEdit controls vertically in a view and let the user browse that long arrangement. That''s possible, but cumbersome in many ways. For example will you have to adjust the number of controls and the contents they show for every user edit.

I would recommend going into the direction of just one control, ever if you have to implement some owner drawing to show the page boundaries.


这篇关于用MFC分页文档时出现问题困扰着我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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