コード例 #1
0
        void OnSizeLocationChanged()
        {
            Point             offset     = _placementTarget.TranslatePoint(new Point(), Owner);
            Point             size       = new Point(_placementTarget.ActualWidth, _placementTarget.ActualHeight);
            HwndSource        hwndSource = (HwndSource)HwndSource.FromVisual(Owner);
            CompositionTarget ct         = hwndSource.CompositionTarget;

            offset = ct.TransformToDevice.Transform(offset);
            size   = ct.TransformToDevice.Transform(size);

            Win32.POINT screenLocation = new Win32.POINT(offset);
            Win32.ClientToScreen(hwndSource.Handle, ref screenLocation);
            Win32.POINT screenSize = new Win32.POINT(size);
            var         hwnsource  = (HwndSource)HwndSource.FromVisual(this);

            if (hwnsource != null)
            {
                Win32.MoveWindow(hwnsource.Handle, screenLocation.X, screenLocation.Y, screenSize.X, screenSize.Y, true);
            }
        }
コード例 #2
0
        void OnSizeLocationChanged()
        {
            Point offset = _placementTarget.TranslatePoint(new Point(), Owner);
            Point size = new Point(_placementTarget.ActualWidth, _placementTarget.ActualHeight);
            HwndSource hwndSource = (HwndSource)HwndSource.FromVisual(Owner);
            CompositionTarget ct = hwndSource.CompositionTarget;
            offset = ct.TransformToDevice.Transform(offset);
            size = ct.TransformToDevice.Transform(size);

            Win32.POINT screenLocation = new Win32.POINT(offset);
            Win32.ClientToScreen(hwndSource.Handle, ref screenLocation);
            Win32.POINT screenSize = new Win32.POINT(size);
            var hwnsource = (HwndSource)HwndSource.FromVisual(this);
            if(hwnsource!=null)
                Win32.MoveWindow(hwnsource.Handle, screenLocation.X, screenLocation.Y, screenSize.X, screenSize.Y, true);
        }