c# 使form窗体在系统中获得焦点
时间:2021-05-24 05:37:54
收藏:0
阅读:0
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet =System.Runtime.InteropServices.CharSet.Auto, ExactSpelling =true)]
public static extern IntPtrGetForegroundWindow(); //获得当前活动窗体的句柄
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint= "SetForegroundWindow")]
public static extern boolSetForegroundWindow(IntPtr hWnd);//设置此窗体句柄的窗体为活动窗体
GetForegroundWindow(),此函数返回一个当前活动窗体的句柄
SetForegroundWindow(this. Handle )设置自己为活动窗体
评论(0)