从hWnd获取(资源)ID [英] Get the (resource) ID from hWnd

查看:373
本文介绍了从hWnd获取(资源)ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ResourceHacker中,当您打开一个可执行文件(windows)时,您可以看到与对话框相关联的标识符。有谁有一个想法,他们来自哪里?我的意思是,我怎么能在我的C ++程序中从HWND获取ID?



BTW,GetWindowLong(hwnd,GWL_ID) >

谢谢

解决方案

GetWindowLong(hwnd,GWL_ID )在对话框中返回控件的标识符,但不能用于对话框本身,因为对话框只是没有标识符。



与对话框相关联的标识符实际上用于引用资源blob本身,而不是窗口。它们用于创建对话框(请参阅 CreateDialog()



创建对话框后,没有与原始模板或该标识符的连接。实际上没有对该ID的使用,对话框注意,您可以使用相同的对话框资源创建几个不同的对话框。



这些标识符可以通过 HWND (通常)由资源编辑器按顺序分配,或者如果您手动创建资源,则手动分配。



有关主题的更多信息,您可以阅读有关 CreateDialogIndirect()函数,创建一个对话框 使用电子邮件。


In ResourceHacker, when you open an executable (windows), you can see identifiers associated with dialogs. Does anyone have an idea from where they come? I mean, how can I do the same in my C++ program to get the ID from a HWND?

BTW, GetWindowLong(hwnd, GWL_ID) returns 0.

Thanks

解决方案

The GetWindowLong(hwnd, GWL_ID) returns the identifier of a control in a dialog, but it cannot be used for the dialog itself, because dialogs simply don't have identifiers.

The identifiers associated with dialogs are actually used to refer to the resource blob itself, not to the window. They are used to create the dialog (see CreateDialog().

Once the dialog is created there is no connection to the original template or to that identifier. Actually there is no use for that ID, the dialog is simply identified by its HWND. Note that you can create several different dialog using the same dialog resource.

These identifiers are assigned (usually) sequentially by the resource editor, or manually if you create the resources by hand.

For more insight on the topic you can read about the CreateDialogIndirect() function, that creates a dialog without using a resouce.

这篇关于从hWnd获取(资源)ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆