I’m trying to “link” my form to another window, like this. I’ve done this using the Form.Show(IWin32Window owner) method. This is working pretty good, with 1 exception… When the owner window has focus and I click its icon in the taskbar, the owner window (and my window) minimizes nicely.
However, when my Form has focus, and I click the icon of the owner window in the taskbar, I would expect the owner window to regain focus, but it doesn’t. My form’s border flickers indicating it has focus. I can take the focus away from my Form by clicking somewhere in the owner window’s bounds, but I would think clicking the icon in the taskbar would do the same?
Is there maybe a different way to “link” my form to the other window without this focus problem? .ShowDialog(IWin32Window) isn’t what I’m looking for I think because it wants focus all the time, I want my Form to always stay on top but not always have focus.
I’m using a borderless form, so I’m not seeing the “flicker” indicating my form has focus unless I turn borderless off. If there is no way to “link” my Form differently, is there maybe a way to catch this window message so I can implement my own “flicker”?
public class ParentWndWrapper : IWin32Window
{
IntPtr m_Handle;
public ParentWndWrapper(IntPtr pParent){m_Handle = pParent;}
public IntPtr Handle{get { return m_Handle; }}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Process[] processArray = Process.GetProcessesByName("Photoshop");
Process photoshopProcess = processArray[0];
IntPtr photoshopHWND = photoshopProcess.MainWindowHandle;
var win32Wrapper = new ParentWndWrapper(photoshopHWND);
Show(win32Wrapper);
}
}