Using the next answer I am trying to programmatically reposition a citrix window, somehow the window does not move.
I assume the process name that holds the Citrix window is one of the next processes that were added in Process.GetProcesses()
after I started Citrix: Receiver, wfica32, pnamain, concentr, wfcrun32.
any help why the window does not move?
IntPtr hWnd = IntPtr.Zero;
var p1 = Process.GetProcesses().Where(p => p.Id != 0 && p.ProcessName == _processToRepositionWindowName).FirstOrDefault();
if (p1 != null && p1.MainWindowHandle != IntPtr.Zero)
{
hWnd = p1.MainWindowHandle;
//tried both options
//hWnd = p1.Handle;
}
else
{
hWnd = FindWindow(_processToRepositionWindowName, null);
if(hWnd == IntPtr.Zero)
{
hWnd = FindWindow(null, _processToRepositionWindowName);
}
}
if (hWnd != IntPtr.Zero)
{
var i = SetWindowPos(hWnd, IntPtr.Zero, windowXLocation, windowYLocation, 0, 0, SWP_NOSIZE | SWP_NOZORDER | 0x0040);
}
I have had the same issue a couple times (And not only with Citrix windows...).
You need to send an EnterSizeMove message before calling SetWindowPos. Ideally, you need to close with a ExitSizeMove message (Although I have skipped this last step a couple times).
I code in Java, but the issue is the same in any language:
I came to this solution from an AutoHotKey forum.