⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 如何理解cscrollview中的滚动条及视图处理,请各位帮忙解答几个小问题.htm

📁 visual c++ MFC教程式
💻 HTM
📖 第 1 页 / 共 2 页
字号:
lpClipRect指向一个CRect对象或RECT结构,指定了要滚动的裁剪区域。只有这个矩形中的位才会被滚动。在矩形之外的位不会被影响,即使它们是在lpRect矩形之内。如果lpClipRect为NULL,则不会在滚动矩形上进行裁剪。 
&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 
说明这个函数滚动当前CWnd对象的客户区内容。如果插字符在要滚动的CWnd之内,则ScrollWindow自动将插字符隐藏,以避免它被擦除,然后当滚动完成以后,再恢复插字符。插字符的位置将相应地调整。ScrollWindow成员函数所涉及的区域将不会被重画,但是将被加入当前CWnd对象的更新区域。应用程序最终将接收到一条WM_PAINT消息,通知它这个区域需要重画。要在滚动完成的同时重画涉及的区域,则应在调用ScrollWindow之后立即调用UpdateWindow成员函数。如果lpRect为NULL,则窗口的任何子窗口的位置将被设为xAmout和yAmout指定的偏移,并且CWnd中任何无效(未画出)区域也被加上偏移。当lpRect为NULL的时候,ScrollWindow更快一些。如果lpRect不为NULL,则子窗口的位置不发生变化,并且CWnd的无效区域也没有偏移。当lpRect为NULL的时候,如果要防止更新问题,则应在调用ScrollWindow之前调用UpdateWindow成员函数以重画CWnd。</P>
<H3><STRONG><A class=anchor name=r_29930997>7 
楼</A>krh2001(边城浪子)</STRONG><SPAN>回复于 2005-06-07 09:03:16 得分 0 </SPAN></H3>
<P> <BR>&nbsp; BOOL &nbsp; CScrollViewEx::OnScrollBy(CSize &nbsp; sizeScroll, 
&nbsp; BOOL &nbsp; bDoScroll) &nbsp; &nbsp; <BR>&nbsp; { &nbsp; <BR>&nbsp; 
CPoint &nbsp; ptOrig,ptNew; &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; // &nbsp; don't 
&nbsp; scroll &nbsp; if &nbsp; there &nbsp; is &nbsp; no &nbsp; valid &nbsp; 
scroll &nbsp; range &nbsp; (ie. &nbsp; no &nbsp; scroll &nbsp; bar) &nbsp; 
<BR>&nbsp; CScrollBar* &nbsp; pBar; &nbsp; <BR>&nbsp; DWORD &nbsp; dwStyle 
&nbsp; = &nbsp; GetStyle(); &nbsp; <BR>&nbsp; pBar &nbsp; = &nbsp; 
GetScrollBarCtrl(SB_VERT); &nbsp; <BR>&nbsp; if &nbsp; ((pBar &nbsp; != &nbsp; 
NULL &nbsp; &amp;&amp; &nbsp; !pBar-&gt;IsWindowEnabled()) &nbsp; || &nbsp; 
<BR>&nbsp; (pBar &nbsp; == &nbsp; NULL &nbsp; &amp;&amp; &nbsp; !(dwStyle &nbsp; 
&amp; &nbsp; WS_VSCROLL))) &nbsp; <BR>&nbsp; { &nbsp; <BR>&nbsp; // &nbsp; 
vertical &nbsp; scroll &nbsp; bar &nbsp; not &nbsp; enabled &nbsp; <BR>&nbsp; 
sizeScroll.cy &nbsp; = &nbsp; 0; &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; pBar 
&nbsp; = &nbsp; GetScrollBarCtrl(SB_HORZ); &nbsp; <BR>&nbsp; if &nbsp; ((pBar 
&nbsp; != &nbsp; NULL &nbsp; &amp;&amp; &nbsp; !pBar-&gt;IsWindowEnabled()) 
&nbsp; || &nbsp; <BR>&nbsp; (pBar &nbsp; == &nbsp; NULL &nbsp; &amp;&amp; &nbsp; 
!(dwStyle &nbsp; &amp; &nbsp; WS_HSCROLL))) &nbsp; <BR>&nbsp; { &nbsp; 
<BR>&nbsp; // &nbsp; horizontal &nbsp; scroll &nbsp; bar &nbsp; not &nbsp; 
enabled &nbsp; <BR>&nbsp; sizeScroll.cx &nbsp; = &nbsp; 0; &nbsp; <BR>&nbsp; } 
&nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; ptOrig=GetScrollPosition(); &nbsp; 
<BR>&nbsp; // &nbsp; adjust &nbsp; current &nbsp; position &nbsp; <BR>&nbsp; 
ptNew=ptOrig+sizeScroll; &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; // &nbsp; check 
&nbsp; x &nbsp; position &nbsp; <BR>&nbsp; if &nbsp; (ptNew.x &nbsp; &gt; &nbsp; 
m_szTotal.cx-m_szPage.cx) &nbsp; <BR>&nbsp; ptNew.x &nbsp; = &nbsp; 
m_szTotal.cx-m_szPage.cx; &nbsp; <BR>&nbsp; if &nbsp; (ptNew.x &nbsp; &lt; 
&nbsp; 0) &nbsp; <BR>&nbsp; ptNew.x &nbsp; = &nbsp; 0; &nbsp; <BR>&nbsp; &nbsp; 
<BR>&nbsp; // &nbsp; check &nbsp; y &nbsp; position &nbsp; <BR>&nbsp; if &nbsp; 
(ptNew.y &nbsp; &gt; &nbsp; m_szTotal.cy-m_szPage.cy) &nbsp; <BR>&nbsp; ptNew.y 
&nbsp; = &nbsp; m_szTotal.cy-m_szPage.cy; &nbsp; <BR>&nbsp; if &nbsp; (ptNew.y 
&nbsp; &lt; &nbsp; 0) &nbsp; <BR>&nbsp; ptNew.y &nbsp; = &nbsp; 0; &nbsp; 
<BR>&nbsp; &nbsp; <BR>&nbsp; // &nbsp; did &nbsp; anything &nbsp; change? &nbsp; 
<BR>&nbsp; if &nbsp; (ptNew &nbsp; == &nbsp; ptOrig) &nbsp; <BR>&nbsp; return 
&nbsp; FALSE; &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; if &nbsp; (bDoScroll) &nbsp; 
<BR>&nbsp; { &nbsp; <BR>&nbsp; // &nbsp; do &nbsp; scroll &nbsp; and &nbsp; 
update &nbsp; scroll &nbsp; positions &nbsp; <BR>&nbsp; SCROLLINFO &nbsp; info; 
&nbsp; <BR>&nbsp; int &nbsp; xMove=-(ptNew.x &nbsp; - &nbsp; ptOrig.x) &nbsp; * 
&nbsp; m_szUnit.cx; &nbsp; <BR>&nbsp; int &nbsp; yMove=-(ptNew.y &nbsp; - &nbsp; 
ptOrig.y) &nbsp; * &nbsp; m_szUnit.cy; &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 
DoScrollWindow(xMove,yMove); &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; 
info.fMask=SIF_POS; &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; if(ptNew.x!=ptOrig.x) 
&nbsp; <BR>&nbsp; { &nbsp; <BR>&nbsp; info.nPos=ptNew.x; &nbsp; <BR>&nbsp; 
SetScrollInfo(SB_HORZ,&amp;info); &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; &nbsp; 
<BR>&nbsp; if(ptNew.y!=ptOrig.y) &nbsp; <BR>&nbsp; { &nbsp; <BR>&nbsp; 
info.nPos=ptNew.y; &nbsp; <BR>&nbsp; SetScrollInfo(SB_VERT,&amp;info); &nbsp; 
<BR>&nbsp; } &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; return &nbsp; TRUE; &nbsp; 
<BR>&nbsp; } &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; &nbsp; <BR>&nbsp; void &nbsp; 
CScrollViewEx::DoScrollWindow(int &nbsp; xMove, &nbsp; int &nbsp; yMove) &nbsp; 
<BR>&nbsp; { &nbsp; <BR>&nbsp; CRect &nbsp; rc,rcScroll; &nbsp; <BR>&nbsp; 
GetClientRect(&amp;rc); &nbsp; <BR>&nbsp; rcScroll=rc; &nbsp; <BR>&nbsp; 
rcScroll.left+=GetDocument()-&gt;GetColWidth(-1); &nbsp; <BR>&nbsp; 
if(xMove&lt;rcScroll.Width()){ &nbsp; <BR>&nbsp; 
ScrollWindow(xMove,0,&amp;rcScroll,&amp;rcScroll); &nbsp; <BR>&nbsp; }else{ 
&nbsp; <BR>&nbsp; InvalidateRect(&amp;rcScroll); &nbsp; <BR>&nbsp; goto &nbsp; 
ENDL; &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; rcScroll=rc; &nbsp; <BR>&nbsp; 
rcScroll.top+=GetDocument()-&gt;GetLineHeight(-1); &nbsp; <BR>&nbsp; 
if(yMove&lt;rcScroll.Height()){ &nbsp; <BR>&nbsp; 
ScrollWindow(0,yMove,&amp;rcScroll,&amp;rcScroll); &nbsp; <BR>&nbsp; }else{ 
&nbsp; <BR>&nbsp; InvalidateRect(&amp;rcScroll); &nbsp; <BR>&nbsp; goto &nbsp; 
ENDL; &nbsp; <BR>&nbsp; } &nbsp; <BR>&nbsp; ENDL:; &nbsp; <BR>&nbsp; &nbsp; 
<BR>&nbsp; }</P>
<H3><STRONG><A class=anchor name=r_29931615>8 
楼</A>coolwin11(鹰之歌)</STRONG><SPAN>回复于 2005-06-07 09:19:38 得分 0 </SPAN></H3>
<P>明白了,谢谢各位!</P>
<H4><STRONG>相关问题</STRONG></H4>
<DIV class=relation>
<UL></UL></DIV></DIV></DIV><BR><BR>
<HR>

<H5>推荐文章</H5>
<UL>
  <LI><A title=如何在SDI的工作区里显示一张bmp图片?大家帮忙,谢谢! 
  href="http://www.ask-expert.cn/html/yongliang/200611/50672.html">如何在SDI的工作区里显示一张bmp图片?大家帮忙,谢谢!</A> 

  <LI><A title=大家帮帮忙看看,真是阴沟里翻船了 
  href="http://www.ask-expert.cn/html/yongliang/200611/39371.html">大家帮帮忙看看,真是阴沟里翻船了</A> 

  <LI><A title=vc开发控件的问题!!! 
  href="http://www.ask-expert.cn/html/yongliang/200611/41358.html">vc开发控件的问题!!!</A> 

  <LI><A title=对话框中加入ACTIVEX控件以后,对话框就不能DOMODAL弹出的问题。 
  href="http://www.ask-expert.cn/html/yongliang/200611/46493.html">对话框中加入ACTIVEX控件以后,对话框就不能DOMODAL弹出的问题。</A> 

  <LI><A title="升星,散分,呵呵 :)" 
  href="http://www.ask-expert.cn/html/yongliang/200611/41520.html">升星,散分,呵呵 
  :)</A> 
  <LI><A title="主  题:  全面详细新帖[调查]您从事软件开发多少年了,薪水," 
  href="http://www.ask-expert.cn/html/yongliang/200611/43183.html">主  题: 
  全面详细新帖[调查]您从事软件开发多少年了,薪水,</A> 
  <LI><A title=各位大哥请教该如何显示表里所有的内容 
  href="http://www.ask-expert.cn/html/yongliang/200611/50552.html">各位大哥请教该如何显示表里所有的内容</A> 

  <LI><A title=如何在控件中加入picture控件 
  href="http://www.ask-expert.cn/html/yongliang/200611/46929.html">如何在控件中加入picture控件</A> 

  <LI><A title=新手请教:为何我的MDI项目一启动就有一个子窗体启动,如何不让 
  href="http://www.ask-expert.cn/html/yongliang/200611/37015.html">新手请教:为何我的MDI项目一启动就有一个子窗体启动,如何不让</A> 

  <LI><A title=求MSChart控件的资料 
  href="http://www.ask-expert.cn/html/yongliang/200611/50990.html">求MSChart控件的资料</A> 

  <LI><A title="写一个类似ping程序中修改本机的IP地址,类似于简单的IP欺骗, " 
  href="http://www.ask-expert.cn/html/yongliang/200611/40795.html">写一个类似ping程序中修改本机的IP地址,类似于简单的IP欺骗, 
  </A>
  <LI><A title=用SHFileOperation删除文件的怪问题 
  href="http://www.ask-expert.cn/html/yongliang/200611/43100.html">用SHFileOperation删除文件的怪问题</A> 

  <LI><A title=用Domodal()打开一个对话框是怎样初始化对话框里面的控件? 
  href="http://www.ask-expert.cn/html/yongliang/200611/37474.html">用Domodal()打开一个对话框是怎样初始化对话框里面的控件?</A> 

  <LI><A title=在FORMVIEW派生试图中动态生成控件的问题 
  href="http://www.ask-expert.cn/html/yongliang/200611/38748.html">在FORMVIEW派生试图中动态生成控件的问题</A> 

  <LI><A title=怎么在CONSOLE程序中使用定时器? 
  href="http://www.ask-expert.cn/html/yongliang/200611/42787.html">怎么在CONSOLE程序中使用定时器?</A> 
  </LI></UL>
<HR>
<A href="http://www.ask-expert.cn/plus/sitemap.html">站点地图</A> | <A 
href="http://www.ask-expert.cn/plus/rssmap.html">RSS订阅</A> <BR>
<SCRIPT language=javascript 
src="如何理解CScrollView中的滚动条及视图处理,请各位帮忙解答几个小问题.files/749383.js" 
type=text/javascript></SCRIPT>
<NOSCRIPT><A href="http://www.51.la/?749383" target=_blank><IMG 
style="BORDER-TOP-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none" 
alt=我要啦免费统计 
src="如何理解CScrollView中的滚动条及视图处理,请各位帮忙解答几个小问题.files/s.gif"></A></NOSCRIPT> 
</DIV><BR><BR><BR></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -