본문 바로가기
→ 개발/WPF

[WPF] 새 WPF창 띄울때 마우스위치에 띄우기

by 벅스쭌 2010. 7. 12.
반응형

1. 클래스를 생성

    class MouseEvent
    {
        [DllImport("User32")]
        public static extern int GetCursorPos(out MyPoint pt);
    }    

    public struct MyPoint
    {
        public int x;
        public int y;
        public MyPoint(int _x, int _y)
        {
            x = _x;
            y = _y;
        }
    }

2. 사용하기
	MyPoint p;
	AddGrowtemperatureWindow addgrowtemperaturewindow = new AddGrowtemperatureWindow();
	MouseEvent.GetCursorPos(out p);
	addgrowtemperaturewindow.Left = p.x;
	addgrowtemperaturewindow.Top = p.y;
	addgrowtemperaturewindow.ShowDialog();
반응형