Delphi mouse wheel event in component

I want to write a component that uses the mouse wheel to enlarge something similar to Google Earth.

I have a component using onMouseWheel, and I have the MaxZoom properties MinZoom and Zoom there is a better option which is a StretchDraw with a bitmap I am trying to get the location of the component area in the form

As I understand it, I have to find every parent until I find tCustomform and add all the components and components of the components left to get the location of the objects, to find the location of my objects. there is a better way

As soon as I have a location, I can enlarge the map from the location of the mouse cursor if the mouse is over my object and where you can zoom in.

is there any code please

+5
source share
2 answers

It depends on what content you are going to increase; I will only post here how to get how long the wheel has been moving

in a private declaration

private
{ Private declarations }
procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);

when creating or any other starting procedure

OnMouseWheel := formMouseWheel; // depends on you 

FormMouseWheel is as follows

procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
// your code here 
// WheelDelta returns you - or + values (in my computer -120 and + 120 ; 
// It depends on control panel mouse wheel settings)

//   If it is a font make the font size bigger or 
// if it is a image 
 // strech := true;
//  increase width and height of the Timage
//and put them inside a scrollbox
// 
end;

I tested it using the vcl form (not inside the component). If you want to zoom in, let us know what content you want to zoom in.

+2
source

If you are writing a component, you should try to override these 2 methods in your component:

function DoMouseWheelDown (Shift: TShiftState; MousePos: TPoint): Boolean; override;
function DoMouseWheelUp (Shift: TShiftState; MousePos: TPoint): Boolean; override;

TControl. , .

+1

All Articles