0

I wrote an application in C# that brings another application to the foreground.

This function so far. However, there is a problem.

If you set the focus, the application is opened and brought to the foreground, but the Windows docking function does not work. The application is only ever opened in its last window size.

EDIT: I forgot to mention that the docking should be seen on the Windows desktop (monitor edge).

Does anyone have any idea how to get the docking feature on?

        [DllImport("../user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);

        [DllImport("../user32.dll")]
        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        public void SetWindowToForeground(List<string> formattedPartList)
        {
            string windowTitle = formattedPartList[4];
            int activeResize = 5; // 

            IntPtr mainWindowHandle = GetProcessIdByName(windowTitle);
  
            SetForegroundWindow(mainWindowHandle);
            ShowWindow(mainWindowHandle, activeResize);
        }
3252
  • 21
  • 3
  • You mean you want to dock the window at the edge of the desktop? – Elie Asmar Nov 10 '21 at 14:07
  • Yes. If you dock a window on the edge, the window is then in the background and then the focus is activated, the window is then brought forward, but in its last window size and no longer docked. I would like to have it docked again at the edge. – 3252 Nov 10 '21 at 14:51

0 Answers0