winfrom 获取焦点控件
程序员文章站
2023-11-08 21:10:58
[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; }
原文连接:
推荐阅读