Delphi组件中的鼠标滚轮事件

发布于 2024-10-05 14:02:15 字数 300 浏览 7 评论 0原文

我想写一个使用鼠标滚轮缩放的组件 类似于谷歌地球的东西。

我有一个使用 onMouseWheel 的组件,并且有属性 MaxZoom MinZoom 和 Zoom 有一个更好的选择,即带有位图的 StretchDraw 我正在尝试以表格形式获取组件区域的位置

据我所知,我必须找到每个父级,直到我找到 tCustomform 并添加所有组件的顶部和左侧组件以获取对象位置以找到我的对象位置。 有更好的方法

一旦我有了位置,如果鼠标位于我的对象上方以及从哪里缩放,我可以从鼠标光标位置缩放地图,是否

。请问有人见过任何代码吗

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

相对绾红妆 2024-10-12 14:02:16

如果您正在编写组件,那么您应该尝试重写组件中的这两个方法:

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

它们是 TControl 的受保护动态方法。每当鼠标滚轮旋转时,它们就会被调用。

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.

北城孤痞 2024-10-12 14:02:16

这取决于您要缩放的内容类型;
我只会在这里发布如何

私有声明上

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

在创建或任何其他启动过程中的

OnMouseWheel := formMouseWheel; // depends on you 

获取轮子移动了多长时间FormMouseWheel 像这样

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;

我使用 vcl 表单(不在组件内部)检查它,
如果您想缩放,请将您想要缩放的内容告诉我们

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文