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);

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

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 几款比较有名的刷流量软件「建议收藏」

    几款比较有名的刷流量软件「建议收藏」谨记:刷流量一直是提高网店或者网站不是很正规的方法,虽然流量很快会上去,但也要合理使用或使用其他正规的方法提高流量!为网站刷流量,提高网站的排名,就要用到刷流量软件,主要有流量精灵,飞速流量专家和天河流量王是三款比较有名的流量软件,下面把它们的功能比较一下!      第一款软件飞速流量专家      该款软件同样采用互点积分制,特点就是该软件支持纯网赚用户,就是说

  • 华中农业大学python实验题

    华中农业大学python实验题华中农业大学Python部分实验题,旨在为大家提供思路,希望大家抱着借鉴的心理来学习,不要直接抄袭。

  • 贪心算法之背包问题

    贪心算法之背包问题

  • PTA-集合相似度[通俗易懂]

    PTA-集合相似度[通俗易懂]原题链接输入样例:33 99 87 1014 87 101 5 877 99 101 18 5 135 18 9921 21 3输出样例:50.00%33.33%#include<bits/stdc++.h>#define x first#define y second#define send string::nopsusing namespace std;typedef long long ll;const int N = 1e4 + 10;cons

  • 捋一捋PDF、PMF、CDF是什么

    捋一捋PDF、PMF、CDF是什么总第230篇/张俊红还记得前段时间看过一篇文章,就是调查大家疫情期间都干了什么,有一条是疫情期间终于弄清楚了PDF和CDF的区别。PDF、PMF、CDF这几个概念确实很容易混淆。今天就来…

  • Seata-Saga模式 原理

    Seata-Saga模式 原理1Saga模式示例1.1Saga状态机工具状态机设计组件:seata-saga-statemachine-designer状态机在线画图工具:saga_designer1.2代码示例github上Seata-sample有完整的示例代码,SeataSaga模式中有此示例的完整介绍和分析。这里仅摘取部分和介绍原理有关的代码进行分析。1.2.1初始化dbmysql示例:CREATETABLEIFNOTEXISTS`seata_state_machine_def`(

发表回复

您的电子邮箱地址不会被公开。

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