Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. problem calling a P/Invoke

problem calling a P/Invoke

Scheduled Pinned Locked Moved C#
help
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jtmtv18
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • J jtmtv18

      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

      J Offline
      J Offline
      Joel Lucsy
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups