用什么API可以得到Windows操作系统中当前获得焦点的句柄? 如题! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 只用GetFocus();是不行的,GetFocus();只能取得本程序内的焦点句柄,下面的函数可以取得所有程序的焦点句柄Function GetCurHandle:THandle;begin AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), True); Result := GetFocus(); AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), False);end; GenieWin(精灵太保) ( ) 信誉:99-----------------------------------------你的方法好像也不行,还有其它的方法吗?我要的是:获得整个屏幕中当前窗口的句柄,那个窗口可能是属于本程序,也可能是属于其它的window程序。 那你就用 SetForegroundWindow 吧.如果还是不行就用下面的:(加了GetParent)Function GetActiveHandle:THandle;begin AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), True); Result := GetParent(GetFocus()); AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), False);end; windows提供了这样的API,得到当前活动窗口的句柄. 那到底是哪个API撒?老大,讲讲吧 看来这个问题太偏了,把CSDN的老大们全难倒了。不好意思 函数原型:HWND GetActiveWindow(VOID)获得与调用线程的消息队列相关的活动窗口的窗口句柄。GetActiveWindow返回活动窗口句柄. 到这个地址http://www.fm201.com的 “下载中心” 看看,希望有帮助 如何绑架视频采集卡的程序? dbgird中选择多条记录,如何批量更新某一字段值? format一个sql语句时的百分号问题 double和real型有什么区别 各位高手,对以下查询语句有何意见 各位大虾请指教:线程如何获得消息并进行处理 关于“系统服务程序” delphi 控制excel列的问题 如何按enter键跳到下一个DBEdit框(按Tab Order) 新手又有好菜送上,很嫩很嫩!!! (60分送給你) 试用Delphi 2006,还是那句老话, 伟大的Borland,伟大的Delphi! 常量定义问题$的意思?
下面的函数可以取得所有程序的焦点句柄Function GetCurHandle:THandle;
begin
AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), True);
Result := GetFocus();
AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), False);
end;
-----------------------------------------
你的方法好像也不行,还有其它的方法吗?
我要的是:获得整个屏幕中当前窗口的句柄,那个窗口可能是属于本程序,也可能是属于其它的window程序。
如果还是不行就用下面的:(加了GetParent)Function GetActiveHandle:THandle;
begin
AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), True);
Result := GetParent(GetFocus());
AttachThreadInput(GetCurrentThreadId, GetWindowThreadProcessId(GetForegroundWindow(), nil), False);
end;
获得与调用线程的消息队列相关的活动窗口的窗口句柄。
GetActiveWindow
返回活动窗口句柄.
http://www.fm201.com
的 “下载中心” 看看,希望有帮助