KB10337 - Mouse Wheel support in the TatukGIS Project.
Delphi supports the Mouse Wheel only as a focused control. So you can proceed by calling GIS_ViewerWND1.SetFocus. But better is to add OnMouseWheelXXX events on your form and redirect such events into the GIS_ViewerWND control.
For example, this code shows how to add zoom-in on a mouse wheel event:
procedure
TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
GISMouseWheelDown( Sender, Shift, MousePos, Handled ) ;
end;
procedure TForm1.GISMouseWheelDown(Sender: TObject;
Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
var
pt : TPoint ;
ptg1 : TGIS_Point ;
ptg2 : TGIS_Point ;
delta : TGIS_Point ;
begin
with GIS do begin
pt := ScreenToClient( MousePos ) ;
if not PtInRect( ClientRect, pt ) then exit ; // not this window
Handled := True ;
if IsEmpty then exit ;
// zoom and restore a proper map position
ptg1 := ScreenToMap( ScreenToClient( MousePos ) ) ;
Zoom := Zoom * 2 ;
ptg2 := ScreenToMap( ScreenToClient( MousePos ) ) ;
delta.X := ptg1.X - ptg2.X ;
delta.Y := ptg1.Y - ptg2.Y ;
Center := GisPoint( Center.X + delta.X, Center.Y + delta.Y ) ;
Handled := True ;
end ;
end;
Created: November 21, 2003, Modified: August 04, 2015