首页 > 开发 > 综合 > 正文

在MapX中响应滚轮放大缩小地图

2024-07-21 02:25:23
字体:
来源:转载
供稿:网友

’模块中

option explicit

public const gwl_wndproc = (-4)
public const wm_command = &h111
public const wm_mbuttondown = &h207
public const wm_mbuttonup = &h208
public const wm_mousewheel = &h20a

public oldwinproc   as long
public declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long
public declare function callwindowproc lib "user32" alias "callwindowproca" (byval lpprevwndfunc as long, byval hwnd as long, byval msg as long, byval wparam as long, byval lparam as long) as long
public declare function getwindowlong lib "user32" alias "getwindowlonga" (byval hwnd as long, byval nindex as long) as long

public function flexscroll(byval hwnd as long, byval wmsg as long, byval wparam as long, byval lparam as long) as long
    select case wmsg
        case wm_mousewheel
            select case wparam
                case -7864320     '向下滚
                    setcurrentscale "zoomout", 2
                case 7864320       '向上滚
                    setcurrentscale "zoomin", 2
          end select
    end select
   
    flexscroll = callwindowproc(oldwinproc, hwnd, wmsg, wparam, lparam)
end function



private sub setcurrentscale(strinorout as string, dscale as double)
    if frmmain.map1 is nothing then exit sub
   
    if strinorout = "zoomin" then
        frmmain.map1.zoom = (frmmain.map1.zoom) * dscale
        frmmain.map1.refresh
    elseif strinorout = "zoomout" then
        frmmain.map1.zoom = (frmmain.map1.zoom) / dscale
        frmmain.map1.refresh
    end if
end sub







private sub form_load()
        
    oldwinproc = getwindowlong(map1.hwnd, gwl_wndproc)
    setwindowlong map1.hwnd, gwl_wndproc, addressof flexscroll

end sub

private sub form_unload(cancel as integer)
    setwindowlong map1.hwnd, gwl_wndproc, oldwinproc
end sub


商业源码热门下载www.html.org.cn

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表