我在程序中用了scrollbox,想实现鼠标滚轮的事件,通过该事件,我就可以让我得窗体上下移动。我的函数是这样的。但是不执行,请大家帮我看看!
procedure TForm2.ScrollBox1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
scrollbox1.VertScrollBar.Position:=wheeldelta+
scrollbox1.VertScrollBar.Position;
end;
procedure TForm2.ScrollBox1MouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
scrollbox1.VertScrollBar.Position:=wheeldelta+
scrollbox1.VertScrollBar.Position;
end;
解决方案 »
- 控件问题,下载点cxPC, cxControls, MyPageControl
- 用CreateFile直接读硬盘超过2g部分就出错的问题。(xpsp2系统,ntfs分区)
- 过年散分,嘿嘿
- 请大家帮忙!!想用delphi做一个cs结构的东东,数据库在服务器上,客户端的软件如何与服务器进行通信,也就是如何读写数据?
- 窗体应用:无法改变应用程序图标,Project Options->Application->Locd Icon...变灰了
- 关于dll,up有分
- dbedit的问题?
- C/S结构问题,可否使用MS Access作为局域网中的数据库??
- 高手请进
- 求Delphi高手牛人帮帮忙
- 动态生成控件的问题!
- 有没有好一点做delphi控件的书?
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
BoxPos, ABoxPos: TPoint;
begin
with Scrollbox1 do
begin
BoxPos := ClientToScreen(Point(0, 0));
ABoxPos := BoxPos;
Inc(ABoxPos.X, Width);
Inc(ABoxPos.Y, Height);
if (MousePos.X >= BoxPos.X) and (MousePos.X <= ABoxPos.X) and
(MousePos.Y >= BoxPos.Y) and (MousePos.Y <= ABoxPos.Y) then
begin
WheelDelta := WheelDelta*VertScrollBar.Range div Self.VertScrollBar.Range;
VertScrollBar.Position := WheelDelta + VertScrollBar.Position;
end;
end;
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
我的scrollbox是充满整个窗体的。我试了你的方法,还是不行
有没有其他更好一点的例子呢?