win32下怎样得到窗口的句柄HWND?

guguqiaqia 2009-09-16 04:16:06
前提是我这个窗口没有CAPTION.
也就是说用FindWindow函数, 无法指定caption.

在win32下,不是MFC

还有其它方法吗?或者是如何修改FindWindow ?
...全文
326 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
tangpeng4703 2009-09-18
  • 打赏
  • 举报
回复
FindWindow()用啊..
Huqing008 2009-09-17
  • 打赏
  • 举报
回复
FindWindow()与GetWindow()配合着使用
tutu08 2009-09-17
  • 打赏
  • 举报
回复
创建窗口时创建一个类名试试
  • 打赏
  • 举报
回复
SetProp 给窗口一个附加属性。
GetProp

//以下方法本人没用过,上面可以
SetWindowLong
GWL_USERDATA
Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero.
zngsai 2009-09-16
  • 打赏
  • 举报
回复
你把鼠标放到窗口上,然后用WindowFromPoint

The WindowFromPoint function retrieves a handle to the window that contains the specified point.

HWND WindowFromPoint(
POINT Point // point
);
Parameters
Point
[in] Specifies a POINT structure that defines the point to be checked.
Return Values
The return value is a handle to the window that contains the point. If no window exists at the given point, the return value is NULL. If the point is over a static text control, the return value is a handle to the window under the static text control.
Qt-UI 2009-09-16
  • 打赏
  • 举报
回复
枚举窗口 EnumWindows
MoXiaoRab 2009-09-16
  • 打赏
  • 举报
回复
FindWindow(窗体类名,NULL);

还可以使用GetWindow来遍历窗口
  • 打赏
  • 举报
回复
在程序A中,被控制的窗口

struct Tag_STRUCT
{
HWND hWnd;
} ;

struct Tag_STRUCT Struct;

Struct.hWnd = m_hWnd;
WritePrivateProfileStruct("Section","Key",&Struct,sizeof(Struct),"C:\\1.ini");


程序B中

struct Tag_STRUCT
{
HWND hWnd;
} ;

struct Tag_STRUCT Struct;

GetPrivateProfileStruct("Section","Key",&Struct,sizeof(Struct),"C:\\1.ini");

HWND hwnd = ::FindWindow(NULL,"wuming");

if(hwnd != NULL)
MessageBox("Found!");



if(hwnd == Struct.hWnd )
MessageBox("the same !");

::ShowWindow(hwnd,SW_HIDE);

fishion 2009-09-16
  • 打赏
  • 举报
回复
如果是你的窗口,你创建窗口时就创建一个类名
guguqiaqia 2009-09-16
  • 打赏
  • 举报
回复
不是很懂.
Randyqiu 2009-09-16
  • 打赏
  • 举报
回复
把那个程序开着,用spy++可以看到它的类名的
  • 打赏
  • 举报
回复
打错了....把窗口句柄写入文件....
  • 打赏
  • 举报
回复
把文件句柄写入文件,其他程序读取
guguqiaqia 2009-09-16
  • 打赏
  • 举报
回复
也就是说findwindow函数的第一个参数,可以是对话框属性Class name中指定的值了 ?
xylicon 2009-09-16
  • 打赏
  • 举报
回复
FindWindow 可以通过class name
其他的可以用
EnumWindows
I_NBFA 2009-09-16
  • 打赏
  • 举报
回复
窗口没标题不怕,肯定有类名,不过一个窗口类可以创建N个窗口,就算窗口标题也可以重复.
区别窗口的唯一凭证就是HWND, 没有HWND你只能分析窗口特征了.
WuXinyang 2009-09-16
  • 打赏
  • 举报
回复
ClassName也可以吧.
窗口样式啊等等,都行的
youyifang 2009-09-16
  • 打赏
  • 举报
回复
caption??是ClassName.
EnumWindows可以查找.

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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