richedit设置滚动条的位置和更新内容

需要txt发现读者richedit的scrollbar位置(为了便于下一次读,直接访问与上次读取下一个读取位置)不值得治疗,采用GetScrollPos、SetScrollPos你可以设置scorllbar位置值。可是!

SetScorllPos调用后仅仅更新了scorllbar的位置richedit的内容没得到更新,google一下没有个现成的解决。仅仅得msdn。

WM_VSCROLL重点标记一下:

SB_THUMBPOSITION

The user has dragged the scroll box (thumb) and released the mouse button. The HIWORD indicates
the position of the scroll box at the end of the drag operation.

However, because the SetScrollInfoSetScrollPosSetScrollRangeGetScrollInfo,GetScrollPos,
and GetScrollRange functions
support 32-bit scroll bar position data, there is a way to circumvent the 16-bit barrier of the WM_HSCROLL and WM_VSCROLL messages.
SeeGetScrollInfo for
a description of the technique.

GetScrollInfo重点标记一下:

SIF_TRACKPOS

Copies the current scroll box tracking position to the nTrackPosmember of the SCROLLINFO structure
pointed to by lpsi.

Remarks

The GetScrollInfo function enables applications to use 32-bit scroll positions. Although the messages that indicate scroll bar position, WM_HSCROLL and WM_VSCROLL,
provide only 16 bits of position data, the functions SetScrollInfo and GetScrollInfo provide
32 bits of scroll bar position data. Thus, an application can call GetScrollInfo while processing either theWM_HSCROLL or WM_VSCROLL messages to obtain 32-bit scroll bar position data.

To get the 32-bit position of the scroll box (thumb) during a SB_THUMBTRACK request code in a WM_HSCROLL or WM_VSCROLL message,
call GetScrollInfo with the SIF_TRACKPOS value in the fMask member of the SCROLLINFO structure.
The function returns the tracking position of the scroll box in the nTrackPos member of the SCROLLINFO structure. This allows you to get the position of the scroll box as the user moves it. The following sample code illustrates
the technique.

SCROLLINFO si;
case WM_HSCROLL:
    switch(LOWORD(wparam)) {
        case SB_THUMBTRACK:
          // Initialize SCROLLINFO structure

            ZeroMemory(&si, sizeof(si));
            si.cbSize = sizeof(si);
            si.fMask = SIF_TRACKPOS;

          // Call GetScrollInfo to get current tracking
          //    position in si.nTrackPos

            if (!GetScrollInfo(hwnd, SB_HORZ, &si) )
                return 1; // GetScrollInfo failed
            break;
        .
        .
        .
    }

实现本文功能:

//保存scrollbar位置
  SCROLLINFO Info={0};
  Info.cbSize=sizeof Info;
  Info.fMask=SIF_TRACKPOS;
  GetScrollInfo(RichEdit1->Handle,SB_VERT,&Info);
  std::auto_ptr<TIniFile> ptrIni(new TIniFile(ExtractFilePath(Application->ExeName)+"Config"));
  ptrIni->WriteInteger("Reader","ScorllPos",Info.nTrackPos);

//设置scrollbar位置
    std::auto_ptr<TIniFile> ptrIni(new TIniFile(ExtractFilePath(Application->ExeName)+"Config"));
    int pos=ptrIni->ReadInteger("Reader","ScorllPos",0);
    SendMessage(RichEdit1->Handle,WM_VSCROLL,MAKEWPARAM(SB_THUMBPOSITION,pos),0);

版权声明:本文博主原创文章,博客,未经同意不得转载。

时间: 2024-08-09 14:33:13

richedit设置滚动条的位置和更新内容的相关文章

richedit设置滚动条位置并更新内容

想做txt阅读器时发现richedit的scrollbar位置(为了下次阅读方便,下次读取直接获取上次阅读位置)不好处理,使用GetScrollPos.SetScrollPos能够获取设置scorllbar位置的值,但是!SetScorllPos调用后只更新了scorllbar的位置richedit的内容没得到更新,google一下没有个现成的解决,只得msdn. WM_VSCROLL重点标记一下: SB_THUMBPOSITION The user has dragged the scroll

java中JTextPane使输出字符到指定的宽度换行,并将垂直滚动条的位置移动到输出的最后位置

SimpleAttributeSet set = new SimpleAttributeSet(); Document doc = tp.getStyledDocument(); FontMetrics fm = tp.getFontMetrics(tp.getFont());//得到JTextPane 的当前字体尺寸 int paneWidth = tp.getWidth();//面板的宽度 String text = new String(bt, 0, len); try { for(int

jQuery:实现图片按需加载的方法,当要显示内容的高度超过了页面的高度,按需加载,根据滚动条的位置来判断页面显示的内容

实现图片按需加载的方法,当要显示内容的高度超过了页面的高度,按需加载,根据滚动条的位置来判断页面显示的内容 这个类似于京东或淘宝页面,根绝页面的滚动,显示下面的内容 如下图所示,一开始并不是所有的图片都显示,当滚动条移动到页面最下面的时候,再显示下面的内容 解决思路:通过判断滚动条是否滚动到了页面的最下面,如果滚动到了页面的最下面,则重新加载图片 知识点:1.offset() 方法返回或设置匹配元素相对于文档的偏移(位置) 返回第一个匹配元素的偏移坐标. 该方法返回的对象包含两个整型属性:top

Win10 Mobile/PC稳定预览版14393.221(222)更新内容大全

win10之家 10月1日消息,微软此前推送了Win10 Mobile一周年更新预览版14393.221,而今天推送了Win10 PC年度更新14393.222,虽然版本号有差异,但微软将两次Windows10累积更新内容合并到一起公布. 下面IT之家为大家整理的Win10 Build 14393.222 (PC) / 14393.221 (Mobile)更新内容: 提升相关稳定性,包括Windows更新代理.驱动分享.VPN虚拟网络.集群.HTTP下载.IE11.Hyper-V虚拟机.多媒体播

关于div的滚动条滚动到底部,内容显示不全的问题。(已解决)

今天我做了一个带有滚动条,底部有两个按钮的div.  当我拖动滚动条到底部, 按钮没有显示出来.  我看了看我的样式设置,是这样的: /* 内容样式 */ #contentPartDiv{ position:fixed; top:4em; bottom:0; width:100%; height:100%; overflow-y:auto; } 这个意思是 内容的位置固定, 高度占满剩余的部分,自动滚动.  为此没必要设置高度height, 所以我去掉它. 然后重启页面,好了, 而且不管我怎么修

获取滚动条的位置

下面就开始scrollTop 用法讲解: scrollTop() 定义和用法 scrollTop() 方法设置或返回被选元素的[垂直滚动条位置]. Note: 当滚动条位置位于最顶部时,位置是0:当用于返回位置时:    该方法返回 第一个匹配元素的滚动条的垂直位置.当用于设置位置时:    该方法设置 所有匹配元素的滚动条的垂直位置. scrollTop() 语法 返回滚动条位置 $(selector).scrollTop() 设置滚动条位置 $(selector).scrollTop(pos

Apache设置经验总结(持续更新)

Alias 想让/opt/foswiki的内容显示出来,但不想拷贝到/var/www/html中,怎么做 Alias /foswiki/ "/opt/foswiki/" <Directory "/opt/foswiki/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> 这些是模

谷歌下设置滚动条的css样式

.oLi-lists-scroll::-webkit-scrollbar { width:5px;  padding:1px; background:url(../images/repeat-bar.png) repeat-y;} /* Track */ .oLi-lists-scroll::-webkit-scrollbar-track {height:4px;} /* Handle */ .oLi-lists-scroll::-webkit-scrollbar-thumb { backgro

转载自前端开发:CSS设置滚动条样式

浏览器默认的滚动条样子太过屌丝了,得自己动手整整.记得IE浏览器有几个设置滚条的样式,不过比较鸡肋,只能设置颜色之类的,而且webkit下面也不支持.无意间看到网易邮箱的滚动条样子很好看,一开始以为是用div模拟的,结果一看,吼吼,正合我意,利用的CSS来设置的,而且是webkit浏览器的. 得好好研究这几个属性下,才能自己动手改造. webkit浏览器css设置滚动条 主要有下面7个属性 ::-webkit-scrollbar 滚动条整体部分,可以设置宽度啥的 ::-webkit-scroll