获取独立于语言的Windows句柄 [英] Get language independent windows handle

查看:56
本文介绍了获取独立于语言的Windows句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的应用程序中,我使用的是PageSetupDialog,我想移动OK并取消按钮.
我使用FindWindowEx函数来获取子窗口句柄.
我的代码如下:

Hi,

In my application I am using PageSetupDialog , I want to move OK and cancel buttons.
I used FindWindowEx function to get child window handle.
My code is as follows:

FindWindowEx(hWndPageSetup, IntPtr.Zero, "Button", "OK");
FindWindowEx(hWndPageSetup, IntPtr.Zero, "Button", "Cancel");


它在英语版本的OS上运行良好,我想用日语运行应用程序时希望得到OK和Cancel按钮的句柄,因为我已经使用Ok和Cancel英文字符串,所以我无法得到句柄.

我想独立使用这些按钮的语言!!


it is working fine in English version of OS, I want get handle of OK and Cancel button when i run my application in japanese i am not able to get handle as i have used Ok and Cancel english strings.

I want to get handle of these buttons language independent!!

Dose any body have answer to this problem?

推荐答案

没有机会,因为您不知道单击该按钮会做什么.
但是除了名称之外,您还可以使用位置(即索引),因为它不会以其他语言更改:
枚举子孩子并计数.由于数字没有变化,您可以对其进行硬编码:

No chance, because you don''t know what the button will do if clicked.
But beside the name you could use the position (i.e. index) as this won''t change in different languages:
Enumerate through the subchildren and count the number. As the number didn''t change, you can hardcode it:

IntPtr handle= FindWindowByCaption(0, "MyWindow");

int controlCount = 2; //adapt it to your dialog
int i = 0;
EnumChildWindows(handle, delegate(IntPtr hwnd, IntPtr lparam)
{
	i++; 
	if (i == controlCount)
	  handle = hwnd;
	return 1;
}, IntPtr.Zero);


这篇关于获取独立于语言的Windows句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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