[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);
const int AW_HIDE = 0X10000;
const int AW_ACTIVATE = 0X20000;
const int AW_HOR_POSITIVE = 0X1;
const int AW_HOR_NEGATIVE = 0X2;
const int AW_VER_POSITIVE = 0X4;
const int AW_VER_NEGATIVE = 0X8;
const int AW_SLIDE = 0X40000;
const int AW_BLEND = 0X80000;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern int AnimateWindow
(IntPtr hwand, int dwTime, int dwFlags);
public static void ApplyPOS(string strWindowName)
{
try
{
Global.FormInSession = strWindowName;
if (Global.MaintenanceMode == false)
{
IntPtr hWnd = FindWindowByCaption(IntPtr.Zero, strWindowName);
if (Global.TestingMode == true)
{
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 300, 150, SWP_SHOWWINDOW);
}
else
{
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 15000, 150500, SWP_SHOWWINDOW);
}
Log.Flow_writeToLogFile("Positioning Form : " + strWindowName);
}
}
catch (Exception ex)
{
}
}
public static void RemovePOS(string strWindowName)
{
try
{
IntPtr hWnd = FindWindowByCaption(IntPtr.Zero, strWindowName);
SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_HIDEWINDOW);
}
catch (Exception ex)
{
}
}
No comments:
Post a Comment