winfrom 获取焦点控件
程序员文章站
2022-06-13 08:29:55
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Winapi)] internal static extern IntPtr GetFocus(); ///获取 当前拥有焦点 ......
[dllimport("user32.dll", charset = charset.auto, callingconvention = callingconvention.winapi)] internal static extern intptr getfocus(); ///获取 当前拥有焦点的控件 private control getfocusedcontrol() { control focusedcontrol = null; intptr focusedhandle = getfocus(); if (focusedhandle != intptr.zero) focusedcontrol = control.fromchildhandle(focusedhandle); return focusedcontrol; }
原文连接:
上一篇: 了解annotation