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

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

问题描述

文本框或RichTextBox的,只有我要的是触发功能的事情时滚动条动作。

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天全站免登陆