找回密码
 加入
搜索
查看: 2859|回复: 6

[系统综合] 求助,怎样让一个窗口或者控件始终占有焦点,直到该窗口销毁~

    [复制链接]
发表于 2017-8-16 07:41:21 | 显示全部楼层 |阅读模式
不考虑使用GUISetState
目前我尝试注册了WM_COMMAND消息
伪代码如下:
if $WM_KILLFOCUS And (句柄=窗口句柄 or 句柄 = 控件句柄) then return
运行未得到想要的结果

求大家指点下。
@afan,A大,我搜索到一个帖子,看你回过一个类似的贴。求指点~~
 楼主| 发表于 2017-8-16 12:56:14 | 显示全部楼层
回复 2# afan
尝试着写了一下,基本能实现功能,但未达预期效果。
求A大帮看下,代码怎么改一下。
Func _WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
        if $lParma <> $hForm then           ;$hForm  窗体句柄
                Winactive($hForm)
                GUICtrlSetState($Inptu,@GUI_FOCUS)     ;$hForm  控件句柄
        Endif
EndFunc
发表于 2017-8-16 11:20:24 | 显示全部楼层
注册 WM_ACTIVATE 消息
发表于 2017-8-16 11:44:21 | 显示全部楼层
from MSDN  

While processing this message, do not make any function calls that display or activate a window. This causes the thread to yield control and can cause the application to stop responding to messages. For more information, see Message Deadlocks.
发表于 2017-8-16 14:06:12 | 显示全部楼层
细节自行研究吧
Global $hForm = GUICreate('')
Global $Input = GUICtrlCreateInput('', 100, 100, 120, 20)
GUISetState()
GUIRegisterMsg('0x0006', '_WM_ACTIVATE')

While GUIGetMsg() <> -3
WEnd

Func _WM_ACTIVATE($hWnd, $msg, $wParam, $lParam)
        If Not $wParam Then
                WinActivate($hForm)
                GUICtrlSetState($Input, 0x100)
        EndIf
EndFunc   ;==>WM_ACTIVATE
发表于 2017-8-16 14:38:55 | 显示全部楼层
回复 5# afan


    这种方式不保险,,,连续快速在其他窗口点击鼠标。。。。会导致程序获取不到焦点。。
发表于 2017-8-16 15:31:19 | 显示全部楼层
回复 6# yamakawa


    有两个字叫细节
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-24 11:05 , Processed in 0.074417 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表