设置句柄显示状态、激活句柄、操作句柄获得键盘输入焦点
//SetFocus为指定的窗口设置键盘输入焦点 [DllImport("user32.dll", EntryPoint = "SetFocus")] public static extern IntPtr SetFocus(IntPtr hWnd); //SetForegroundWindow 把创建给定窗口的线程放到前台并激活该窗口 [DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] public static extern bool SetForegroundWindow(IntPtr hWnd); //ShowWindowAsync 设置由不同线程创建的窗口显示状态 [DllImport("user32.dll", EntryPoint = "ShowWindowAsync")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); //常量,隐藏 private const int SW_HIDE = 0; //常量,显示,标准状态 private const int SW_SHOWNORMAL = 1; //常量,显示,最小化 private const int SW_SHOWMINIMIZED = 2; //常量,显示,最大化 private const int SW_SHOWMAXIMIZED = 3; //常量,显示,不激活 private const int SW_SHOWNOACTIVATE = 4; //常量,显示,回复原状 private const int SW_RESTORE = 9; //常量,显示,默认 private const int SW_SHOWDEFAULT = 10;
评论前必须登录!
注册