problem calling a P/Invoke
-
Im trying to call the function ChildWindowFromPoint but it seems that it always asumes the Parent window is in the Upperleft hand corner, meaning even if the parent form is in the lower right it wont find the child control until i click around in the area in the upper left hand corner. Its all a little hard to describe here but in anycase ill include the code on how im calling the function. Im using global mouse cords, with the upper left of the screen being 0,0. [DllImport("User32")] public static extern IntPtr ChildWindowFromPoint(int handle, int x,int y ); int chihan = (int)Form1.ChildWindowFromPoint(handle,e.X,e.Y); //show if it found a pointer MessageBox.Show(chihan.ToString()); //try to display the window text of the child control StringBuilder s = new StringBuilder(1024); Form1.GetWindowText(chihan,s,1024); MessageBox.Show(s.ToString()); I dont know what im doing wrong, i can find the parent control without a problem, reguardless of where it is located on the screen, and im using the same cords as i use in the function above, Thanks alot for your time ~Jesse
-
Im trying to call the function ChildWindowFromPoint but it seems that it always asumes the Parent window is in the Upperleft hand corner, meaning even if the parent form is in the lower right it wont find the child control until i click around in the area in the upper left hand corner. Its all a little hard to describe here but in anycase ill include the code on how im calling the function. Im using global mouse cords, with the upper left of the screen being 0,0. [DllImport("User32")] public static extern IntPtr ChildWindowFromPoint(int handle, int x,int y ); int chihan = (int)Form1.ChildWindowFromPoint(handle,e.X,e.Y); //show if it found a pointer MessageBox.Show(chihan.ToString()); //try to display the window text of the child control StringBuilder s = new StringBuilder(1024); Form1.GetWindowText(chihan,s,1024); MessageBox.Show(s.ToString()); I dont know what im doing wrong, i can find the parent control without a problem, reguardless of where it is located on the screen, and im using the same cords as i use in the function above, Thanks alot for your time ~Jesse
You probably need to convert the coords to the parents client coords. And, its going to depend on what coord system its coming from as to what you'd have to do. Try looking into PointToClient and PointToScreen. -- Joel Lucsy