How to get position a Child Window & its items?
-
I am able to find the Parent Window & its Child Windows, even I can find the position of the Parent Windows ... I can't find the position a its Child Window & its Child items (Button, Text Box ...) 1. The following codes to help me pinpoint the Parent & its Child Window:
IntPtr hwnd;
hwnd = FindWindow("ParentClass", "ParentTitle");WindowsEnumerator enumerator = new WindowsEnumerator(); foreach (ApiWindow top in enumerator.GetTopLevelWindows()) { foreach (ApiWindow child in enumerator.GetChildWindows(top.hWnd)) MessageBox.Show("Child Window = " + child.MainWindowTitle + ", Child ClassName = " + child.ClassName); }
2. When I found an intended Child Window, I used:
IntPtr Chd_win = IntPtr.Zero;
Chd_win = FindWindowEx(hwnd_Parent, Chd_win, "ChildWindow_Class", "ChildWindow_Tiltle"); // From one of the found Child Window in #1GetWindowRect(Chd\_win, out rect); MessageBox.Show("Child = " + Chd\_win.ToString() + ": TopLeft\_X = " + rect.Left.ToString() + ", TopLeft\_Y = " + rect.Top.ToString());
*) The result shows always TopLeft_X = 0 & TopLeft_Y = 0 Anyone can help? :((
-
I am able to find the Parent Window & its Child Windows, even I can find the position of the Parent Windows ... I can't find the position a its Child Window & its Child items (Button, Text Box ...) 1. The following codes to help me pinpoint the Parent & its Child Window:
IntPtr hwnd;
hwnd = FindWindow("ParentClass", "ParentTitle");WindowsEnumerator enumerator = new WindowsEnumerator(); foreach (ApiWindow top in enumerator.GetTopLevelWindows()) { foreach (ApiWindow child in enumerator.GetChildWindows(top.hWnd)) MessageBox.Show("Child Window = " + child.MainWindowTitle + ", Child ClassName = " + child.ClassName); }
2. When I found an intended Child Window, I used:
IntPtr Chd_win = IntPtr.Zero;
Chd_win = FindWindowEx(hwnd_Parent, Chd_win, "ChildWindow_Class", "ChildWindow_Tiltle"); // From one of the found Child Window in #1GetWindowRect(Chd\_win, out rect); MessageBox.Show("Child = " + Chd\_win.ToString() + ": TopLeft\_X = " + rect.Left.ToString() + ", TopLeft\_Y = " + rect.Top.ToString());
*) The result shows always TopLeft_X = 0 & TopLeft_Y = 0 Anyone can help? :((
-
I have use AutoIt Info to monitor all Child Windows, it found them ... however I amn't sure it works for C# ( it has Class, ClassNN,Title, Name, Advanced Class ...), I did try all of them but doesn't work well! - As you suggested I am using SPY now to see it can help!:java:
-
By using Spy I am now able to see my intended Child Windows with Handle, Caption & Class exact like the one I used ... I try it over & returning the same x=0 & y=0! However, the AutoiT find tool shows its position correctly! I can't use AutoIt with the current project (C# only) ... you can help? :((
-
Finally I found out (for now) I can't get their coordinations x,y of the Child Window. However, since I am able to go directly into its instance ... therefore I no more need it! Cheers :)
-
Finally I found out (for now) I can't get their coordinations x,y of the Child Window. However, since I am able to go directly into its instance ... therefore I no more need it! Cheers :)