zoukankan      html  css  js  c++  java
  • wpf坐标转换相关

    window = Window.GetWindow(【Visual】);
    Point offset = 【Visual】.TransformToAncestor(window).Transform(new Point(0, 0))

    上面代码可以获得任意组件的窗口坐标。

    获取鼠标相对于任意组件的位置用Mouse.GetPosition(IInputElement relativeTo)或MouseEventArgs.GetPosition(IInputElement relativeTo)

    获取屏幕鼠标位置用win32api

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Runtime.InteropServices;
    
    namespace Samples
    {
        class Win32
        {
            [StructLayout(LayoutKind.Sequential)]
            public struct POINT
            {
                public int X;
                public int Y;
    
                public POINT(int x, int y)
                {
                    this.X = x;
                    this.Y = y;
                }
            }
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            public static extern bool GetCursorPos(out POINT pt);     
             
        }
    }
  • 相关阅读:
    黑色边影,
    拉伸的代码,
    一定是selection的原因啊,要不然呢,
    status bar的差别,
    黄色,
    域名错了,
    node=day4
    PS切片
    移动端插件IScroll.js
    移动web资源概论
  • 原文地址:https://www.cnblogs.com/wangjixianyun/p/2883096.html
Copyright © 2011-2022 走看看