chart 或 dbchart 滚动键滚动放大问题(200分)

  • 主题发起人 主题发起人
  • 开始时间 开始时间

Unregistered / Unconfirmed
GUEST, unregistred user!
在chart的 mousemove事件中加入的 chart.setfocus后
在chart上滚动MOUSE中键,图表会随着在Y轴滚动.
如果想禁止这个滚动,如何处理
(本意是MOUSE中键滚动,只让图表按X方向缩放,不要在Y轴上下滚动. X轴的缩放自写好代码放mousewheelup,mousewheeldown中)
 
好像有这样的属性可以设置的
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TLineSeries;
procedure FormCreate(Sender: TObject);
procedure Chart1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Chart1MouseWheel(Sender: TObject;
Shift: TShiftState;
WheelDelta: Integer;
MousePos: TPoint;
var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
Randomize;
for i := 0 to 20do
Series1.AddXY(i, Random(100));
end;

procedure TForm1.Chart1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
begin
Chart1.SetFocus;
end;

procedure TForm1.Chart1MouseWheel(Sender: TObject;
Shift: TShiftState;
WheelDelta: Integer;
MousePos: TPoint;
var Handled: Boolean);
var
x1, x2, s:do
uble;
begin
//
x1 := Chart1.BottomAxis.Minimum;
x2 := Chart1.BottomAxis.Maximum;
if WheelDelta < 0 then
begin
s := (x2 - x1) / 4;
if s < 0.001 then
s := 0.001;
x1 := x1 - s;
x2 := x2 + s;
end
else
begin
s := (x2 - x1) / 5;
if s < 0.001 then
s := 0.001;
x1 := x1 + s;
x2 := x2 - s;
end;

Chart1.BottomAxis.SetMinMax(x1, x2);
Handled := true;
//主要是这句
end;

end.
 

Similar threads

S
回复
0
查看
828
SUNSTONE的Delphi笔记
S
S
回复
0
查看
758
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部