日期:2014-05-17 浏览次数:20870 次
[DllImport("user32.dll", EntryPoint = "GetWindowRect")]
private static extern bool GetWindowRect(IntPtr hWnd, ref Rectangle lpRect);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string strClassName, int nptWindowName);
private void MainForm_LocationChanged(object sender, EventArgs e)
{
IntPtr hWnd = FindWindow("Shell_TrayWnd", 0);
if (hWnd != IntPtr.Zero)
{
Rectangle rect = new Rectangle();
GetWindowRect(hWnd, ref rect);
if (this.Top >= rect.Top)
{
this.Top = rect.Top + this.Height;
}
}
}