How can I bring the word application window is minisized to the front using C#?

401 Views Asked by At

I'm developing a addin for office word using vsto. I'm trying to bring the word window that is minisized rebringing it to the front.I try to use winapi function SwitchToThisWindowSetForegroundWindow, SetWindowPos like this

if (handlePtr != IntPtr.Zero)
{
    Win32API.SwitchToThisWindow(handlePtr, true);
    //Win32API.ShowWindow(handlePtr, Win32API.SW_MAXIMIZE);
    ////Win32API.SetForegroundWindow(handlePtr); 
    //Win32API.SetWindowPos(handlePtr, Win32API.HWND_TOP, 0, 0, 0, 0, Win32API.SWP_NOMOVE | Win32API.SWP_NOSIZE | Win32API.SWP_SHOWWINDOW);
}

and Application.Activate(), it works how every other function like this does and only makes it flash in taskbar instead of bringing it to the front.

Is there anyway to fix this? I also try to sendkeys ‘alt+tab’ but i don't know how to direct the word process window.

0

There are 0 best solutions below