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. How do i get the location of a control in screen coordinates?

How do i get the location of a control in screen coordinates?

Scheduled Pinned Locked Moved C#
questiontutorial
3 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.
  • F Offline
    F Offline
    FocusedWolf
    wrote on last edited by
    #1

    The reason: I made a tooltip control that doesn't rely on dllimports at all which is pretty cool i think :D and i want the control to appear below whatever button summons...I don't want to just use mouseposition and load it where the mouse clicks because that would look unprofessional i think. The question: How to i get the location of a control relative to its position on the screen. I was thinking of somehow determining incremently all the outermost parents that encase the button that i want the screen coords of and adding up some stuff... Are their any cleaner methods?

    B 1 Reply Last reply
    0
    • F FocusedWolf

      The reason: I made a tooltip control that doesn't rely on dllimports at all which is pretty cool i think :D and i want the control to appear below whatever button summons...I don't want to just use mouseposition and load it where the mouse clicks because that would look unprofessional i think. The question: How to i get the location of a control relative to its position on the screen. I was thinking of somehow determining incremently all the outermost parents that encase the button that i want the screen coords of and adding up some stuff... Are their any cleaner methods?

      B Offline
      B Offline
      Brian Nottingham
      wrote on last edited by
      #2

      Something like this maybe... Point screenPt = control.Parent.PointToScreen(control.Location);

      F 1 Reply Last reply
      0
      • B Brian Nottingham

        Something like this maybe... Point screenPt = control.Parent.PointToScreen(control.Location);

        F Offline
        F Offline
        FocusedWolf
        wrote on last edited by
        #3

        TY! worked perfectly :P Here's the code i used to put it below the button Point spot = this.button1.Parent.PointToScreen(this.button1.Location); this.panelbar.Left = spot.X; this.panelbar.Top = spot.Y + this.button1.Height;

        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