using System.Runtime.InteropServices;[DllImport("user32.dll", EntryPoint="SetWindowPos")]
public static extern int SetWindowPos (
int hwnd,
int hWndInsertAfter,
int x,
int y,
int cx,
int cy,
int wFlags
);
[DllImport("user32.dll", EntryPoint="FindWindow")]
public static extern int FindWindow (
string lpClassName,
string lpWindowName
);private void button1_Click(object sender, System.EventArgs e)
{
int hwnd = FindWindow("notepad", null);
SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x001|0x002|0x040);
}