Пример #1
0
        public static int RegisterBar(Window abWindow, double width, double height, ABEdge edge = ABEdge.ABE_TOP)
        {
            NativeMethods.APPBARDATA abd = new NativeMethods.APPBARDATA();
            abd.cbSize = Marshal.SizeOf(typeof(NativeMethods.APPBARDATA));
            IntPtr handle = new WindowInteropHelper(abWindow).Handle;

            abd.hWnd = handle;

            if (!appBars.Contains(handle))
            {
                uCallBack            = NativeMethods.RegisterWindowMessage("AppBarMessage");
                abd.uCallbackMessage = uCallBack;

                uint ret = NativeMethods.SHAppBarMessage((int)NativeMethods.ABMsg.ABM_NEW, ref abd);
                appBars.Add(handle);
                Trace.WriteLine("Created AppBar for handle " + handle.ToString());

                ABSetPos(abWindow, width, height, edge);
            }
            else
            {
                NativeMethods.SHAppBarMessage((int)NativeMethods.ABMsg.ABM_REMOVE, ref abd);
                appBars.Remove(handle);
                Trace.WriteLine("Removed AppBar for handle " + handle.ToString());

                return(0);
            }

            return(uCallBack);
        }
Пример #2
0
        public static int RegisterBar(Window abWindow, Screen screen, double width, double height, ABEdge edge = ABEdge.ABE_TOP)
        {
            lock (appBarLock)
            {
                NativeMethods.APPBARDATA abd = new NativeMethods.APPBARDATA();
                abd.cbSize = Marshal.SizeOf(typeof(NativeMethods.APPBARDATA));
                IntPtr handle = new WindowInteropHelper(abWindow).Handle;
                abd.hWnd = handle;

                if (!appBars.Contains(handle))
                {
                    uCallBack            = NativeMethods.RegisterWindowMessage("AppBarMessage");
                    abd.uCallbackMessage = uCallBack;

                    prepareForInterop();
                    uint ret = NativeMethods.SHAppBarMessage((int)NativeMethods.ABMsg.ABM_NEW, ref abd);
                    interopDone();
                    appBars.Add(handle);
                    CairoLogger.Instance.Debug("Created AppBar for handle " + handle.ToString());

                    ABSetPos(abWindow, screen, width, height, edge, true);
                }
                else
                {
                    prepareForInterop();
                    NativeMethods.SHAppBarMessage((int)NativeMethods.ABMsg.ABM_REMOVE, ref abd);
                    interopDone();
                    appBars.Remove(handle);
                    CairoLogger.Instance.Debug("Removed AppBar for handle " + handle.ToString());

                    return(0);
                }
            }

            return(uCallBack);
        }
Пример #3
0
        public MainWindow(string[] args)
        {
            //Disconnect Finsemble properly if Unhandled Exception happens. Otherwise you can disrupt your workspace.
            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

            //Example how to handle window closing event
            Closing += MainWindow_Closing;

            //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
            var handle = new WindowInteropHelper(this).EnsureHandle();

            FSBL               = new FinsembleWPF(this, handle.ToString("X"), args); // Finsemble needs the command line arguments to connect and also this Window handle to manage snapping, docking etc.
            FSBL.Connected    += Finsemble_Connected;
            FSBL.Disconnected += FSBL_Disconnected;
            var connectTask = FSBL.Connect("WPFExampleCore", JWK);
        }
Пример #4
0
        public void Init3dScene(string path)
        {
            ProcessStartInfo info = new ProcessStartInfo();

            info.FileName        = path;
            info.CreateNoWindow  = true;
            info.UseShellExecute = true;
            IntPtr     mainHandle = new WindowInteropHelper(window).Handle;
            HwndSource source     = PresentationSource.FromDependencyObject(ScalePanel) as HwndSource;

            windowHandle = source.Handle;
            Console.WriteLine(windowHandle.ToString());
            Console.WriteLine(mainHandle.ToString());
            info.Arguments = "-parentHWND " + windowHandle.ToInt32();
            app            = Process.Start(info);
            app.WaitForInputIdle();
            Win32API.EnumChildWindows(windowHandle, WindowEnum, IntPtr.Zero);
            AdaptWindow(null, null);
        }
Пример #5
0
 void Test()
 {
     IntPtr handle    = new WindowInteropHelper(this).Handle;
     string sHandle   = handle.ToString();
     IntPtr newHandle = new IntPtr(Convert.ToInt32(sHandle));
 }
Пример #6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(delegate //main thread
            {
                //WindowInteropHelper helper = new WindowInteropHelper(dockingWindow);
                //HwndSource.FromHwnd(helper.Handle).AddHook(HwndMessageHook);

                PresentationSource source = PresentationSource.FromVisual(dockingWindow);

                if (source != null)
                {
                    dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;
                    dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22;
                }

                WindowLocation    = new Point(dockingWindow.Left, dockingWindow.Top);
                WindowBottomRight = new Point(dockingWindow.Left + dockingWindow.Width, dockingWindow.Top + dockingWindow.Height);

                IntPtr windowHandle = new WindowInteropHelper(dockingWindow).Handle;

                var props = new JObject
                {
                    ["windowName"]   = dockingWindowName,
                    ["top"]          = dockingWindow.Top,
                    ["left"]         = dockingWindow.Left,
                    ["width"]        = dockingWindow.Width,
                    ["height"]       = dockingWindow.Height,
                    ["windowHandle"] = windowHandle.ToString(),
                    ["windowAction"] = "open"
                };

                //bridge.SendRPCCommand("NativeWindow", props.ToString(), dockingChannel);
            });

            routerClient.Subscribe("Finsemble.WorkspaceService.groupUpdate", delegate(object s, FinsembleEventArgs args)
            {
                var groupData = args.response?["data"]?["groupData"] as JObject;
                if (groupData == null)
                {
                    return;
                }
                dynamic thisWindowGroups       = new ExpandoObject();
                thisWindowGroups.dockingGroup  = "";
                thisWindowGroups.snappingGroup = "";
                thisWindowGroups.topRight      = false;
                foreach (var item in groupData)
                {
                    var windowsInGroup = item.Value["windowNames"] as JArray;
                    if (windowsInGroup.Where(window => (string)window == bridge.windowName).Count() > 0)
                    {
                        if ((bool)item.Value["isMovable"])
                        {
                            thisWindowGroups.dockingGroup = item.Key;
                            if ((string)item.Value["topRightWindow"] == bridge.windowName)
                            {
                                thisWindowGroups.topRight = true;
                            }
                        }
                        else
                        {
                            thisWindowGroups.snappingGroup = item.Key;
                        }
                    }
                }
                DockingGroupUpdateHandler?.Invoke(this, thisWindowGroups);
            });
        }
Пример #7
0
        private void DllInjectTestButton_OnClick(object sender, RoutedEventArgs e)
        {
            //this.HideMinimizeBox();
            IntPtr hwnd = new WindowInteropHelper(this).Handle;

            unsafe
            {
                fixed(int *p = &m_inject_id)
                {
                    string message = $"value:{*p}, address:{((int)p).ToString("X")}, HandlesScrolling:{hwnd.ToString("X")}";

                    MessageBox.Show(message);
                }
            }
        }