『急问』如何获取窗口句柄?

dbeetle 2004-12-24 02:43:39
现有某软件,支持标准C,需要加入一小段C代码用于获取当前窗口或某指定窗口的窗口句柄
小弟一直做java,对于C完全是初学者。如果用前者到时可以轻松解决,后者,只能乞求诸位高手帮我写一个小小的实例了。
...全文
177 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
YFY 2004-12-25
  • 打赏
  • 举报
回复

如果可以使用Windows API的话,那么FindWindow可以。

如果在VC里面编程,this->hWnd 更简单。

好像没有发现C语言库函数:本身可以找到当前窗口或某指定窗口的窗口句柄。

ggg82 2004-12-25
  • 打赏
  • 举报
回复
不知道你是怎么定位窗口的,是自己程序中的窗体呢还是要获取其他程序的窗体,这里面相关函数很多,要使用先了解windows API
justoday 2004-12-25
  • 打赏
  • 举报
回复
HWND FindWindow(
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);

找指定 标题或类型 的窗体 找到的话:返回句柄
lu1172101275 2004-12-24
  • 打赏
  • 举报
回复
所有窗口类 里含成员hWnd ,this->hWnd 可实现
wenxi2004 2004-12-24
  • 打赏
  • 举报
回复
FindWindow
The FindWindow function retrieves the handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows.

HWND FindWindow(
LPCTSTR lpClassName,
LPCTSTR lpWindowName );
Parameters
lpClassName
Long pointer to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero.
lpWindowName
Long pointer to a null-terminated string that specifies the window name (the window’s title). If this parameter is NULL, all window names match.

70,020

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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