我想编写一个使用鼠标滚轮缩放类似Google地球的组件.
我有一个使用onMouseWheel的组件,我有属性MaxZoom MinZoom和Zoom有一个更好的选项,StretchDraw与位图我试图获取组件区域的位置在窗体中
据我所知,我必须找到每个父项,直到找到tCustomform并添加所有Component的顶部和组件,以获取对象位置以找到我的对象位置.有没有更好的办法
一旦我有了位置,我可以从鼠标光标位置缩放地图,如果鼠标在我的对象上并且在哪里放大.
有任何人看到任何代码请
这取决于您要缩放的内容类型;我只会在这里发布如何获取轮子移动了多长时间
关于私人声明
private
{ Private declarations }
procedure FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
Run Code Online (Sandbox Code Playgroud)
在创建或任何其他启动过程中
OnMouseWheel := formMouseWheel; // depends on you
Run Code Online (Sandbox Code Playgroud)
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;
Run Code Online (Sandbox Code Playgroud)
我使用 vcl 形式(不在组件内部)进行了检查,如果您想缩放,请向我们发布您想要缩放的内容类型
归档时间: |
|
查看次数: |
9703 次 |
最近记录: |