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 / C++ / MFC
  4. All window handle from point

All window handle from point

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
5 Posts 4 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.
  • M Offline
    M Offline
    Member 2965471
    wrote on last edited by
    #1

    hi, how can i get all the windows handle from a point? For example if in (100,100) i have two windows overlapped, i want to get the handle of the topmost window and the handle of the other window.

    C _ C 3 Replies Last reply
    0
    • M Member 2965471

      hi, how can i get all the windows handle from a point? For example if in (100,100) i have two windows overlapped, i want to get the handle of the topmost window and the handle of the other window.

      C Offline
      C Offline
      Charles Oppermann
      wrote on last edited by
      #2

      WindowFromPoint, ChildWindowFromPointEx. For windows under windows, you'll have to EnumWindows and do your own hit testing.

      /* Charles Oppermann */ http://weblogs.asp.net/chuckop

      1 Reply Last reply
      0
      • M Member 2965471

        hi, how can i get all the windows handle from a point? For example if in (100,100) i have two windows overlapped, i want to get the handle of the topmost window and the handle of the other window.

        _ Offline
        _ Offline
        _Superman_
        wrote on last edited by
        #3

        Use EnumWindows to enumerate the windows. Use GetWindowRect to get the rectangle of the window. Then use PtInRect to check if the point of interest lies within the window rectangle.

        «_Superman_»  _I love work. It gives me something to do between weekends.

        _Microsoft MVP (Visual C++)

        Polymorphism in C

        1 Reply Last reply
        0
        • M Member 2965471

          hi, how can i get all the windows handle from a point? For example if in (100,100) i have two windows overlapped, i want to get the handle of the topmost window and the handle of the other window.

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          Additionally to what the others have said, the "get the rectangle and check if the point is inside it" method might not work with non-rectangular windows (layered windows with per-pixel alpha (see here[^]) or windows with a non-rectangular window region (see here[^]). I wonder if sending these kinds of windows the WM_NCHITTEST[^] message could tell you if the point is on the window or not.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

          C 1 Reply Last reply
          0
          • C Code o mat

            Additionally to what the others have said, the "get the rectangle and check if the point is inside it" method might not work with non-rectangular windows (layered windows with per-pixel alpha (see here[^]) or windows with a non-rectangular window region (see here[^]). I wonder if sending these kinds of windows the WM_NCHITTEST[^] message could tell you if the point is on the window or not.

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

            C Offline
            C Offline
            Charles Oppermann
            wrote on last edited by
            #5

            That's what RealChildWindowFromPoint handles.

            /* Charles Oppermann */ http://weblogs.asp.net/chuckop

            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