开发者

Delphi Mouse wheel event in component

I'm wanting to write a component that uses the mouse wheel to zoom something similar to Google earth.

I have a component using onMouseWheel and I have properties MaxZoom MinZoom and Zoom there is a better option that StretchDraw with the bitmap I'm trying to get the location of the components area in the form

What I understand I have to find each parent until I find the tCustomform and add all Component's top and components left to get the objects location to find my objects location. is there a better way

once I have the location I can zoom a Map from the mouse cursor location if the mouse is over my object and where to zoom from.

has any one seen any code please 开发者_运维问答


If you are writing a component then you should try overriding these 2 methods in your component:

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

which are protected dynamic methods of TControl. They get called whenever the mouse wheel is rotated.


It depends on what kind of content you are going to zoom ; I will only Post here how to get how long the wheel has moved

on private declaration

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

on create or any other starting procedure

OnMouseWheel := formMouseWheel; // depends on you 

The FormMouseWheel comes like this

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 checked it using vcl form (not inside component ), If You want to zoom post us what kind of content you want to zoom

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜