zoukankan      html  css  js  c++  java
  • TScrollBox响应鼠标滚轮问题

    Delphi的TScrollBox本身并不响应鼠标滚轮事件(不知道为什么),但可以在ScrollBox的鼠标滚动事件中进行控制:

    procedure TfrmTaskNoteEdit.ScrollBox1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
      MousePos: TPoint; var Handled: Boolean);
    begin
      if   WheelDelta   <   0   then
        SendMessage(scrollBox1.Handle,WM_VSCROLL,   SB_LINEDOWN,   0) //向下滚
      else
        SendMessage(scrollBox1.Handle,WM_VSCROLL,   SB_LINEUP,   0); //向上滚
    end;


    测试通过,奇怪的是我在一个PageControl的两个页面中分别放置两个ScrollBox时只有一个有响应,郁闷,后来只好调整到窗体的MouseWheel事件中:

    procedure TfrmTaskNoteEdit.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
      var Handled: Boolean);
    begin
      inherited;
      case RzPageControl1.ActivePageIndex of
        0:
        begin
          if WheelDelta < 0 then
            ScrollBox1.Perform(WM_VSCROLL,SB_LINEDOWN,0)
          else
            ScrollBox1.Perform(WM_VSCROLL,SB_LINEUP,0);
        end;
        2:
        begin
          if WheelDelta < 0 then
            ScrollBox2.Perform(WM_VSCROLL,SB_LINEDOWN,0)
          else
            ScrollBox2.Perform(WM_VSCROLL,SB_LINEUP,0);
        end;
      end;
    end;
  • 相关阅读:
    第二次作业
    初学JAVA的 感想 尹鑫磊
    初学JAVA 感想
    《将博客搬至CSDN》
    JAVA中的几种内部类
    JAVA-静态变量与实体变量
    teacher页面的代码
    测试说明书的概述和摘要
    网站的概述
    html与xhtml的区别
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/3166670.html
Copyright © 2011-2022 走看看