捕获文本框滚动事件? [英] Catch Textbox Scroll Event?

查看:29
本文介绍了捕获文本框滚动事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文本框或富文本框,我唯一想要的就是在滚动条移动时触发一个功能.

Textbox or richtextbox, only thing i want is triggering a function when scrollbar moves.

我已经找到了 GetScrollPos 和 SetScrollPos.我想定期检查滚动条的位置,但必须有更好的方法.那么,什么是更好的方法?

I already found GetScrollPos and SetScrollPos. I thought of checking scrollbar position periodically but there must be a better way. So, what is the better way?

更新:使用 WinForms

Update: Using WinForms

推荐答案

假设是WinForms,可以试试pinvoking:

Assuming WinForms, you can try pinvoking:

public class MyRTF: RichTextBox {

  private const int WM_HSCROLL = 0x114;
  private const int WM_VSCROLL = 0x115;
  private const int WM_MOUSEWHEEL = 0x20A;

  protected override void WndProc(ref Message m) {
    base.WndProc(ref m);

    if (m.Msg == WM_VSCROLL || m.Msg == WM_HSCROLL || m.Msg == WM_MOUSEWHEEL) {
      // scrolling...
    }
  }

}

这篇关于捕获文本框滚动事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆