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

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

大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。

需要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 
SetScrollInfo

SetScrollPos

SetScrollRange

GetScrollInfo
,
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. See
GetScrollInfo
 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);

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116881.html原文链接:https://javaforall.net

(0)
上一篇 2022年1月13日 下午10:00
下一篇 2022年1月13日 下午11:00


相关推荐

  • Microsoft Platform SDK Febrary 2003 Edition 下载地址与下载方式「建议收藏」

    Microsoft Platform SDK Febrary 2003 Edition 下载地址与下载方式「建议收藏」今天上网找windowssdk,发现最新的SDK已经不支持vc6.0,在微软官方站下看到下面一段话。DevelopmentTools.TobuildtheC/C++samples,youmusthaveaC/C++compiler.IfyouareusingMicrosoftVisualC/C++®,runitatleastoncebe

    2022年5月23日
    45
  • c语言流程图各个框的作用,C语言流程图的三种基本结构

    c语言流程图各个框的作用,C语言流程图的三种基本结构现在我们就来讲解一下三种基本的 C 语言结构 其实在夕阳中他有三种基本的结构 我们可以用这三种基本的结构作为一个表示良好算法的基本单元 为了提高算法的储量 然后时尚的设计和阅读方便 我们可以用这三种基本的结构进行划分的 知识点 在计算机中 第一个结构就是顺序结构 虚线框内注视一个十一线结构的顺序结构 其中 A 和 B 两个是顺序执行的 就是执行买一筐之后所指定的操作必须要接着执行 B 所指定的操作 那么顺序结构

    2026年3月17日
    2
  • 获取计算机用户名,java获取计算机用户名

    获取计算机用户名,java获取计算机用户名NetworkInfo()Dimwshnetwork,infoAsStringSetwshnetwork=CreateObject(“WScript.Network”)’获取当前电脑用户信息一、用户名命名规范:总纲:用户名规范包括通用规范和特殊原则。A.通用规范:a.用户名只能由字母、数字和下划线组成,且必须以字母开头。不得出…1、“姓”的全拼+“ZhongS”…

    2022年10月15日
    6
  • Ubuntu20.04下安装QQ[通俗易懂]

    https://blog.csdn.net/dulingwen/article/details/89848661https://blog.csdn.net/qq_36428171/article/details/81209475https://github.com/wszqkzqk/deepin-wine-ubuntuhttps://www.lulinux.com/archives/1319…

    2022年4月16日
    134
  • linux上查看mysql的密码_Linux下MySQL忘记密码「建议收藏」

    linux上查看mysql的密码_Linux下MySQL忘记密码「建议收藏」1、前沿今天在服务器安装mysql之后,登录发现密码错误,但是我没有设置密码呀,最后百度之后得知,mysql在5.7版本之后会自动创建一个初始密码。报错如下:[root@mytestlnx02~]#mysql-uroot-pEnterpassword:ERROR1045(28000):Accessdeniedforuser’root’@’localhost'(usingp…

    2022年6月21日
    245
  • 图像特征:HOG特征

    图像特征:HOG特征主要参考 1 目标检测的图像特征提取之 一 HOG 特征 算法 https www cnblogs com txg198955 p 3999083 html1 HOG 特征 nbsp nbsp nbsp nbsp nbsp nbsp 方向梯度直方图 HistogramofO HOG 特征是一种在计算机视觉和图像处理中用来进行物体检测的特征描述子 它通过计算和统计图像局部区域的梯度方向直方图

    2026年3月17日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号