FindWindowW not working for form controls



Hi All

I have been trying for hours to get a handle to the controls on my form with no luck.
I have tried a number of different veriations of FindWindow with no luck. It seems to only work for top level Forms, I can get the handle to them fine, but nothing on the form itself.

Some backgroung:
I am using Windows Mobile 5 with CF2.0
Have 2 applications AppMain and AppToTest.
I load up AppMain and on it there is a button, when I click the button I start AppToTest as a Process using Process.Start("AppToTest Path","").
This all works fine. I can even get the MainWindowHandle from the process.
The problem comes when trying to get hold of the Handles for the Buttons or Edit boxes on that AppToTest form.

I have opened Remote Spy and I can see them there but I can seem to get hold of then.

How does every one else do it?
I don't even mined looping round all the forms controls getting the handles that way but I cant even see how that could be done cose there doesn't seem to be any enumWindows API.

Any help would be much appriciated. Bellow I have attached some of the fings I have tried and I always seem to get a 0 returned.


Thanks,
Ink





Some Examples of things I have tried.

[DllImport("coredll.dll", EntryPoint = "FindWindowW", SetLastError = true)]
static extern IntPtr FindWindowW(string lpClassName, string lpWindowName);

[DllImport("coredll.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);


[DllImport("coredll.dll", EntryPoint = "FindWindow", SetLastError = true, CharSet = CharSet.Auto)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

FindWindowW(null, "Set TB Text")

FindWindowW("", "Set TB Text")

FindWindowW("Edit", null)

FindWindowW("Edit", "My Text Box")

FindWindowEx(2080908848, IntPtr.Zero, "Edit", "My Text Box")

FindWindowEx(2080908848, IntPtr.Zero, "Button", "Set TB Text")

FindWindowEx(2080908848, 0, "Button", "Set TB Text")



.