I would like to resize the topmost windows. I have small problem in the code below. It doesnt resize the window smaller or to bigger size if the window is not maximized when the program starts. Do you have any idea to fix it?
CODE:
int handle = 0;
handle = GetForegroundWindow();
System.Drawing.Rectangle r = new System.Drawing.Rectangle();
GetWindowRect(handle, ref r);
if (jointLeft.Position.X < jointRight.Position.X - 0.15 && jointLeft.Position.X >jointRight.Position.X - 0.30)
{
Debug.WriteLine("smaller (" + r.Left + ";" + r.Top + ")" + (r.Right - r.Left - 10) + "x" + (r.Bottom - r.Top));
SetWindowPos(handle, -1, r.Left, r.Top, (r.Right - r.Left) - 10,r.Bottom - r.Top + 8, SHOWWINDOW);
} else if (jointLeft.Position.X < jointRight.Position.X - 0.30 && jointLeft.Position.X > jointRight.Position.X - 0.50)
{
Debug.WriteLine("bigger (" + r.Left + ";" + r.Top + ")" + (r.Right - r.Left + 10) + "x" + (r.Bottom - r.Top) );
SetWindowPos(handle, -1,r.Left, r.Top, (r.Right - r.Left) + 18, r.Bottom - r.Top + 8, SHOWWINDOW);
}
I’ve done top-most window resizing with “Media Player Classic – Home Cinema” application (process name is “mpc-hc”). It works for me.
Please try the following code.
Native definitions:
The Main of the Program:
Hope this helps.