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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to get position a Child Window & its items?

How to get position a Child Window & its items?

Scheduled Pinned Locked Moved C#
helptutorialquestion
6 Posts 2 Posters 0 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.
  • U Offline
    U Offline
    User 10603967
    wrote on last edited by
    #1

    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 #1

                            GetWindowRect(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? :((

    L 1 Reply Last reply
    0
    • U User 10603967

      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 #1

                              GetWindowRect(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? :((

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Can you find the control with Spy++? If not, then it might not be a real control, but simply a drawing.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      U 3 Replies Last reply
      0
      • L Lost User

        Can you find the control with Spy++? If not, then it might not be a real control, but simply a drawing.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        U Offline
        U Offline
        User 10603967
        wrote on last edited by
        #3

        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:

        1 Reply Last reply
        0
        • L Lost User

          Can you find the control with Spy++? If not, then it might not be a real control, but simply a drawing.

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          U Offline
          U Offline
          User 10603967
          wrote on last edited by
          #4

          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? :((

          1 Reply Last reply
          0
          • L Lost User

            Can you find the control with Spy++? If not, then it might not be a real control, but simply a drawing.

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            U Offline
            U Offline
            User 10603967
            wrote on last edited by
            #5

            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 :)

            L 1 Reply Last reply
            0
            • U User 10603967

              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 :)

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Grats :) Bit late reply; there's a "managed spy++" for use with .NET apps. Would help if you need to access .NET specific properties.

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

              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