TScrollBox响应鼠标滚轮题目
添加时间:2013-7-2 点击量:
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;
所有随风而逝的都属于昨天的,所有历经风雨留下来的才是面向未来的。—— 玛格丽特·米切尔 《飘》
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;
所有随风而逝的都属于昨天的,所有历经风雨留下来的才是面向未来的。—— 玛格丽特·米切尔 《飘》