相关文章推荐
胡子拉碴的刺猬  ·  【福田汽车2023款风景G7新能源 ...·  3 年前    · 
乐观的蜡烛  ·  雨总的木僵症到最后治好了吗_雨总的木僵症是什 ...·  3 年前    · 
逼格高的课本  ·  马心瑞凭《大话西游缘起》出圈,不仅被要求拍续 ...·  3 年前    · 
玉树临风的荔枝  ·  书写携手共进共同发展的华彩乐章-中青在线·  3 年前    · 
长情的跑步机  ·  星途星纪元ES什么时候上市?星途星纪元ES最 ...·  3 年前    · 
Code  ›  richedit设置滚动条的位置和更新内容开发者社区
社区功能 position 滚动条 scroll
https://cloud.tencent.com/developer/article/2042117
文雅的小蝌蚪
2 年前
全栈程序员站长

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

腾讯云
开发者社区
文档 意见反馈 控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
发布
首页
学习
活动
专区
工具
TVP 最新优惠活动
返回腾讯云官网
全栈程序员站长
首页
学习
活动
专区
工具
TVP 最新优惠活动
返回腾讯云官网
社区首页 > 专栏 > richedit设置滚动条的位置和更新内容

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

作者头像
全栈程序员站长
发布 于 2022-07-06 17:40:11
1.4K 0
发布 于 2022-07-06 17:40:11
举报
文章被收录于专栏: 全栈程序员必看 全栈程序员必看

大家好,又见面了,我是全栈君

需要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 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 the WM_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);
 
推荐文章
胡子拉碴的刺猬  ·  【福田汽车2023款风景G7新能源 多用途乘用车 长轴平顶7/9座 宁德时代50.23kWh】报价_参数_图片 – 新浪汽车
3 年前
乐观的蜡烛  ·  雨总的木僵症到最后治好了吗_雨总的木僵症是什么_不健全关系雨总为什么会得木僵症 - 抖音
3 年前
逼格高的课本  ·  马心瑞凭《大话西游缘起》出圈,不仅被要求拍续集,还带火一句话_紫霞_影片_观众
3 年前
玉树临风的荔枝  ·  书写携手共进共同发展的华彩乐章-中青在线
3 年前
长情的跑步机  ·  星途星纪元ES什么时候上市?星途星纪元ES最新消息-无敌电动
3 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号