Click here to Skip to main content
15,747,766 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

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");

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?
Updated 27-Mar-12 2:30am

1 solution

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)
	if (i == controlCount)
	  handle = hwnd;
	return 1;
}, IntPtr.Zero);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900