SetFocus函数为什么调用失败?

gwwgww 2005-09-23 05:10:52
我看了MSDN中的描述:If the function succeeds, the return value is the handle to the window that previously had the keyboard focus. If the hWnd parameter is invalid or the window is not attached to the calling thread's message queue, the return value is NULL. To get extended error information, call GetLastError.

说有两种情况会失败:
1 hWnd parameter is invalid
2 the window is not attached to the calling thread's message queue

我看了,不是第二种情况。
我想知道,什么叫“hWnd parameter is invalid ”,而且我调用GetLastError返回0.



...全文
270 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜牛 2005-09-24
  • 打赏
  • 举报
回复
代码。
wyfeizj 2005-09-24
  • 打赏
  • 举报
回复
在OnDraw()函数里面执行!
gwwgww 2005-09-23
  • 打赏
  • 举报
回复
应该不是吧,它的onSetFocus根本就没被调用
goodboyws 2005-09-23
  • 打赏
  • 举报
回复
SetFocus以后别的窗口又改回去了
gwwgww 2005-09-23
  • 打赏
  • 举报
回复
不是的,不是对话框上的LISTbox,是一个CWnd窗口上的listbox, 不知道跟父窗口的风格有没有关系
phoenix96_2000 2005-09-23
  • 打赏
  • 举报
回复
是不是在OnInitDialog中调用的,
如果是要返回FALSE才行
gwwgww 2005-09-23
  • 打赏
  • 举报
回复
我知道是这个意思,对应的窗口也没销毁, GetLastError返回0,MSDN上的描述不详,我不知道为什么会失败。我想让他得到焦点的窗口是一个listbox.

大家帮忙看看是什么原因
windyloft 2005-09-23
  • 打赏
  • 举报
回复
就是句柄是不可用的
可能是对应的window已经销毁了
fairyprince 2005-09-23
  • 打赏
  • 举报
回复
说你的句柄是非法的

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧